Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import os
|
|
|
4 |
|
5 |
def translate_text(text, target_language):
|
6 |
try:
|
@@ -25,9 +26,11 @@ def translate_text(text, target_language):
|
|
25 |
if response.status_code == 200:
|
26 |
return response.json()['choices'][0]['message']['content'].strip()
|
27 |
else:
|
28 |
-
|
|
|
29 |
except Exception as e:
|
30 |
-
|
|
|
31 |
|
32 |
def translate_interface(text, target_language):
|
33 |
translated_text = translate_text(text, target_language)
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import os
|
4 |
+
import time
|
5 |
|
6 |
def translate_text(text, target_language):
|
7 |
try:
|
|
|
26 |
if response.status_code == 200:
|
27 |
return response.json()['choices'][0]['message']['content'].strip()
|
28 |
else:
|
29 |
+
print(f"Ошибка при переводе текста. Ошибка: {response.text}")
|
30 |
+
time.sleep(1)
|
31 |
except Exception as e:
|
32 |
+
print(f"Ошибка: {str(e)}")
|
33 |
+
time.sleep(1)
|
34 |
|
35 |
def translate_interface(text, target_language):
|
36 |
translated_text = translate_text(text, target_language)
|