Skip to content

Commit

Permalink
Delete invalid files when they're invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Mews committed Jun 8, 2024
1 parent 4d51cef commit 2faee0f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/simplestretch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import soundfile
from numpy import ndarray

import pathlib


def stretch_audio(
Expand Down Expand Up @@ -60,6 +60,9 @@ def stretch_audio(
try:
soundfile.write(output, audio, samplerate=stretched_samplerate)
except soundfile.LibsndfileError as exc:
# Delete invalid file
pathlib.Path.unlink(output)

exc.add_note("(Try saving it as a .wav file instead)")
raise exc

Expand Down

0 comments on commit 2faee0f

Please sign in to comment.