Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -106,17 +106,24 @@ def nllb(model_name, sl, tl, input_text):
|
|
| 106 |
@spaces.GPU
|
| 107 |
def translate_text(input_text: str, sselected_language: str, tselected_language: str, model_name: str) -> str:
|
| 108 |
"""
|
| 109 |
-
Translates the input text from the source language to the target language.
|
| 110 |
|
| 111 |
-
|
| 112 |
input_text (str): The source text to be translated
|
| 113 |
sselected_language (str): The source language of the input text
|
| 114 |
tselected_language (str): The target language in which the input text is translated
|
| 115 |
-
model_name (str): The selected translation model
|
| 116 |
|
| 117 |
Returns:
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
"""
|
|
|
|
| 120 |
sl = all_langs[sselected_language]
|
| 121 |
tl = all_langs[tselected_language]
|
| 122 |
message_text = f'Translated from {sselected_language} to {tselected_language} with {model_name}'
|
|
|
|
| 106 |
@spaces.GPU
|
| 107 |
def translate_text(input_text: str, sselected_language: str, tselected_language: str, model_name: str) -> str:
|
| 108 |
"""
|
| 109 |
+
Translates the input text from the source language to the target language using a specified model.
|
| 110 |
|
| 111 |
+
Parameters:
|
| 112 |
input_text (str): The source text to be translated
|
| 113 |
sselected_language (str): The source language of the input text
|
| 114 |
tselected_language (str): The target language in which the input text is translated
|
| 115 |
+
model_name (str): The selected translation model name
|
| 116 |
|
| 117 |
Returns:
|
| 118 |
+
tuple:
|
| 119 |
+
translated_text(str): The input text translated to the selected target language
|
| 120 |
+
message_text(str): A descriptive message summarizing the translation process. Example: "Translated from English to French with Helsinki-NLP."
|
| 121 |
+
|
| 122 |
+
Example:
|
| 123 |
+
>>> translate_text("Hello world", "English", "German", "Helsinki-NLP")
|
| 124 |
+
("Hallo Welt", "Translated from English to German with Helsinki-NLP.")
|
| 125 |
"""
|
| 126 |
+
|
| 127 |
sl = all_langs[sselected_language]
|
| 128 |
tl = all_langs[tselected_language]
|
| 129 |
message_text = f'Translated from {sselected_language} to {tselected_language} with {model_name}'
|