mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-09-30 19:59:34 +02:00
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:
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:
|
||||||
|
|||||||
Reference in new issue
Block a user