我是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)很抱歉,我不能更好地解释这些错误,但我是新手,任何帮助都将是令人惊讶的。
发布于 2021-04-11 18:14:51
Add shading='auto'将解决此问题。
所以代码应该是plt.pcolormesh(times, frequencies, spectrogram,shading='auto' )
发布于 2021-05-06 00:59:36
Add shading='auto'将解决此问题。
所以代码应该是
plt.pcolormesh(times, frequencies, spectrogram,shading='auto' )发布于 2021-03-30 00:43:46
我解决了更改rcparams:plt.rcParams['pcolor.shading'] ='nearest'的问题。希望这能对某些人有所帮助。
https://stackoverflow.com/questions/65799736
复制相似问题