[SciPy-User] scipy.io.wavfile.read

0 views
Skip to first unread message

Nils Wagner

unread,
Mar 2, 2010, 2:31:04 PM3/2/10
to SciPy Users List
Hi all,

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

David Cournapeau

unread,
Mar 2, 2010, 8:24:38 PM3/2/10
to SciPy Users List
Nils Wagner wrote:
> Hi all,
>
> 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')
>

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

Nils Wagner

unread,
Mar 3, 2010, 4:47:28 AM3/3/10
to SciPy Users List
On Wed, 03 Mar 2010 10:24:38 +0900
David Cournapeau <da...@silveregg.co.jp> wrote:
> Nils Wagner wrote:
>> Hi all,
>>
>> 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')
>>
>
> 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).
>

Is it possible to improve the message returned by
wavfile.read in case of special encodings ?

Nils

Reply all
Reply to author
Forward
0 new messages