0

i'm trying to run a program that converts audio.mp3 to audio.wav

os.system("echo 'y' | ffmpeg -i " + DOWNLOAD_LOCATION + "audio.mp3 ./audio.wav 2>/dev/null")
    with sr.AudioFile('./audio.wav') as source:
        audio = r.record(source)

but i always get the same error

Traceback (most recent call last):
  File "run.py", line 151, in <module>
    res = runCap()
  File "run.py", line 119, in runCap
    with sr.AudioFile('./audio.wav') as source:
  File "/usr/local/lib/python2.7/dist-packages/speech_recognition/__init__.py", line 203, in __enter__
    self.audio_reader = wave.open(self.filename_or_fileobject, "rb")
  File "/usr/lib/python2.7/wave.py", line 511, in open
    return Wave_read(f)
  File "/usr/lib/python2.7/wave.py", line 160, in __init__
    f = __builtin__.open(f, 'rb')
IOError: [Errno 2] No such file or directory: './audio.wav'

your help would be much appreciated

  • 2
    this may help: https://stackoverflow.com/a/32583160/4954037 . – hiro protagonist Feb 16 '20 at 11:22
  • 1
    Please don't use Python 2 any more, use Python 3! Concerning your question, it would help if you provided a [mcve]. However, the error is kind-of obvious, so I wonder what your problem is there. As a new user, also make sure you take the [tour] and read [ask]. – Ulrich Eckhardt Feb 16 '20 at 11:23
  • All the errors (such as `ENOENT` propagated from you OS) can usually be taken for their face value. If it says the file is not there, it usually is not. The question is why? Is it missing? Typo? Race? Are you making the call form the location you assume you're calling from?... Otherwise `os.system()` is a bit crude and suggests this is more of a bash script then python job perhaps? And iirc `ffmped` has `-y` option to not have to pass `y` on `stdin`. – Ondrej K. Feb 17 '20 at 12:59

0 Answers0