I am trying to make a voice-assistant app using tkinter in Python and I'm having two issues with my code.
A snippet from my code:
def listen_to_me():
    msg2 = Message(root, text="Listening...", bg='yellow', font=('times', 14, 'italic'))
    msg2.pack
    msg2.place(x=200, y=220)
    with sr.Microphone() as source:
        audio = r.listen(source)
        global query
        query = r.recognize_google(audio, language='en-IN', show_all=True)
        if query:
            try:
                (f"[Me]: {query}")                                       
            except:
                engine.say("Sorry didn't quite catch that. Please repeat.")   
    return query
def reply():
    while True:
        global query
        # Logic for executing tasks based on query
        if 'wikipedia' in query:
            speak('Searching Wikipedia...')
            query = query.replace("wikipedia", "")
            query = query.replace("search", "")
            query = query.replace("for", "")
            results = wikipedia.summary(query, sentences=1)
            speak(f'According to Wikipedia, {results}')
        elif 'open youtube' in query:
            speak('Opening Youtube')
            webbrowser.open("https://youtube.com")
        elif 'open stack overflow' in query:
            speak('Opening StackOverflow')
            webbrowser.open("https://stackoverflow.com")
        elif 'what' in query and 'time' in query:
            strTime = datetime.datetime.now().strftime("%H:%M:%S")    
            speak(f"Sir, The time is {strTime}")
        elif 'how are you' or 'what\'s up' in query:
            speak('I am doing jolly good, sir.')
Problem-1: I'm getting the output but it seems to be stuck in a loop:
[MyAssistant]: Good evening! I am Jarvis. How may I help you today?
[MyAssistant]: I am doing jolly good, sir.
[MyAssistant]: I am doing jolly good, sir.
[MyAssistant]: I am doing jolly good, sir.
[MyAssistant]: I am doing jolly good, sir.
[MyAssistant]: I am doing jolly good, sir.
[MyAssistant]: I am doing jolly good, sir.
[MyAssistant]: I am doing jolly good, sir.
Problem-2: I want to convert my query to the lower-case. I've tried the following:
query = query.lower()
Error:
AttributeError: 'list' object has no attribute 'lower'
Thanks in advance!
 
     
     
    

