Skip to content

Commit

Permalink
Refactor audio file conversion and deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Microwave-WYB committed May 21, 2024
1 parent 57fbb58 commit be7e2ce
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions phone_sensors/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ async def upload(
try:
audio: AudioSegment = AudioSegment.from_file(file_path)
audio.export(wav_file_path, format="wav")
file_path.unlink()
return submit_analyze_audio_job(redis_conn, wav_file_path, status)
except Exception as e:
if wav_file_path.exists():
wav_file_path.unlink()
raise HTTPException(status_code=400, detail=f"Error converting file to wav: {e}") from e

file_path.unlink()
return submit_analyze_audio_job(redis_conn, wav_file_path, status)

0 comments on commit be7e2ce

Please sign in to comment.