Could not read some .wav files using scipy.io.wavread.read ()

I am trying to read a wav file using scipy.io.wavread. It reads the file correctly. For some files, it gives the 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 be unchanged 

Can someone suggest me some solution?

+4
source share
1 answer

I use the code below to read wav files. I know this does not solve your problem, but maybe you can read your wav file with this code and maybe figure out what is wrong?

My experience is that wav files sometimes contain “weird” things that need to be processed or deleted.

Hope this helps you.

Rgds

Cyrex

 import wave import struct def wavRead(fileN): waveFile = wave.open(fileN, 'r') NbChanels = waveFile.getnchannels() data = [] for x in range(NbChanels): data.append([]) for i in range(0,waveFile.getnframes()): waveData = waveFile.readframes(1) data[i%(NbChanels)].append(int(struct.unpack("<h", waveData)[0])) RetAR = [] BitDebth = waveFile.getsampwidth()*8 for 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 
0
source

Source: https://habr.com/ru/post/1480104/


All Articles