【问题标题】:AttributeError: 'NoneType' object has no attribute 'count' [duplicate]AttributeError:“NoneType”对象没有属性“count”[重复]
【发布时间】:2022-01-02 12:55:52
【问题描述】:

嘿,我需要帮助,这是我在这里的第一篇文章,所以我不知道该怎么做,但我想知道如何解决我的问题,我是编码新手

def get_audio():
    with sr.Microphone() as source:
        audio = listener.listen(source)
        said =''

        try:
            said = r.recognize_google(audio)
            print(said)
        except Exception as e:
            print('Exception' + str(e))
Wake = 'hey friday'
while True:
text = get_audio()
    if text.count(Wake) < 0:
        talk('I am ready sir')

【问题讨论】:

标签: python python-3.x pycharm


【解决方案1】:

你的get_audio 函数必须返回一些东西。

text 没有从 get_audio 获得任何信息,因此它会发出 AttributeError。

【讨论】:

    猜你喜欢
    • 2021-04-13
    • 1970-01-01
    • 2021-05-26
    • 2019-03-10
    • 2022-08-12
    • 2019-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多