经历好几个小时的折腾
from pydub.audio_segmentimport AudioSegment
from scipy.ioimport wavfile
from python_speech_features.baseimport mfcc
import pandas
import sys
song = AudioSegment.from_file('D:/demo/xihuani.MP3',format='MP3')
print(song)
错误
Traceback (most recent call last):
File "D:/demo/classs_demo.py", line 7, in
song = AudioSegment.from_file('D:/demo/xihuani.MP3',format='MP3')
File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\site-packages\pydub\audio_segment.py", line 665, in from_file
info = mediainfo_json(orig_file)
File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
Process finished with exit code 1
上面的错误是少安装了 ffmpeg 但是你用pip install ffmpeg 安装后还是一样的错误
然后呢 你需要自己去官网下载 。exe的然后再去代码调用ffmpeg
最后
from pydub.audio_segmentimport AudioSegment
from scipy.ioimport wavfile
from python_speech_features.baseimport mfcc
import pandas
import sys
AudioSegment.converter ='D:\\ffmpeg\\bin\\ffmpeg.exe'
song = AudioSegment.from_file('D:/demo/xihuani.MP3',format='MP3')
print(song)