我正尝试使用google speech_recognition,但仅当我使用葡萄牙语的音频文件时有效,如果我使用英语的某些音频会给我该错误:
Traceback (most recent call last):
File "C:\Users\deabr_000\Downloads\stt.py", line 16, in <module>
print(r.recognize_google(audio, language="en-US"))
File "C:\Users\deabr_000\AppData\Local\Programs\Python\Python37\lib\site-packages\speech_recognition\__init__.py", line 858, in recognize_google
if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError()
speech_recognition.UnknownValueError
完整代码在这里:
import speech_recognition as sr
r = sr.Recognizer()
with sr.WavFile('C:/Users/deabr_000/Downloads/something_inside.wav') as source:
audio = r.record(source)
print(r.recognize_google(audio, language="en-US"))
我使用歌曲是因为我需要得到歌词才能做点事,我在pt-br歌曲上取得了成功,但是在任何其他语言的歌曲下都无法正常工作
我不知道问题是由我从youtube下载并转换为wav的歌曲(如果这首歌曲是pt-br作品)导致的,但是对于音频文件却有效(https://github.com/realpython/python-speech-recognition/tree/master/audio_files)>
我该怎么办?