The python module pyttsx is a text-to-speech module for python. The sample code
import pyttsx
engine=pyttsx.init()
engine.say("hello")
engine.say("everybody")
engine.runAndWait()
is supposed to get the the call to runAndWait and read the queue words ("hello" and "everybody") and then return. However on Yosemite the runAndWait function never returns (just hangs forever) even after the queue of words is read.
I'm pretty sure this is just a Yosemite problem. Any mac users out there have a workaround for this issue yet? Thanks very much.
Cheers, ht
To deal with this problem,
1- make a class for pyttsx3;
2- make an instance of the class, send the text to it, then del() it.
3- repeat step 2 several times.
the Class:
import pyttsx3
class _TTS:
engine = None
rate = None
def __init__(self):
self.engine = pyttsx3.init()
def start(self,text_):
self.engine.say(text_)
self.engine.runAndWait()
the instance:
tts = _TTS()
tts.start("text")
del(tts)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With