kh-CHEUNG commited on
Commit
46c628d
·
verified ·
1 Parent(s): 726c7b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -83,8 +83,8 @@ def transcribe(inputs, task):
83
  return text
84
 
85
 
86
- audio_input = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio: from microphone") #gr.Audio(sources="upload", type="filepath", label="Audio: from file")
87
- audio_input_choice = gr.Radio(["audio file", "microphone"], label="Audio") #, value="audio file"
88
  task_input_choice = gr.Radio(["transcribe", "translate"], label="Task", value="transcribe")
89
 
90
  transcribe_interface = gr.Interface(
@@ -130,13 +130,17 @@ chat_interface = gr.ChatInterface(
130
 
131
  with gr.Blocks() as demo:
132
  gr.TabbedInterface([transcribe_interface, chat_interface], ["Step 1: Transcribe", "Step 2: Extract"])
 
 
 
133
 
134
  def update_audio_input(audio_input_choice):
135
  if audio_input_choice == "audio file":
136
  return gr.Audio(sources="upload", type="filepath", label="Audio: from file")
137
  elif audio_input_choice == "microphone":
138
  return gr.Audio(sources="microphone", type="filepath", label="Audio: from microphone")
139
- audio_input_choice.input(fn=update_audio_input,
 
140
  inputs=audio_input_choice,
141
  outputs=audio_input
142
  )
 
83
  return text
84
 
85
 
86
+ audio_input = gr.Audio(sources="upload", type="filepath", label="Audio: from file") #gr.Audio(sources="microphone", type="filepath", label="Audio: from microphone")
87
+ audio_input_choice = gr.Radio(["audio file", "microphone"], label="Audio Input Source", value="audio file") #
88
  task_input_choice = gr.Radio(["transcribe", "translate"], label="Task", value="transcribe")
89
 
90
  transcribe_interface = gr.Interface(
 
130
 
131
  with gr.Blocks() as demo:
132
  gr.TabbedInterface([transcribe_interface, chat_interface], ["Step 1: Transcribe", "Step 2: Extract"])
133
+
134
+ def clear_audio_input():
135
+ return None
136
 
137
  def update_audio_input(audio_input_choice):
138
  if audio_input_choice == "audio file":
139
  return gr.Audio(sources="upload", type="filepath", label="Audio: from file")
140
  elif audio_input_choice == "microphone":
141
  return gr.Audio(sources="microphone", type="filepath", label="Audio: from microphone")
142
+
143
+ audio_input_choice.input(fn=clear_audio_input, outputs=audio_input).then(fn=update_audio_input,
144
  inputs=audio_input_choice,
145
  outputs=audio_input
146
  )