def recognize(self):
if self.engine == 'google':
try:
from pprint import pprint
print("Google Speech Recognition")
return self.r.recognize_google(self.audio, show_all=False)
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
if self.engine == 'witai':
WIT_AI_KEY = "7LUFYD6ZZKLYSI652C75J4UZWTIMJIPX"
try:
print("Wit.ai")
return self.r.recognize_wit(self.audio, key=WIT_AI_KEY)
except sr.UnknownValueError:
print("Wit.ai could not understand audio")
except sr.RequestError as e:
print("Could not request results from Wit.ai service; {0}".format(e))
if self.engine == 'sphinx':
try:
print("Sphinx")
return self.r.recognize_sphinx(self.audio)
except sr.UnknownValueError:
print("Sphinx could not understand audio")
except sr.RequestError as e:
print("Sphinx error; {0}".format(e))
return None
评论列表
文章目录