def google_callback(self, recognizer, audio):
"""
called from the background thread
"""
try:
captured_audio = recognizer.recognize_google(audio,
key=self.key,
language=self.language,
show_all=self.show_all)
Utils.print_success("Google Speech Recognition thinks you said %s" % captured_audio)
self._analyse_audio(audio_to_text=captured_audio)
except sr.UnknownValueError:
Utils.print_warning("Google Speech Recognition could not understand audio")
# callback anyway, we need to listen again for a new order
self._analyse_audio(audio_to_text=None)
except sr.RequestError as e:
Utils.print_danger("Could not request results from Google Speech Recognition service; {0}".format(e))
# callback anyway, we need to listen again for a new order
self._analyse_audio(audio_to_text=None)
self.stop_listening()
评论列表
文章目录