zanemotiwala commited on
Commit
7400283
·
verified ·
1 Parent(s): dd080e7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def transcribe_speech(audio_file):
4
+ if audio_file is None:
5
+ return "No audio found, please retry."
6
+ output = asr(audio_file.name) # Assuming `asr` is your speech recognition function
7
+ return output["text"]
8
+
9
+ with gr.Blocks() as demo:
10
+ with gr.Row():
11
+ with gr.Column():
12
+ mic = gr.Audio(source="microphone", type="filepath", label="Record from Microphone")
13
+ mic_button = gr.Button("Transcribe from Microphone")
14
+ with gr.Column():
15
+ upload = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
16
+ upload_button = gr.Button("Transcribe Uploaded File")
17
+
18
+ transcription = gr.Textbox(label="Transcription", lines=3, placeholder="Transcription will appear here...")
19
+
20
+ mic_button.click(transcribe_speech, inputs=mic, outputs=transcription)
21
+ upload_button.click(transcribe_speech, inputs=upload, outputs=transcription)
22
+
23
+ demo.launch(share=True)