def _google_stt(self):
"""
Uses Google's Speech to Text engine to
understand speech and convert it into
text.
:return: String, either the spoken text or error text.
"""
click.echo("Please speak now")
# Listen to the microphone set up in the __init__ file.
with self.microphone as mic_source:
audio = self.recognizer.listen(mic_source)
click.echo("Processing audio")
try:
# Try to recognize the text
return self.recognizer.recognize_google(audio, show_all=self.debugging)
except sr.UnknownValueError: # speech is unintelligible
return "Google could not understand the audio."
except sr.RequestError:
return "Could not request results from Google's speech recognition service."
评论列表
文章目录