为什么 scipy.io 的 Scipy 的 wavefile.py 不能打开 wave 文件?

Why won't Scipy's wavefile.py from scipy.io open a wave file?

我正在尝试构建一个音频到可见波形转换器 a 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 and discovered that the non-data chunk that wavfile.py is having a hard time chewing on is a little-endian signed integer, presumably 3 bytes long, going by @mgilson's comment on this question 做了一些挖掘。

无论出于何种原因,numpy 似乎都不想使用 3 字节小端有符号整数。我想使用提到的修复 here, but I can't even load the file. Would it make sense to try to hack together a modified version of wavefile.py? Does anyone have an idea of how I can work around this? My implementation, borrowing from 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')

Scipy 根本无法读取我正在尝试使用的 24 位 WAV。感谢@WarrenWeckesser 的评论。