pythonpython-3.xapipyttsxpyttsx3

Voice assistant not getting terminated


Hello I am currently making a voice assistant and I want to terminate it but it isnt getting termintating and just getting repeated

elif 'you can sleep now' in query or 'take rest' in query:                
            speak('ohk master I am going to sleep you can call me again anytime going to sleep in 3 ,2 , 1')
            break

  if __name__ == "__main__":  
        while True:
            permission = takeCommand()
            if 'wake up' in permission:
                task_execute()
            elif 'close' in permission or 'buy' in permission:
                speak('ok sir have a good day')
                exit()

Solution

  • Add break after speak() to break from the loop.