1

I am making an Artificial Intelligence (AI) assistant and I wrote this to make it speak:

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[0].id)


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

it does not speak and shows:

Process finished with exit code 0

how to fix it??

Aryan GS
  • 39
  • 5

1 Answers1

1

You forgot to use the function. Use this code:

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[0].id)


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


# what you are missing
# use your function to say something
speak('Hello')

Hopefully, it works!

JoraSN
  • 332
  • 2
  • 14