Mohi Indharan Mohi Indharan - 5 days ago 4
Python Question

problems with wavfile.py showing a unexpected error

i wrote this function a while ago it was working for a while then this happened help me


track is mp3 file cmd converts mp3 into temp.wav file


def convertwmv(track):
oname = 'temp.wav'
cmd='lame --decode {0} {1}'.format( track,oname )
os.system(cmd)
data=wav.read(oname)
return data


Error:

sh: 1: Syntax error: "(" unexpected

File "/home/mako/.local/lib/python3.5/site-packages/scipy/io/wavfile.py", line 233, in read
fid = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'temp.wav'

Answer

Apparently the track name you are using might be having some brackets in it's file name. bash commands don't deal well with special characters and spaces. Try to escape them before formatting your cmd variable. It became apparent after your last edit.

Comments