Tonic commited on
Commit
f1d5a1b
·
verified ·
1 Parent(s): 099e1b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
app.py CHANGED
@@ -313,7 +313,6 @@ def process_input(image=None, file=None, audio=None, text="", translateto = "Eng
313
 
314
 
315
 
316
- # Define the inputs and outputs for the Gradio Interface
317
  inputs = [
318
 
319
  gr.Dropdown(choices=choices, label="Your Native Language"),
@@ -341,24 +340,35 @@ outputs = [
341
  gr.Audio(label="Audio Output (Target Language) 3")
342
  ]
343
 
 
344
  def update_outputs(inputlanguage, target_language, audio, image, text, file):
345
  processed_text, audio_output_path, top_phrases, translations, audio_outputs = process_input(
346
  image=image, file=file, audio=audio, text=text,
347
  translateto=target_language, translatefrom=inputlanguage
348
  )
349
 
350
- audio_outputs_components = [(ao[0], ao[1]) for ao in audio_outputs]
351
- output_tuple = (processed_text, audio_output_path)
352
- for i in range(len(top_phrases)):
353
- output_tuple += (top_phrases[i], translations[i]) + audio_outputs_components[i]
354
- while len(output_tuple) < 14:
355
- output_tuple += ("", "", "", "")
 
 
 
 
 
 
 
 
 
 
 
356
  return output_tuple
357
 
358
  def interface_func(inputlanguage, target_language, audio, image, text, file):
359
  return update_outputs(inputlanguage, target_language, audio, image, text, file)
360
 
361
- # Create the Gradio interface
362
  iface = gr.Interface(fn=interface_func, inputs=inputs, outputs=outputs, title=title, description=description)
363
 
364
  if __name__ == "__main__":
 
313
 
314
 
315
 
 
316
  inputs = [
317
 
318
  gr.Dropdown(choices=choices, label="Your Native Language"),
 
340
  gr.Audio(label="Audio Output (Target Language) 3")
341
  ]
342
 
343
+
344
  def update_outputs(inputlanguage, target_language, audio, image, text, file):
345
  processed_text, audio_output_path, top_phrases, translations, audio_outputs = process_input(
346
  image=image, file=file, audio=audio, text=text,
347
  translateto=target_language, translatefrom=inputlanguage
348
  )
349
 
350
+ output_tuple = (
351
+ processed_text, # RichTextbox content
352
+ audio_output_path, # Main audio output
353
+ top_phrases[0] if len(top_phrases) > 0 else "", # Focus 1
354
+ translations[0] if len(translations) > 0 else "", # Translated Phrases 1
355
+ audio_outputs[0][0] if len(audio_outputs) > 0 else "", # Audio Output (Native Language) 1
356
+ audio_outputs[0][1] if len(audio_outputs) > 0 else "", # Audio Output (Target Language) 1
357
+ top_phrases[1] if len(top_phrases) > 1 else "", # Focus 2
358
+ translations[1] if len(translations) > 1 else "", # Translated Phrases 2
359
+ audio_outputs[1][0] if len(audio_outputs) > 1 else "", # Audio Output (Native Language) 2
360
+ audio_outputs[1][1] if len(audio_outputs) > 1 else "", # Audio Output (Target Language) 2
361
+ top_phrases[2] if len(top_phrases) > 2 else "", # Focus 3
362
+ translations[2] if len(translations) > 2 else "", # Translated Phrases 3
363
+ audio_outputs[2][0] if len(audio_outputs) > 2 else "", # Audio Output (Native Language) 3
364
+ audio_outputs[2][1] if len(audio_outputs) > 2 else "" # Audio Output (Target Language) 3
365
+ )
366
+
367
  return output_tuple
368
 
369
  def interface_func(inputlanguage, target_language, audio, image, text, file):
370
  return update_outputs(inputlanguage, target_language, audio, image, text, file)
371
 
 
372
  iface = gr.Interface(fn=interface_func, inputs=inputs, outputs=outputs, title=title, description=description)
373
 
374
  if __name__ == "__main__":