Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,37 +6,35 @@ import traceback
|
|
| 6 |
asr = pipeline(
|
| 7 |
"automatic-speech-recognition",
|
| 8 |
model="tacab/ASR_SOMALI",
|
| 9 |
-
chunk_length_s=30, #
|
| 10 |
-
device=-1 # CPU;
|
| 11 |
)
|
| 12 |
|
| 13 |
def transcribe(audio_filepath):
|
| 14 |
"""
|
| 15 |
-
audio_filepath:
|
| 16 |
-
|
| 17 |
"""
|
| 18 |
try:
|
| 19 |
-
result = asr(audio_filepath
|
| 20 |
-
return result
|
| 21 |
except Exception as e:
|
| 22 |
-
# log full stack trace to Space logs
|
| 23 |
traceback.print_exc()
|
| 24 |
-
|
| 25 |
-
return f"Error during transcription:\n{e}"
|
| 26 |
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
-
gr.Markdown("## Tacab
|
| 29 |
with gr.Row():
|
| 30 |
mic = gr.Audio(
|
| 31 |
-
sources=["microphone"],
|
| 32 |
-
type="filepath",
|
| 33 |
-
label="
|
| 34 |
)
|
| 35 |
-
btn = gr.Button("
|
| 36 |
txt_out = gr.Textbox(
|
| 37 |
-
label="
|
| 38 |
interactive=False,
|
| 39 |
-
placeholder="
|
| 40 |
)
|
| 41 |
|
| 42 |
btn.click(fn=transcribe, inputs=[mic], outputs=[txt_out])
|
|
|
|
| 6 |
asr = pipeline(
|
| 7 |
"automatic-speech-recognition",
|
| 8 |
model="tacab/ASR_SOMALI",
|
| 9 |
+
chunk_length_s=30, # kala jar haddii audio-ga dheer yahay
|
| 10 |
+
device=-1 # CPU; haddii GPU doorato, u beddel 0
|
| 11 |
)
|
| 12 |
|
| 13 |
def transcribe(audio_filepath):
|
| 14 |
"""
|
| 15 |
+
audio_filepath: jidka faylka WAV ee la duubay.
|
| 16 |
+
Soo celi qoraalka ama fariin khalad.
|
| 17 |
"""
|
| 18 |
try:
|
| 19 |
+
result = asr(audio_filepath)
|
| 20 |
+
return result.get("text", "Qoraal lama helin.")
|
| 21 |
except Exception as e:
|
|
|
|
| 22 |
traceback.print_exc()
|
| 23 |
+
return f"Khalad inta lagu turjunayo:\n{e}"
|
|
|
|
| 24 |
|
| 25 |
with gr.Blocks() as demo:
|
| 26 |
+
gr.Markdown("## Qalabka Tacab ASR ee Af-Soomaaliga")
|
| 27 |
with gr.Row():
|
| 28 |
mic = gr.Audio(
|
| 29 |
+
sources=["microphone"],
|
| 30 |
+
type="filepath",
|
| 31 |
+
label="Duub Cod Af-Soomaali ah"
|
| 32 |
)
|
| 33 |
+
btn = gr.Button("Turjun")
|
| 34 |
txt_out = gr.Textbox(
|
| 35 |
+
label="Qoraalka Turjumaadda",
|
| 36 |
interactive=False,
|
| 37 |
+
placeholder="Halkaan ayuu qoraalkaaga ka soo muuqan doonaaβ¦"
|
| 38 |
)
|
| 39 |
|
| 40 |
btn.click(fn=transcribe, inputs=[mic], outputs=[txt_out])
|