tags:

views:

127

answers:

1

I am trying to read a *.wav file using scipy. I do the following:

import scipy
x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')

As a result of this code I get:

Traceback (most recent call last):
  File "test3.py", line 2, in <module>
    x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')
AttributeError: 'module' object has no attribute 'io'

Does anybody know what is wrong here? Thank you in advance.

+2  A: 

As the error says, scipy module does not have 'io'.

io.wavfile is a submodule, you need to from scipy.io import wavfile and then do wavfile.read("/usr/share/sounds/purple/receive.wav")

This gives me an error with the file you are using as an example, however...

Kimvais
Why scipy does not have io? Why people write scipy.io if scipy does not have io?
Roman
The behaviour is a bit odd and unclear to me as well. Hopefully someone more enlightened will explain why this is so...
Kimvais
Thank you for your answer. It helped to fix the problem. But a new problem appear: "cannot import name NumpyTest". I have already asked a new question about that.
Roman
...and I have answered that too :)
Kimvais