[SciPy-Dev] Suggested Change to io.wavfile
Thu Aug 9 10:08:01 CDT 2012
I'm running into a wavfile read error which appears to be caused by
slight problems in wavfile meta-data. (Specifically, the meta-data
mis-reports the number of frames). Unfortunately, 2/3 of the wav files
I've randomly sampled have this problem, and most audio packages just
deal with it.
I notice from a search that a lot of people have this problem with
/usr/lib/python2.7/site-packages/scipy/io/wavfile.pyc in read(file)
126 fmt = '<i'
--> 127 size = struct.unpack(fmt, data)
128 fid.seek(size, 1)
Here's a fix - just calculate the actual file length and use the minimum
or the file length and the meta-data reported length.
< ## Calculate the actual file length in case meta-data is incorrect
< current_pos = fid.tell()
< actual_file_length = fid.tell()
< fid.seek( current_pos )
< total_length = min( fsize, actual_file_length )
< while (fid.tell() < total_length):
> while (fid.tell() < fsize):
More information about the SciPy-Dev