Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

I want to develop a voice assistant in python with wake command, but it's giving loop error. Kindly be informed that I am new to pyttx3 so unable to find where I can fix this. There is some loop error that I am unable to fix, please help to make it work.

import pyjokes

client = wolframalpha.Client(app_id)

engine = pyttsx3.init() 

voices = engine.getProperty('voices') 

engine.setProperty('voice', voices[1].id) 

def speak(text):

    engine.say(text)

    engine.runAndWait()

   

WAKE = "hello jack"

SERVICE = authenticate_google()

print("Start")

while True:

    text = get_audio()

    if text.count(WAKE) > 0:

        speak("I am ready")

        text = get_audio()

        CALENDAR_STRS = ["what do i have", "do i have", "am i busy"]

        for phrase in CALENDAR_STRS:

            if phrase in text:

                date = get_date(text)

                if date:

                    get_events(date, SERVICE)

                else:

                    speak("I don't understand")

        NOTE_STRS = ["make a note", "write this down", "remember this"]

        for phrase in NOTE_STRS:

            if phrase in text:

                speak("What would you like me to write down?")

                note_text = get_audio()

                note(note_text)

                speak("I've made a note of that.")

    

RuntimeError: run loop already started

1 Answer

0 votes
by (108k points)

I believe that you have to import the pyttsx3 package and other modules. Please be informed that the pyttsx3 is a text-to-speech translation library in Python. Unlike alternative packages, it works offline and is cooperative with both Python 2 and 3.

Kick-start your career in Python with the perfect below python tutorial video for better understanding:

Related questions

0 votes
1 answer
asked Jan 10, 2021 in Python by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer
asked Dec 17, 2020 in Python by laddulakshana (16.4k points)
0 votes
1 answer
asked Dec 12, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
asked Oct 8, 2019 in Python by Sammy (47.6k points)

Browse Categories

...