我正在尝试建立音频到可见波形转换器 la 的联觉,但是我遇到了一个很小的错误:
/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 documentation进行了一些挖掘,发现wavfile.py很难咀嚼的非数据块是一个小尾数带符号的整数,大概是3个字节,由@mgilson发表在this question上。
无论出于何种原因,numpy似乎都不希望使用3字节的Little-Endian带符号整数。我以为可以使用提到的here修复程序,但是我什至无法加载文件。尝试一起破解wavefile.py的修改版本是否有意义?有人知道我该如何解决吗?我从this借用的实现是:
from scipy import signal
from scipy.io import wavfile
import scipy.io.wavfile
M=1024
rate, 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 :(得分:0)
Scipy根本无法读取我要使用的24位WAV。感谢@WarrenWeckesser的评论。