nateshmbhat / pyttsx3

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

Missing guard condition in sapi5 driver #221

Open Vincent-Stragier opened 2 years ago

Vincent-Stragier commented 2 years ago

I do not see how the method runAndWait() can return, there seems to be no guard condition in the startLoop method. https://github.com/nateshmbhat/pyttsx3/blob/5d3755b060a980f48fcaf81df018dd06cbd17a8f/pyttsx3/drivers/sapi5.py#L124-L132

Looking at pyttsx3/drivers/espeak.py driver, I altered the method startLoop in pyttsx3/drivers/sapi5.py:

    def startLoop(self):
        first = True
        self._looping = True
        while self._looping:
            if first:
                self._proxy.setBusy(False)
                first = False
            if not pythoncom.PumpWaitingMessages() and self._looping:
                self._stopping = False
                self._proxy.notify('finished-utterance', completed=False)
                self._proxy.setBusy(False)
            time.sleep(0.05)
lehuymanhtan commented 2 years ago

Thank. This helped me!