vuxuanhoan commited on
Commit
3f38a74
·
verified ·
1 Parent(s): a689c10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -13,12 +13,12 @@ MAX_FILE_AGE = 24 * 60 * 60 # maximum age of audio files in seconds (24 hours)
13
  async def text_to_speech(text, lang):
14
  tts = edge_tts.Communicate(text, voice=lang) # Chọn giọng nói tương ứng với ngôn ngữ
15
  fp = io.BytesIO()
16
-
17
- # Ghi âm thanh vào bộ nhớ
18
  await tts.save(fp, 'audio/mp3') # Định dạng mp3
19
  fp.seek(0)
20
 
21
- os.makedirs(AUDIO_DIR, exist_ok=True)
22
  file_name = str(time.time()) + '.mp3' # Đổi định dạng thành mp3
23
  file_path = os.path.join(AUDIO_DIR, file_name)
24
 
 
13
  async def text_to_speech(text, lang):
14
  tts = edge_tts.Communicate(text, voice=lang) # Chọn giọng nói tương ứng với ngôn ngữ
15
  fp = io.BytesIO()
16
+
17
+ # Lưu âm thanh vào bộ nhớ và lưu tệp vào AUDIO_DIR
18
  await tts.save(fp, 'audio/mp3') # Định dạng mp3
19
  fp.seek(0)
20
 
21
+ os.makedirs(AUDIO_DIR, exist_ok=True) # Đảm bảo thư mục tồn tại
22
  file_name = str(time.time()) + '.mp3' # Đổi định dạng thành mp3
23
  file_path = os.path.join(AUDIO_DIR, file_name)
24