0

I have an MP3 file that I want to convert into a WAV file, but no matter how I try writing the code, it keeps raising FileNotFoundError on the MP3 file and warns me about the installation of FFmpeg.

my code:

from pydub import AudioSegment

# Specify the path to the FFmpeg executable
ffmpeg_path = r"C:\Users\תמרה\AppData\Local\ffmpegio\ffmpeg-downloader\ffmpeg\bin\ffmpeg.exe"
AudioSegment.ffmpeg = ffmpeg_path
AudioSegment.ffprobe = ffmpeg_path

# Load the MP3 file
mp3_file = r"C:\Users\תמרה\Tea Time - Ofshane.mp3"
audio = AudioSegment.from_file(mp3_file, format="mp3")

# Export as WAV
wav_file = r"C:\Users\תמרה\Tea Time - Ofshane.wav"
audio.export(wav_file, format="wav")

when running:

C:\Users\תמרה\PycharmProjects\spotify\venv\Scripts\python.exe "C:\Users\תמרה\PycharmProjects\spotify\file stuff.py" C:\ffmpeg-2023-05-29-git-45fa85a777-full_build\bin\ffmpeg.exe 
C:\Users\תמרה\PycharmProjects\spotify\venv\lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Users\תמרה\PycharmProjects\spotify\venv\lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
  warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
  File "C:\Users\תמרה\PycharmProjects\spotify\file stuff.py", line 12, in <module>
    audio = AudioSegment.from_file(mp3_file, format="mp3")
  File "C:\Users\תמרה\PycharmProjects\spotify\venv\lib\site-packages\pydub\audio_segment.py", line 728, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "C:\Users\תמרה\PycharmProjects\spotify\venv\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\תמרה\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 971, in __init__
True
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\תמרה\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1440, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Process finished with exit code 1

What should I do to make this work?

  • Are you 1000% sure the file exist? See if you can open the file with python. – TheTridentGuy supports Ukraine Jun 03 '23 at 15:45
  • Per the README here: https://github.com/jiaaro/pydub, There is a `.from_mp3()` method. does it work? – TheTridentGuy supports Ukraine Jun 03 '23 at 15:51
  • Check the [following post](https://stackoverflow.com/a/51932538/4926757). First issue is `AudioSegment.ffprobe = ffmpeg_path` (change it to `ffprobe_path`...). Second issue is that we should also set `AudioSegment.converter = ffmpeg_path`. You may also try to copy ffmpeg.exe and ffprobe.exe to the same folder as the Python script. – Rotem Jun 03 '23 at 20:24

0 Answers0