Reputation: 23
i have tried to run this code
filepath = "C:/Users/Linus/Desktop/Test/Audio/" #Input audio file path
from pydub import AudioSegment
import os
def mp3_to_wav(audio_file_name):
if audio_file_name.split('.')[1] == 'mp3':
sound = AudioSegment.from_mp3(audio_file_name)
audio_file_name = audio_file_name.split('.')[0] + '.wav'
sound.export(audio_file_name, format="wav")
if __name__ == "__main__":
for audio_file_name in os.listdir(filepath):
file_name = filepath + audio_file_name
file_name = os.path.realpath(file_name)
mp3_to_wav(file_name)
but i got this error below (last line)
runfile('C:/Users/Linus/Desktop/Test/test2.py', wdir='C:/Users/Linus/Desktop/Test')
C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\utils.py:165: 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\Linus\AppData\Roaming\Python\Python37\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 "<ipython-input-1-b871056654c0>", line 1, in <module>
runfile('C:/Users/Linus/Desktop/Test/test2.py', wdir='C:/Users/Linus/Desktop/Test')
File "C:\Programme\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Programme\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Linus/Desktop/Test/test2.py", line 22, in <module>
mp3_to_wav(file_name)
File "C:/Users/Linus/Desktop/Test/test2.py", line 14, in mp3_to_wav
sound = AudioSegment.from_mp3(audio_file_name)
File "C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\audio_segment.py", line 716, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\audio_segment.py", line 665, in from_file
info = mediainfo_json(orig_file)
File "C:\Users\Linus\AppData\Roaming\Python\Python37\site-packages\pydub\utils.py", line 263, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Programme\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
super(SubprocessPopen, self).__init__(*args, **kwargs)
File "C:\Programme\Anaconda3\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Programme\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden
The last line is in german and means 'The system can't find the specified file'.
I read alot in a lot of forums, but i could not find any solution. Im kinda new in programming in Python (and programming in generell) and I have no idea what I have to do. Would be great if anyone could help.
Upvotes: 1
Views: 277
Reputation: 885
Ich glaube, dass Sie FFMPEG nicht installiert haben. Mach mal pip install ffmpeg
und dann entweder schreiben Sie das in deinem PATH oder in Ihrem Programm: AudioSegment.ffmpeg = "C:\\path\\path\\ffmpeg.exe"
(das ist wo Sie FFMPEG installiert haben)
Ich lerne gerade Deutsch, also sorry wenn ich etwas flasch geschrieben habe :)
Upvotes: 1