Futuresony commited on
Commit
ef378d0
·
verified ·
1 Parent(s): f815b19

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import librosa
3
+ from asr import transcribe, ASR_EXAMPLES, ASR_NOTE
4
+
5
+ # Define only English and Swahili languages
6
+ ASR_LANGUAGES = {
7
+ "eng": "English",
8
+ "swh": "Swahili",
9
+ }
10
+
11
+ # Speech-to-Text Interface
12
+ mms_transcribe = gr.Interface(
13
+ fn=transcribe,
14
+ inputs=[
15
+ gr.Audio(),
16
+ gr.Dropdown(
17
+ [f"{k} ({v})" for k, v in ASR_LANGUAGES.items()],
18
+ label="Language",
19
+ value="eng English",
20
+ ),
21
+ ],
22
+ outputs="text",
23
+ examples=ASR_EXAMPLES,
24
+ title="Speech-to-Text",
25
+ description="Transcribe audio in either English or Swahili.",
26
+ article=ASR_NOTE,
27
+ allow_flagging="never",
28
+ )
29
+
30
+ # Main Gradio App
31
+ with gr.Blocks() as demo:
32
+ gr.Markdown("<p align='center' style='font-size: 20px;'>MMS Speech-to-Text</p>")
33
+ gr.HTML("<center>Convert speech to text in English and Swahili.</center>")
34
+
35
+ mms_transcribe.render()
36
+
37
+ if __name__ == "__main__":
38
+ demo.queue()
39
+ demo.launch()
40
+