Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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__":
|