Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
995 views
in Technique[技术] by (71.8m points)

speech recognition - if "confidence" in actual_result["alternative"] error while using speech_recognition in python

I am using speech_recognition my .wav is 34 minutes. I ran for 100 secondes and the result is good. My code is the following

import speech_recognition as sr
r = sr.Recognizer()
audio = sr.AudioFile("xxxx.wav")
with audio as source:
    audio = r.record(source, duration=100)
r.recognize_google(audio, language="fr-FR")

When I run the same code from the begining with duration = 300, I have the following:

---------------------------------------------------------------------------
UnknownValueError                         Traceback (most recent call last)
<ipython-input-4-54e2464499c7> in <module>
----> 1 r.recognize_google(audio, language="fr-FR")

~anaconda3envsenv38libsite-packagesspeech_recognition\__init__.py in recognize_google(self, audio_data, key, language, show_all)
    778         # return results
    779         if show_all: return actual_result
--> 780         if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError()
    781 
    782         if "confidence" in actual_result["alternative"]:

UnknownValueError: 
 
question from:https://stackoverflow.com/questions/65646211/if-confidence-in-actual-resultalternative-error-while-using-speech-recogni

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...