Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -116,24 +116,20 @@ def process_request(input_text):
|
|
| 116 |
# Return the translations and contexts
|
| 117 |
return translations, context_results
|
| 118 |
|
|
|
|
| 119 |
def gradio_interface(input_text):
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
output
|
| 124 |
-
for context, translation in translations.items():
|
| 125 |
-
output.append({"context": context.capitalize(), "text": translation})
|
| 126 |
-
|
| 127 |
-
# Return the JSON-serializable object
|
| 128 |
-
return output
|
| 129 |
|
| 130 |
# Create the Gradio interface
|
| 131 |
interface = gr.Interface(
|
| 132 |
fn=gradio_interface,
|
| 133 |
inputs="text",
|
| 134 |
-
outputs="
|
| 135 |
title="Frenchizer",
|
| 136 |
-
description="Translate text from English to French with context
|
| 137 |
)
|
| 138 |
|
| 139 |
interface.launch()
|
|
|
|
| 116 |
# Return the translations and contexts
|
| 117 |
return translations, context_results
|
| 118 |
|
| 119 |
+
# Gradio interface
|
| 120 |
def gradio_interface(input_text):
|
| 121 |
+
translation, contexts = process_request(input_text)
|
| 122 |
+
# Format the output
|
| 123 |
+
output = f"Translation: {translation}\n"
|
| 124 |
+
return output.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
# Create the Gradio interface
|
| 127 |
interface = gr.Interface(
|
| 128 |
fn=gradio_interface,
|
| 129 |
inputs="text",
|
| 130 |
+
outputs="text",
|
| 131 |
title="Frenchizer",
|
| 132 |
+
description="Translate text from English to French with context detection and threshold."
|
| 133 |
)
|
| 134 |
|
| 135 |
interface.launch()
|