I was provided with a large WAV continuous underwater recording file that I would like to convert to a numpy array for analysis. I'm struggling to do this.
So far, I:
import numpy as np import scipy as sp import wave as wv import struct wavefile = wv.open(filename,'r') (nchannels,sampwidth,framerate,nframes,comptype,compname) = wavefile.getparams()
The first frame looks like this: '\ xcd \ xbc \ xff @ \ x01 \ x00'. I tried to unzip it using a struct, but unzip everything I do. I get the following error: " str size does not match format ". I think this is due to the fact that the Python structure cannot process 24-bit data.
The wave file parameter is as follows:
- nchannels = 2
- sampwidth = 3
- = 48000 frame rate
- nframes = 283516532L
- CompType = 'NONE'
- compname = 'not compression'
Does anyone know how to read a 24-bit stereo WAV file into a numpy array?
source share