MiklX commited on
Commit
bf488ff
·
1 Parent(s): 9496fa1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -6,6 +6,8 @@ import tempfile
6
  import os
7
  import requests
8
 
 
 
9
  app = Flask(__name__)
10
 
11
  CORS(app)
@@ -20,9 +22,10 @@ def index():
20
 
21
  # Получение текста из формы
22
  input_text = request.form.get('text')
23
-
 
24
  # Генерируем аудио
25
- tts = gTTS(text=input_text, lang="ru", slow=False)
26
 
27
  # Создаем временный файл и сохраняем в него аудио
28
  temp_file = tempfile.NamedTemporaryFile(suffix=".mp3", delete=False)
 
6
  import os
7
  import requests
8
 
9
+ from langdetect import detect
10
+
11
  app = Flask(__name__)
12
 
13
  CORS(app)
 
22
 
23
  # Получение текста из формы
24
  input_text = request.form.get('text')
25
+ language_code = detect(input_text)
26
+
27
  # Генерируем аудио
28
+ tts = gTTS(text=input_text, lang=language_code, slow=False)
29
 
30
  # Создаем временный файл и сохраняем в него аудио
31
  temp_file = tempfile.NamedTemporaryFile(suffix=".mp3", delete=False)