def __init__(self, proxy): if not EspeakDriver._moduleInitialized: # espeak cannot initialize more than once per process and has # issues when terminating from python (assert error on close) # so just keep it alive and init once rate = _espeak.Initialize(_espeak.AUDIO_OUTPUT_PLAYBACK, 1000) if rate == -1: raise RuntimeError('could not initialize espeak') EspeakDriver._defaultVoice = self.getProperty('voice') EspeakDriver._moduleInitialized = True _espeak.SetSynthCallback(self._onSynth) # make sure all props reset self.setProperty('voice', EspeakDriver._defaultVoice) self.setProperty('rate', 200) self.setProperty('volume', 1.0) self._proxy = proxy self._looping = True self._stopping = False
def destroy(self): _espeak.SetSynthCallback(None)