title: Why won't Scipy's wavefile.py from scipy.io open a wave file?
body: <p>I'm trying to build an audio frequency to visible waveform converter <em>a la</em> synesthesia, but I'm getting a lovely little error:</p>
  
  <pre><code>/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 "&lt;ipython-input-8-c1948c42b069&gt;", line 5, in &lt;module&gt;
      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 "&lt;i3" not understood
  </code></pre>
  
  <p>Truly pleasant. I did a little digging through numpy's dtype <a href="https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.dtype.html" rel="nofollow noreferrer">documentation</a> 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 <a href="https://stackoverflow.com/questions/12080279/how-do-i-create-a-numpy-dtype-that-includes-24-bit-integers">this question</a>. </p>
  
  <p>It seems that numpy doesn't want to play with a 3-byte little-endian signed integer, for whatever reason. I thought to use the fix mentioned <a href="https://stackoverflow.com/questions/15595928/issues-with-scipy-io-wave-file-processing-after-applying-fourier-transforms">here</a>, 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 <a href="https://www.oreilly.com/library/view/elegant-scipy/9781491922927/ch04.html#" rel="nofollow noreferrer">this</a>, is:</p>
  
  <pre><code>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')
  </code></pre>