Merge pull request #346 from jiawenlai1109/fix/audio-temp-leak-on-save-error

fix(audio_generator): clean up temp file when gTTS save() fails
This commit is contained in:
Alexander Myasoedov
2026-09-22 16:53:32 +03:00
committed by GitHub
@@ -88,9 +88,8 @@ def generate_audio_cross_platform(prompt: str) -> bytes:
tts = gTTS(text=prompt, lang="en")
temp_mp3_path = f"temp_audio_{uuid.uuid4().hex}.mp3"
tts.save(temp_mp3_path)
try:
tts.save(temp_mp3_path)
with open(temp_mp3_path, "rb") as f:
audio_bytes = f.read()
finally: