我试图运行此代码
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)
但我在下面(最后一行)出现此错误
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__(\*rgs, \*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
最后一行是德语,表示“系统找不到指定的文件”。
我在很多论坛上都读了很多书,但找不到任何解决方案。我是Python编程(以及Generell编程)的新手,我不知道该怎么做。如果有人可以帮助,那就太好了。
问题来源:stackoverflow
Ich glaube,Dass Sie FFMPEG nicht installiert haben。Ihrem程序中deinem路径中的Mach malpip install ffmpeg
和dann enweder schreiben Sie das:`AudioSegment.ffmpeg =“ C:\ path \ path \ ffmpeg.exe” gerade Deutsch,也对不起wenn ich etwas flasch geschrieben habe :)
回答来源:stackoverflow
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。