1

Here is what the terminal looks like:

>>> from pydub import AudioSegment
>>> song = AudioSegment.from_wav("E:\\sounds\\ahh.wav")

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    song = AudioSegment.from_wav("E:\\sounds\\ahh.wav")
  File "C:\Python27\lib\pydub\audio_segment.py", line 534, in from_wav
    return cls.from_file(file, 'wav', parameters)
  File "C:\Python27\lib\pydub\audio_segment.py", line 505, in from_file
    p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Now, this file DEFINITELY DOES exist on my computer, and as far as I know I used the backslashes correctly. Why isn't Python able to find it?

1 Answers1

2

Take a closer look at that traceback - it isn't your WAV file that isn't being found, it's an executable program (referred to by conversion_command) that isn't found. According to the Pydub docs, no external command is needed for WAV files, so I suspect that the file you have isn't actually a valid WAV. You could try following the instructions in the Pydub docs for installing its optional dependencies (libav, ffmpeg), in case the file is a valid file of a different format.

jasonharper
  • 9,450
  • 2
  • 18
  • 42