Megh Parikh
Megh Parikh

Reputation: 964

python : how to use wave module?

when I try the following program :

import wave  
w = wave.open('f.wav', 'r')  
for i in range():  
    frame = w.readframes(i)  

the following error comes :

Traceback (most recent call last):  
  File "F:/Python31/fg.py", line 2, in <module>  
    w = wave.open('f.wav', 'r')  
  File "F:\Python31\lib\wave.py", line 498, in open  
    return Wave_read(f)  
  File "F:\Python31\lib\wave.py", line 159, in __init__  
    f = builtins.open(f, 'rb')  
IOError: [Errno 2] No such file or directory: 'f.wav'  

can u tell me wat could b the reason ???

Upvotes: 0

Views: 2495

Answers (2)

cmaynard
cmaynard

Reputation: 2860

You are running the python script from a directory where no file f.wav exists. It can't find the file to read. Either copy f.wav to that directory or run you script from the directory f.wav is located in.

Upvotes: 1

BlogueroConnor
BlogueroConnor

Reputation: 1943

The file is not in the path you put that Python interpreter can find. Check that f.wav is in the same path of your script (or chance the path in open). Is not a wave issue at all.

Upvotes: 2

Related Questions