nateshmbhat / pyttsx3

Offline Text To Speech synthesis for python
Mozilla Public License 2.0
1.99k stars 321 forks source link

fixed 'started-word' event and fixed `stop` function #295

Open Barakri opened 7 months ago

willwade commented 2 months ago

NB: This gives different output from https://github.com/nateshmbhat/pyttsx3/pull/186

e.g for https://github.com/nateshmbhat/pyttsx3/pull/186

starting None word None 1 0 word None 0 3 word None 4 5 word None 10 5 word None 16 3 word None 20 6 word None 27 4 word None 32 3 word None 36 4 word None 41 3 finishing None True

and this PR

starting None word None 2560 3 word None 5120 5 word None 12320 5 word None 20320 3 word None 29120 6 word None 35536 4 word None 41876 3 word None 44570 4 word None 54336 3 finishing None True

import pyttsx3
import logging

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()