python - unable to read some .wav files using scipy.io.wavread.read() -


i trying read .wav file using scipy.io.wavread. reads file properly. files giving following error...

warning (from warnings module):   file "d:\project\cardiocare-1.0\src\scipy\io\wavfile.py", line 121     warnings.warn("chunk not understood", wavfilewarning) wavfilewarning: chunk not understood traceback (most recent call last):   file "d:\project\cardiocare-1.0\src\ccare\plot.py", line 37, in plot     input_data = read(p.bitfile)   file "d:\project\cardiocare-1.0\src\scipy\io\wavfile.py", line 119, in read     data = _read_data_chunk(fid, noc, bits)   file "d:\project\cardiocare-1.0\src\scipy\io\wavfile.py", line 56, in _read_data_chunk     data = data.reshape(-1,noc) valueerror: total size of new array must unchanged 

can 1 suggest me solution?

i use below code read wav files. know not solve problem, maybee read wav file code , maybe figure out wrong?

my experience is, wav files contains "strange" things, must handled or removed.

hope helps out

rgds

cyrex

import wave import struct                       def wavread(filen):   wavefile = wave.open(filen, 'r')      nbchanels = wavefile.getnchannels()   data = []   x in range(nbchanels):       data.append([])   in range(0,wavefile.getnframes()):                      wavedata = wavefile.readframes(1)          data[i%(nbchanels)].append(int(struct.unpack("<h", wavedata)[0]))    retar = []   bitdebth = wavefile.getsampwidth()*8   x in range(nbchanels):        retar.append(np.array(data[x]))        retar[-1] = retar[-1]/float(pow(2,(bitdebth-1)))   fs = wavefile.getframerate()   return retar,fs    

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -