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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -84,6 +84,7 @@ def transcribe(inputs, task):
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
 
@@ -131,20 +132,22 @@ chat_interface = gr.ChatInterface(
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
  )
147
-
148
 
149
  if __name__ == "__main__":
150
  demo.queue().launch() #demo.launch()
 
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 = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio: from file")
88
  audio_input_choice = gr.Radio(["audio file", "microphone"], label="Audio Input Source", value="audio file") #
89
  task_input_choice = gr.Radio(["transcribe", "translate"], label="Task", value="transcribe")
90
 
 
132
  with gr.Blocks() as demo:
133
  gr.TabbedInterface([transcribe_interface, chat_interface], ["Step 1: Transcribe", "Step 2: Extract"])
134
 
135
+
136
  def clear_audio_input():
137
  return None
138
 
139
  def update_audio_input(audio_input_choice):
140
  if audio_input_choice == "audio file":
141
+ return gr.Audio(sources="upload", label="Audio: from file") #, type="filepath", label="Audio: from file")
142
  elif audio_input_choice == "microphone":
143
+ return gr.Audio(sources="microphone", label="Audio: from microphone") #, type="filepath", label="Audio: from microphone")
144
 
145
+ #audio_input_choice.input(fn=clear_audio_input, outputs=audio_input).then(fn=update_audio_input,
146
+ audio_input_choice.input(fn=update_audio_input,
147
  inputs=audio_input_choice,
148
  outputs=audio_input
149
  )
150
+
151
 
152
  if __name__ == "__main__":
153
  demo.queue().launch() #demo.launch()