I tried to read a *.wav file using
scipy.io.wavfile.read
from scipy.io import wavfile
from pylab import plot, show
samplerate, data = wavfile.read('BagPipes.wav')
It failed with
/home/nwagner/local/lib64/python2.6/site-packages/pytz/__init__.py:29:
UserWarning: Module pkg_resources was already imported
from
/home/nwagner/local/lib64/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py,
but
/home/nwagner/local/lib64/python2.6/site-packages/distribute-0.6.4-py2.6.egg
is being added to sys.path
from pkg_resources import resource_stream
/home/nwagner/local/lib64/python2.6/site-packages/pytz/__init__.py:29:
UserWarning: Module site was already imported from
/usr/lib64/python2.6/site.pyc, but
/home/nwagner/local/lib64/python2.6/site-packages/distribute-0.6.4-py2.6.egg
is being added to sys.path
from pkg_resources import resource_stream
/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py:20:
WavFileWarning: Unfamiliar format bytes
warnings.warn("Unfamiliar format bytes",
WavFileWarning)
/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py:92:
WavFileWarning: chunk not understood
warnings.warn("chunk not understood", WavFileWarning)
Traceback (most recent call last):
File "read_wav.py", line 9, in <module>
samplerate, data = wavfile.read('BagPipes.wav')
File
"/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py",
line 90, in read
data = _read_data_chunk(fid, noc, bits)
File
"/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/wavfile.py",
line 43, in _read_data_chunk
data = numpy.fromfile(fid, dtype=dtype,
count=size//bytes)
ZeroDivisionError: integer division or modulo by zero
Any idea ?
The example file is available at
http://www.ilovewavs.com/Effects/Music/Music.htm
Cheers,
Nils
_______________________________________________
SciPy-User mailing list
SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
This file uses ADPCM encoding (a form of compression based on non linear
encoding of each sample), which is most likely not supported by
scipy.io.wavfile. Your two options are to convert this to a "normal" wav
file with linear encoding, or to use audiolab which supports those files
(because libsndile does).
cheeers,
David
Is it possible to improve the message returned by
wavfile.read in case of special encodings ?
Nils