zanemotiwala commited on
Commit
4d6774a
·
verified ·
1 Parent(s): 8fcdd1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -3,21 +3,18 @@ import gradio as gr
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(label="Record from Microphone", type="microphone")
13
- mic_button = gr.Button("Transcribe from Microphone")
14
- with gr.Column():
15
- upload = gr.Audio(label="Upload Audio File", type="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)
 
 
3
  def transcribe_speech(audio_file):
4
  if audio_file is None:
5
  return "No audio found, please retry."
6
+ # Assuming `asr` is a function that processes the audio file at 'audio_file.name' and returns a dictionary with 'text'
7
+ output = asr(audio_file.name)
8
  return output["text"]
9
 
10
  with gr.Blocks() as demo:
11
  with gr.Row():
12
+ mic = gr.Audio(label="Record from Microphone or Upload File", type="filepath")
13
+ transcribe_button = gr.Button("Transcribe Audio")
 
 
 
 
14
 
15
  transcription = gr.Textbox(label="Transcription", lines=3, placeholder="Transcription will appear here...")
16
 
17
+ transcribe_button.click(transcribe_speech, inputs=mic, outputs=transcription)
 
18
 
19
  demo.launch(share=True)
20
+