I am loading the wave file in both method wave.readframes()
and librosa.load()
import librosa
import wave
sample_wave = './data/mywave.wav'
#open file and stft by librosa
a, sr = librosa.load(sample_wave,sr=44100)
print(len(a))
print(a)
#open file and by wave
wav=wave.open(sample_wave)
data=wav.readframes(wav.getnframes())
b = np.frombuffer(data,dtype=np.int16)
print(len(b))
print(b)
It shows the result like this
490255 #(length of by the librosa data)
[-3.0517578e-05 3.9672852e-04 -3.0517578e-05 ... 3.0517578e-05
3.0517578e-05 0.0000000e+00] #(the data by librosa)
490255 #(length of by the wave data)
[-1 13 -1 ... 1 1 0] #(the data by wave)
OK length of both are the same as 490255.
However data is completely not the same ( I guess data by wave
is almost one-third of data by librosa
??)
Why this difference happens???