When we are using soundfile to read a wav file, we may see this error: TypeError: Not allowed for existing files (except ‘RAW’): samplerate, channels, format, subtype, endian.
In this tutorial, we will introduce how to fix.
Problem Reproduction
wav, fs = sf.read(audio_path, samplerate=samplerate)
Look at example code above, we will read an audio with specific sample rate (16k). Running this code, we will see:
Why this error occur?
In soundfile, if the audio file is not a raw file, we can not change samplerate, channels, format, subtype, endian.
How to fix?
We can use
wav, fs = sf.read(audio_path)
or
python librosa.load() to read an audio file.
Here is the tutorial:
Understand librosa.load() is Between -1.0 and 1.0 – Librosa Tutorial