jacobda commited on
Commit
cc38f71
·
1 Parent(s): 9da9992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -154,7 +154,9 @@ def translate(message, lang):
154
  else:
155
  return "Error, sorry!"
156
 
157
- def transcribe(audio, lang, history):
 
 
158
  history = history or []
159
  lang_code = LANGUAGES[lang]
160
  text = pipe(audio)["text"]
@@ -165,18 +167,14 @@ def transcribe(audio, lang, history):
165
  with gr.Blocks() as demo:
166
  history = gr.State([])
167
  with gr.Row():
168
- with gr.Column():
169
- link = gr.Textbox(label = "Put YouTube link here")
170
- audio = get_soundfile(link)
171
  with gr.Column():
172
  language = gr.Dropdown(list(LANGUAGES.keys()))
173
- if audio == None:
174
- audio = gr.Audio(source="microphone", type="filepath")
175
  submit = gr.Button(value="Translate")
176
  with gr.Column():
177
  chatbot = gr.Chatbot().style(color_map=("green", "gray"))
178
  with gr.Column():
179
  link = gr.Textbox(label = "Put YouTube link here")
180
- submit.click(transcribe, inputs=[audio, language, history], outputs=[chatbot, history])
181
 
182
  demo.launch()
 
154
  else:
155
  return "Error, sorry!"
156
 
157
+ def transcribe(audio, lang, history, link):
158
+ if link is not None:
159
+ audio = get_soundfile(link)
160
  history = history or []
161
  lang_code = LANGUAGES[lang]
162
  text = pipe(audio)["text"]
 
167
  with gr.Blocks() as demo:
168
  history = gr.State([])
169
  with gr.Row():
 
 
 
170
  with gr.Column():
171
  language = gr.Dropdown(list(LANGUAGES.keys()))
172
+ audio = gr.Audio(source="microphone", type="filepath")
 
173
  submit = gr.Button(value="Translate")
174
  with gr.Column():
175
  chatbot = gr.Chatbot().style(color_map=("green", "gray"))
176
  with gr.Column():
177
  link = gr.Textbox(label = "Put YouTube link here")
178
+ submit.click(transcribe, inputs=[audio, language, history, link], outputs=[chatbot, history])
179
 
180
  demo.launch()