I'm a rookie to python programming but I have been battling these errors for the longest when trying to plot spectrograms from the RAVDESS dataset wav files. This is the code;
`for file in range(0 , len(listOfFiles) , 1):
windows_size = 20
sample_rate , samples = wavfile.read(listOfFiles[file])
nperseg = int(round(20 * sample_rate / 1e3))
frequencies , times, spectrogram = signal.spectrogram(samples, sample_rate)
plt.pcolormesh(times, frequencies, spectrogram)
plt.imshow(spectrogram)
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.show()`
Here are the errors
<ipython-input-16-dc119f345487>:14: WavFileWarning: Chunk (non-data) not understood, skipping it.
sample_rate , samples = wavfile.read(listOfFiles[file])
<ipython-input-16-dc119f345487>:14: WavFileWarning: Incomplete chunk ID: b'\x00', ignoring it.
sample_rate , samples = wavfile.read(listOfFiles[file])
<ipython-input-16-dc119f345487>:17: MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3. Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading']. This will become an error two minor releases later.
plt.pcolormesh(times, frequencies, spectrogram)
Sorry that I cant explain the errors better but I'm new to this, any kinda help would be amazing.
Add shading='auto'
will resolve this.
So the code should be
plt.pcolormesh(times, frequencies, spectrogram,shading='auto' )
I solved the issue changing my rcparams: plt.rcParams['pcolor.shading'] ='nearest'
.
Hope that this will help someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With