I am using pydub to convert a mp3 file to wav. I switch from Atom to PyCharm and now is throws following error.
C:\Users\BlakkM9\AppData\Local\Programs\Python\Python37\lib\site-packages\pydub\utils.py:193: 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 "speechrec.py", line 102, in <module>
main()
File "speechrec.py", line 36, in main
recognize()
File "speechrec.py", line 51, in recognize
current = AudioSegment.from_mp3("./rec/ready.mp3")
File "C:\Users\BlakkM9\AppData\Local\Programs\Python\Python37\lib\site-packages\pydub\audio_segment.py", line 716, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "C:\Users\BlakkM9\AppData\Local\Programs\Python\Python37\lib\site-packages\pydub\audio_segment.py", line 665, in from_file
info = mediainfo_json(orig_file)
File "C:\Users\BlakkM9\AppData\Local\Programs\Python\Python37\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Users\BlakkM9\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\BlakkM9\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden
Before switching I just typed python start.py in the PowerShell when being in the root directory of the project. This still works without errors.
The corresponding code:
from pydub import AudioSegment
AudioSegment.converter = os.path.dirname(os.path.abspath(__file__)) + "\\ffmpeg\\bin\\ffmpeg"
current = AudioSegment.from_mp3("./rec/ready.mp3")
current.export("./rec/current.wav", format="wav")
Thanks
Blakk
EDIT:
Using an absolute path to the mp3 file is not working aswell (even if it works when I test it with open(...)
two lines above.
printing AudioSegment.converter also is the same in PyCharm and PowerShell.