TiberiuCristianLeon commited on
Commit
c8b57f0
·
verified ·
1 Parent(s): 8c8a42c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
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
- translated_text = requests.get(url, params=params).text[0][0]
 
 
 
 
 
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)