Skip to content

Commit

Permalink
Attempt to convert samplerate to int before raising exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Mews committed Jun 8, 2024
1 parent 0281157 commit 4d51cef
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 @@ -44,7 +44,10 @@ def stretch_audio(
raise ValueError("'factor' must be greater than 0")

if isinstance(audio, ndarray) and not isinstance(samplerate, int):
raise TypeError(f"You must provide a valid sample rate when working with raw audio data (Not {type(samplerate)})")
try:
samplerate = int(samplerate)
except:
raise TypeError(f"You must provide a valid sample rate when working with raw audio data (Not {type(samplerate)})")


# If a file path is provided, load it as a ndarray using soundfile
Expand Down

0 comments on commit 4d51cef

Please sign in to comment.