0

I use the pyttsx3 library and it slows down the runAndWait().

What is the solution?

PS: Pyttsx3 runAndWait() method gets stuck - I read it, it didn't help

def speak(what):
    speak_engine.say(what)
    speak_engine.runAndWait() # stop! 
    speak_engine.stop()
speak.start("Hello world!")
Mario
  • 1,631
  • 2
  • 21
  • 51
Alexander
  • 1
  • 1

1 Answers1

0

I think this should work:

import pyttsx3
def speak(voice):
  engine = pyttsx3.init()
  rate = engine.getProperty('rate')
  engine.setProperty('rate', rate + 1)
  engine.setProperty('voice', 'com.apple.speech.synthesis.voice.Alex')
  engine.say(voice)

  engine.runAndWait()

speak("Hello")
AstroGuy
  • 56
  • 6
  • Hi and thanks for the answer. It would be great if you could explain to us how and why your code solves the OP's problem as code itself is not always easy to read. – Simas Joneliunas Jan 27 '22 at 06:26
  • @Astro Your code doesn't solve the problem, All it does is increase the rate at which it speaks. – K.E.S Oct 10 '22 at 03:57