Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between load of librosa and read of scipy.io.wavfile

I have a question about the difference between the load function of librosa and the read function of scipy.io.wavfile.

from scipy.io import wavfile
import librosa

fs, data = wavfile.read(name)
data, fs = librosa.load(name)

The imported voice file is the same file. If you run the code above, the values ​​of the data come out of the two functions differently. I want to know why the value of the data is different.

like image 270
이응재 Avatar asked Apr 27 '18 12:04

이응재


1 Answers

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
like image 190
Vladimir Iashin Avatar answered Oct 23 '22 02:10

Vladimir Iashin