Difference between load of librosa and read of scipy.io.wavfile
It's worth also mentioning that librosa.load()
normalizes the data (so that all the data points are between 1 and -1), whereas wavfile.read()
does not.
The data is different because scipy
does not normalize the input signal.
Here is a snippet showing how to change scipy
output to match librosa
's:
nbits = 16
l_wave, rate = librosa.core.load(path, sr=None)
rate, s_wave = scipy.io.wavfile.read(path)
s_wave /= 2 ** (nbits - 1)
all(s_wave == l_wave)
# True
From the docstring of librosa.core.load
:
Load an audio file as a floating point time series.
Audio will be automatically resampled to the given rate (default sr=22050).
To preserve the native sampling rate of the file, use sr=None.
scipy.io.wavfile.read
does not automatically resample the data, and the samples are not converted to floating point if they are integers in the file.