zakihassan04 commited on
Commit
ed9ecf7
·
verified ·
1 Parent(s): 404180f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # 1) Load ASR pipeline
5
+ asr = pipeline(
6
+ "automatic-speech-recognition",
7
+ model="tacab/ASR_SOMALI",
8
+ chunk_length_s=30, # haddii audio-ga dheer yahay
9
+ device=-1 # CPU; haddii GPU jiro, device=0
10
+ )
11
+
12
+ def transcribe(audio):
13
+ # audio waa path/wav array
14
+ result = asr(audio, return_timestamps=False)
15
+ text = result["text"]
16
+ return text
17
+
18
+ # 2) Gradio Interface
19
+ with gr.Blocks() as demo:
20
+ gr.Markdown("## Tacab Somali ASR Module")
21
+ with gr.Row():
22
+ mic = gr.Audio(source="microphone", type="filepath", label="Record Somali Input")
23
+ btn = gr.Button("Transcribe")
24
+ txt_out = gr.Textbox(label="Transcription")
25
+ btn.click(fn=transcribe, inputs=mic, outputs=txt_out)
26
+
27
+ if __name__ == "__main__":
28
+ demo.launch()