Update app.py
Browse files
app.py
CHANGED
@@ -58,7 +58,12 @@ if submit_button:
|
|
58 |
import requests
|
59 |
url = os.environ['GTRANSURL']
|
60 |
params = {'client': 'gtx', 'sl': sselected_language, 'tl': tselected_language, 'dt': 't', 'ie': 'UTF-8', 'oe': 'UTF-8', 'q': input_text}
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
62 |
elif model_name.startswith('t5'):
|
63 |
prompt = f'translate {sselected_language} to {tselected_language}: {input_text}'
|
64 |
print(prompt)
|
|
|
58 |
import requests
|
59 |
url = os.environ['GTRANSURL']
|
60 |
params = {'client': 'gtx', 'sl': sselected_language, 'tl': tselected_language, 'dt': 't', 'ie': 'UTF-8', 'oe': 'UTF-8', 'q': input_text}
|
61 |
+
response = requests.get(url, params=params)
|
62 |
+
translated_text = response.text
|
63 |
+
try:
|
64 |
+
print(response.json(), translated_text)
|
65 |
+
except Exception as error:
|
66 |
+
print (error, translated_text)
|
67 |
elif model_name.startswith('t5'):
|
68 |
prompt = f'translate {sselected_language} to {tselected_language}: {input_text}'
|
69 |
print(prompt)
|