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 authored and GitHub committed 2026-09-22 16:53:32 +03:00
commit bdf2208f6b
1 file changed
+1 -2
@@ -88,9 +88,8 @@ def generate_audio_cross_platform(prompt: str) -> bytes:
tts = gTTS(text=prompt, lang="en") tts = gTTS(text=prompt, lang="en")
temp_mp3_path = f"temp_audio_{uuid.uuid4().hex}.mp3" temp_mp3_path = f"temp_audio_{uuid.uuid4().hex}.mp3"
tts.save(temp_mp3_path)
try: try:
tts.save(temp_mp3_path)
with open(temp_mp3_path, "rb") as f: with open(temp_mp3_path, "rb") as f:
audio_bytes = f.read() audio_bytes = f.read()
finally: finally: