Attributeerror: 'nonetype' Object Has No Attribute 'lower' Python3
This is a voice assitance and i want hear my voice and open google or searching! but My program has a AttributeError I want : 1.initialization 2.speak 3.hear and speech Recognizati
Solution 1:
You need to check if the query is not None
if query:
    if 'wikipedia' in query.lower():
        speak('searching in wikipedia....')
        query = query.replace("wikipedia", "")
        results = wikipedia.summary(query, sentences =2)
        print(results)
        speak(results)
    elif 'open youtube' in query.lower():
        url = 'youtube.com'
        chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application/chrome.exe %s'
        webbrowser.get(chrome_path).open(url)
The error that in the header is because you are trying to lower() None type object and from your code it seems that it's happened in the query value.
Post a Comment for "Attributeerror: 'nonetype' Object Has No Attribute 'lower' Python3"