基本上我使用OpenAI耳语。我使用的代码,他们给在github的回购为例。当我在命令行或正常情况下运行它时,它说模块ffmpeg没有一个名为error的属性,该属性是whisper出于某种原因调用的。
代码(只是github上提供的示例代码):
import whisper
model = whisper.load_model("base")
# load audio and pad/trim it to fit 30 seconds
audio = whisper.load_audio("audio.mp3")
audio = whisper.pad_or_trim(audio)
# make log-Mel spectrogram and move to the same device as the model
mel = whisper.log_mel_spectrogram(audio).to(model.device)
# detect the spoken language
_, probs = model.detect_language(mel)
print(f"Detected language: {max(probs, key=probs.get)}")
# decode the audio
options = whisper.DecodingOptions()
result = whisper.decode(model, mel, options)
# print the recognized text
print(result.text)
我在VScode上运行,我也在终端上尝试了whisper audio.mp3
,它们都给出了相同的错误:
编辑:为什么会出现错误?我有正确的代码,并有模块安装到AttributeError: module 'ffmpeg' has no attribute 'Error
确保使用pip install git+https://github.com/openai/whisper.git命令安装whisper
你可以看答案https://github.com/openai/whisper/discussions/251