googlespeech.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:hal 作者: brandenk514 项目源码 文件源码
def listen(self):
        """
        :param self
        This is a wrapper method to the Speech_Recognition package
        found @ https://gist.github.com/GGulati/1ebaeaaa7f7408647fef#file-jarvis-py
        """
        try:
            with speech_recognition.Microphone() as source:
                self.recognizer.adjust_for_ambient_noise(source)
                audio = self.recognizer.listen(source, timeout=10, phrase_time_limit=None)
            return self.recognizer.recognize_google(audio)
        except speech_recognition.WaitTimeoutError:
            self.error_message = "I could not hear you!"
        except speech_recognition.UnknownValueError:
            self.error_message = "I did not quite get that"
        except speech_recognition.RequestError as e:
            self.error_message = "Recognition Error: {0}".format(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号