datbkpro commited on
Commit
ce3dc78
·
verified ·
1 Parent(s): a3a07d7

Update core/tts_service.py

Browse files
Files changed (1) hide show
  1. core/tts_service.py +18 -0
core/tts_service.py CHANGED
@@ -182,6 +182,24 @@ class EnhancedTTSService:
182
  temp_dir = "temp_audio"
183
  os.makedirs(temp_dir, exist_ok=True)
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  filepath = os.path.join(temp_dir, filename)
186
  with open(filepath, 'wb') as f:
187
  f.write(audio_bytes)
 
182
  temp_dir = "temp_audio"
183
  os.makedirs(temp_dir, exist_ok=True)
184
 
185
+ filepath = os.path.join(temp_dir, filename)
186
+ with open(filepath, 'wb') as f:
187
+ f.write(audio_bytes)
188
+
189
+ return filepath
190
+ def save_tts_audio(self, audio_bytes: bytes, filename: str = None) -> str:
191
+ """Lưu audio bytes thành file tạm thời - tương thích với chat service"""
192
+ if audio_bytes is None:
193
+ return None
194
+
195
+ if filename is None:
196
+ import time
197
+ filename = f"tts_output_{int(time.time())}.mp3"
198
+
199
+ import os
200
+ temp_dir = "temp_audio"
201
+ os.makedirs(temp_dir, exist_ok=True)
202
+
203
  filepath = os.path.join(temp_dir, filename)
204
  with open(filepath, 'wb') as f:
205
  f.write(audio_bytes)