首页 > 解决方案 > Python - 为什么我会收到这个 ffprobe 错误?

问题描述

我在mac上,正在开发一个项目,我的程序应该将 .mp3 文件转换为 .wav 文件,然后从该文件中获取文本(基本语音识别)。为了将 .mp3 文件转换为 .wav 文件,我使用的是 ffmpeg 库。我已经使用 pip 而不是使用自制软件安装了 ffmpeg 和 ffprobe 库,所以我将它们安装在一个文件夹中。

这是我的代码:

import speech_recognition
from pydub import AudioSegment
from os import path


#get text from original voice file------------------------------------------------- 

sound = AudioSegment.from_mp3("/path/to/file.mp3")
sound.export("/output/path/file.wav", format="wav")

file_audio = speech_recognition.AudioFile('/output/path/file.wav')

r = speech_recognition.Recognizer()
with file_audio as source:
    audio_text = r.record(source)

word = r.recognize_google(audio_text)

这是我得到的错误: FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'

完全错误: 警告(来自警告模块):文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pydub/utils.py”,第 170 行警告(“不能找到 ffmpeg 或 avconv - 默认为 ffmpeg,但可能无法工作”,RuntimeWarning) RuntimeWarning: 找不到 ffmpeg 或 avconv - 默认为 ffmpeg,但可能无法工作

警告(来自警告模块):文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pydub/utils.py”,第 198 行警告(“找不到 ffprobe 或avprobe - 默认为 ffprobe,但可能不起作用”,RuntimeWarning)

RuntimeWarning:找不到 ffprobe 或 avprobe - 默认为 ffprobe,但可能无法使用 Traceback(最近一次调用最后一次):文件“/Users/marcus/Downloads/pronaunciation_checker/pronaunciation_check.py”,第 12 行,声音 = AudioSegment。 from_mp3(“/Users/marcus/Desktop/think.mp3”)文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pydub/audio_segment.py”,第 796 行,在 from_mp3 返回 cls.from_file(file, 'mp3', parameters=parameters) 文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pydub/audio_segment.py”,行728,在 from_file info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit) 文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pydub/utils.py”,第 274 行,在 mediainfo_json res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE) 文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,第 951 行,在初始化 self._execute_child(args,可执行文件,preexec_fn,close_fds,文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,第 1821 行,在 _execute_child 中引发 child_exception_type(errno_num,err_msg , err_filename) FileNotFoundError: [Errno 2] 没有这样的文件或目录: 'ffprobe'

标签: pythonffmpegvoice-recognitionffprobe

解决方案


推荐阅读