RASMUS commited on
Commit
d16c9d0
1 Parent(s): 469f6b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -321,6 +321,17 @@ def translate_transcriptions(df, selected_translation_lang_2):
321
  'target_lang': DeepL_language_codes_for_translation.get(selected_translation_lang_2)
322
  }
323
  try:
 
 
 
 
 
 
 
 
 
 
 
324
  response = requests.post('https://api-free.deepl.com/v2/translate', headers=headers, data=data)
325
 
326
  # Print the response from the server
 
321
  'target_lang': DeepL_language_codes_for_translation.get(selected_translation_lang_2)
322
  }
323
  try:
324
+
325
+ usage = requests.get('https://api-free.deepl.com/v2/usage', headers=headers)
326
+ usage = json.loads(response.text)
327
+ try:
328
+ print('Usage is at: ' + str(usage['character_count']) + 'characters')
329
+ except Exception as e:
330
+ print(e)
331
+
332
+ if usage['character_count'] >= 490000:
333
+ print("USAGE CLOSE TO LIMIT")
334
+
335
  response = requests.post('https://api-free.deepl.com/v2/translate', headers=headers, data=data)
336
 
337
  # Print the response from the server