我试图建立一个音频可见波形转换器一拉通感,但我发现了一个可爱的小错误:/Users/nathanielastudillo/anaconda/lib/python3.6/site-packages/scipy/io/wavfile.py:172: WavFileWarning: Chunk (non-data) not understood, skipping it. WavFileWarning)Traceback (most recent call last): File "<ipython-input-8-c1948c42b069>", line 5, in <module> rate, audio = wavfile.read('3 - Headache.wav') File "/Users/nathanielastudillo/anaconda/lib/python3.6/site-packages/scipy/io/wavfile.py", line 166, in read data = _read_data_chunk(fid, comp, noc, bits, mmap=mmap) File "/Users/nathanielastudillo/anaconda/lib/python3.6/site-packages/scipy/io/wavfile.py", line 71, in _read_data_chunk data = numpy.fromstring(fid.read(size), dtype=dtype)TypeError: data type "<i3" not understood真令人愉快。我对 numpy 的 dtype文档进行了一些挖掘,发现 wavfile.py 难以咀嚼的非数据块是一个小端有符号整数,大概有 3 个字节长,根据@mgilson 对这个问题的评论。无论出于何种原因,numpy 似乎不想使用 3 字节小端有符号整数。我想使用这里提到的修复程序,但我什至无法加载文件。尝试将修改版本的 wavefile.py 拼凑在一起是否有意义?有谁知道我如何解决这个问题?我的实现,借用this,是:from scipy import signalfrom scipy.io import wavfileimport scipy.io.wavfileM=1024rate, audio = wavfile.read('3 - Headache.wav')freqs, times, spect = signal.spectrogram(audio, fs=rate, window='hanning', nperseg=1024, noverlap=M - 100, detrend=False, scaling='spectrum')
添加回答
举报
0/150
提交
取消