I am trying to convert my mp3 file to wav format but its giving error like this
My Code
from pydub import AudioSegment
src = "my_result.mp3"
dst = "final.wav"
sound = AudioSegment.from_mp3(src)
sound.export("final.wav",format="wav")
But this code is returning this kind of error
C:\Users\91630\AppData\Local\Programs\Python\Python311\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\91630\AppData\Local\Programs\Python\Python311\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\91630\Searches\SciTech Dropbox\meruvu likith\PC\Desktop\python temp\mp3_wav.py", line 6, in <module>
sound = AudioSegment.from_mp3(src)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\91630\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydub\audio_segment.py", line 796, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\91630\AppData\Local\Programs\Python\Python311\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\91630\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\91630\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\91630\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1491, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
If your ffmpeg is installed you need to add the path of ffmpeg to your environment variables' PATH. I'll explain for windows. First, find out where your ffmpeg is installed. Record that path, because you'll need it. Use the windows search for environment variables to bring up that system menu (like this https://docs.oracle.com/en/database/oracle/machine-learning/oml4r/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0). Once there, click on the variable called PATH. Then, add and paste in the path of your ffmpeg. This should allow pydub to access ffmpeg.
This is similar to this question: Pydub installation and ffmpeg which may be of further guidance in other systems.