not-lain commited on
Commit
69696dd
1 Parent(s): 3eb706b

added choices in the audio tab

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -19,7 +19,7 @@ seamless_client = Client("facebook/seamless_m4t")
19
 
20
 
21
 
22
- def process_speech(audio_input):
23
  """
24
  processing sound using seamless_m4t
25
  """
@@ -40,8 +40,8 @@ def process_speech(audio_input):
40
  None,
41
  audio_input, #audio_name
42
  "",
43
- "French",# source language
44
- "English",# target language
45
  api_name="/run",
46
  )
47
  out = out[1] # get the text
@@ -312,12 +312,15 @@ with gr.Blocks(theme='ParityError/Anime') as iface :
312
  image_output = gr.Markdown(label="output text")
313
  image_button = gr.Button("process image")
314
  with gr.Tab("speech to text translation"):
315
- audio_input = gr.Audio(label="talk in french",type="filepath",sources="microphone")
 
 
 
316
  audio_output = gr.Markdown(label="output text")
317
  audio_button = gr.Button("process audio")
318
  text_button.click(process_and_query, inputs=text_input, outputs=text_output)
319
  image_button.click(process_image, inputs=image_input, outputs=image_output)
320
- audio_button.click(process_speech, inputs=audio_input, outputs=audio_output)
321
 
322
 
323
  iface.queue().launch(show_error=True,debug=True)
 
19
 
20
 
21
 
22
+ def process_speech(audio_input,input_language,target_language):
23
  """
24
  processing sound using seamless_m4t
25
  """
 
40
  None,
41
  audio_input, #audio_name
42
  "",
43
+ input_language,# source language
44
+ target_language,# target language
45
  api_name="/run",
46
  )
47
  out = out[1] # get the text
 
312
  image_output = gr.Markdown(label="output text")
313
  image_button = gr.Button("process image")
314
  with gr.Tab("speech to text translation"):
315
+ with gr.Row():
316
+ input_language = gr.Dropdown(["English", "French" ], label="input language",value="French",interactive=True)
317
+ target_language = gr.Dropdown(["English", "French"], label="target language",value="English",interactive=True)
318
+ audio_input = gr.Audio(label="speak",type="filepath",sources="microphone")
319
  audio_output = gr.Markdown(label="output text")
320
  audio_button = gr.Button("process audio")
321
  text_button.click(process_and_query, inputs=text_input, outputs=text_output)
322
  image_button.click(process_image, inputs=image_input, outputs=image_output)
323
+ audio_button.click(process_speech, inputs=[audio_input,input_language,target_language], outputs=audio_output)
324
 
325
 
326
  iface.queue().launch(show_error=True,debug=True)