Skip to content

Commit

Permalink
add cleanup for generated audio files; ensure temporary files are rem…
Browse files Browse the repository at this point in the history
…oved after processing
  • Loading branch information
nwaughachukwuma committed Nov 26, 2024
1 parent 24204a8 commit ca32906
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/src/utils/generate_audiocast.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from fastapi import BackgroundTasks, HTTPException

from src.services.storage import StorageManager
Expand Down Expand Up @@ -36,6 +38,9 @@ def post_generate_audio(
waveform_utils.run_all()
except Exception as e:
print(f"Error in generate_audiocast background_tasks: {str(e)}")
finally:
if os.path.exists(audio_path):
os.remove(audio_path)


async def generate_audiocast(request: GenerateAudioCastRequest, background_tasks: BackgroundTasks):
Expand Down

0 comments on commit ca32906

Please sign in to comment.