The official documentation for pyttsx3 gives a variation of the following example for printing words that are currently being said. The only difference is that the print statements are in Python 3.x syntax instead of Python 2.x.
import pyttsx3
def onStart(name):
print('starting', name)
def onWord(name, location, length):
print('word', name, location, length)
def onEnd(name, completed):
print('finishing', name, completed)
engine = pyttsx3.init()
engine.connect('started-utterance', onStart)
engine.connect('started-word', onWord)
engine.connect('finished-utterance', onEnd)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
The following incorrect output is printed.
starting None
word None 1 0
finishing None True
How can I print the actual word being uttered?
EDIT: If this task is not possible in pyttsx3, I am also open to using any other text to speech library to accomplish this.