我是python编程的新手,但在尝试从RAVDESS数据集wav文件绘制光谱图时,我一直在与这些错误作斗争。这就是代码
`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()`
以下是错误
<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)
很抱歉,我不能更好地解释错误,但我是新手,任何形式的帮助都会令人惊讶
添加
shading='auto'
将解决此问题所以代码应该是
plt.pcolormesh(times, frequencies, spectrogram,shading='auto' )
我解决了更改我的rcparams:
plt.rcParams['pcolor.shading'] ='nearest'
的问题。 希望这能帮助别人添加
shading='auto'
将解决此问题所以代码应该是
相关问题 更多 >
编程相关推荐