[Python] Pyttsx3 does not talk after first speak

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    Im making a speech recognizer for a hobby and after the first run of the if "time" in cmd: if statment i doesn't do it again

    import pyttsx3 as ptts
    import datetime

    engine = ptts.init('sapi5')

    def speak(audio):
    engine.say(audio)
    engine.runAndWait()

    def listen():
    r = sr.Recognizer()
    with sr.Microphone() as source:
    audio = r.listen(source)
    try:
    command = r.recognize_google(audio)
    return command.lower()
    except:
    return ""


    def main():
    while True:
    cmd = listen()
    time = datetime.datetime.now().strftime("%H:%M")
    if cmd == "":
    continue

    if "time" in cmd:
    print(f"Its {time} right now")
    speak(f"its {time} right now")
    continue
    main()


    could i get some help fixing this issue please

    some info about what Im using: Pyaudio for microphone, Windows, Vscode

    Continue reading...

Compartilhe esta Página