1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Pyttsx3 only plays the first message, the second one gets ignored and I don't know why

Discussão em 'Python' iniciado por Stack, Novembro 30, 2025.

  1. Stack

    Stack Membro Participativo

    So, this is my first time using Pyttsx3 and for some reason it just doesn't work proprely? I mean, I guess it should read the second or third message but it straight up doesnt and I'm not sure why at this point

    #Imports
    import time as t
    import os
    import pyttsx3
    #tts
    engine = pyttsx3.init()

    engine.setProperty('rate', 150)
    engine.setProperty('volume', 1)

    rate=engine.getProperty('rate')
    volume=engine.getProperty('volume')
    voices=engine.getProperty('voices')

    if len(voices) > 1:
    engine.setProperty('voice', voices[1].id)
    else:
    engine.setProperty('voice', voices[0].id)

    #functions
    def clear():
    os.system('cls' if os.name == 'nt' else 'clear')

    def tts(text):
    engine.say(text)
    engine.runAndWait()

    t.sleep(0.5)


    # program
    clear()
    t.sleep(0.5)
    tts("Well hello!, Welcome to Walfenix's program!. This place is a little dusty tho... hmm... hold on")
    print("Initializing...")
    t.sleep(2)
    clear()
    tts("There we go, much better!")
    print("Done!")
    tts("This is a test message to see if the voice works.")

    Continue reading...

Compartilhe esta Página