def wit_callback(self, recognizer, audio):
try:
captured_audio = recognizer.recognize_wit(audio,
key=self.key,
show_all=self.show_all)
Utils.print_success("Wit.ai Speech Recognition thinks you said %s" % captured_audio)
self._analyse_audio(captured_audio)
except sr.UnknownValueError:
Utils.print_warning("Wit.ai 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 Wit.ai Speech Recognition service; {0}".format(e))
# callback anyway, we need to listen again for a new order
self._analyse_audio(audio_to_text=None)
# stop listening for an audio
self.stop_listening()
评论列表
文章目录