Spaces:
Running
Running
Update app.py
Browse filesAdded the microphone live recording
app.py
CHANGED
@@ -2,23 +2,28 @@
|
|
2 |
import gradio as gr
|
3 |
from backend import KabyleASR
|
4 |
|
5 |
-
# Initialize ASR
|
6 |
asr = KabyleASR()
|
7 |
|
8 |
def transcribe_audio(audio):
|
9 |
if audio is None:
|
10 |
-
return "Please upload an audio file."
|
11 |
return asr.transcribe(audio)
|
12 |
|
13 |
-
# Gradio Interface
|
14 |
with gr.Blocks() as demo:
|
15 |
gr.Markdown("""
|
16 |
# 🎤 Tanti: Kabyle ASR (Free Tier)
|
17 |
-
Upload a Kabyle audio file
|
|
|
18 |
""")
|
19 |
|
20 |
with gr.Row():
|
21 |
-
audio_input = gr.Audio(
|
|
|
|
|
|
|
|
|
22 |
|
23 |
with gr.Row():
|
24 |
transcribe_btn = gr.Button("Transcribe")
|
@@ -26,8 +31,9 @@ with gr.Blocks() as demo:
|
|
26 |
with gr.Row():
|
27 |
output_text = gr.Textbox(label="Transcription", lines=8)
|
28 |
|
|
|
29 |
transcribe_btn.click(fn=transcribe_audio, inputs=audio_input, outputs=output_text)
|
30 |
|
31 |
-
# Launch without SSR
|
32 |
if __name__ == "__main__":
|
33 |
demo.launch(ssr_mode=False)
|
|
|
2 |
import gradio as gr
|
3 |
from backend import KabyleASR
|
4 |
|
5 |
+
# Initialize ASR (happens once at startup)
|
6 |
asr = KabyleASR()
|
7 |
|
8 |
def transcribe_audio(audio):
|
9 |
if audio is None:
|
10 |
+
return "Please upload or record an audio file."
|
11 |
return asr.transcribe(audio)
|
12 |
|
13 |
+
# Gradio Interface
|
14 |
with gr.Blocks() as demo:
|
15 |
gr.Markdown("""
|
16 |
# 🎤 Tanti: Kabyle ASR (Free Tier)
|
17 |
+
Upload a Kabyle audio file or **record live** using your microphone.
|
18 |
+
⚠️ *Transcription may take 30–60 seconds due to CPU-only processing.*
|
19 |
""")
|
20 |
|
21 |
with gr.Row():
|
22 |
+
audio_input = gr.Audio(
|
23 |
+
sources=["upload", "microphone"], # ✅ Fixed: Added microphone
|
24 |
+
type="filepath",
|
25 |
+
label="Record or Upload Audio"
|
26 |
+
)
|
27 |
|
28 |
with gr.Row():
|
29 |
transcribe_btn = gr.Button("Transcribe")
|
|
|
31 |
with gr.Row():
|
32 |
output_text = gr.Textbox(label="Transcription", lines=8)
|
33 |
|
34 |
+
# Connect button to function
|
35 |
transcribe_btn.click(fn=transcribe_audio, inputs=audio_input, outputs=output_text)
|
36 |
|
37 |
+
# Launch without SSR (required for Hugging Face)
|
38 |
if __name__ == "__main__":
|
39 |
demo.launch(ssr_mode=False)
|