public
Created

PyTTSX problem with GTK and threading

  • Download Gist
ttsxtest.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
import threading
import pyttsx
import objc
from Foundation import *
from PyObjCTools import AppHelper
import gobject
 
shouldUseThreads = True
 
if shouldUseThreads:
import gtk
gobject.threads_init()
 
class Test:
def __init__(self):
self.thread = threading.Thread(target=self.run)
def start(self):
self.thread.start()
def run(self):
pool = NSAutoreleasePool.alloc().init()
engine = pyttsx.Engine()
while True:
text = "Say something, say something, anything."
engine.say(text)
engine.runAndWait()
del pool
t = Test()
 
if shouldUseThreads:
t.start()
gtk.main()
else:
t.run() # this works

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.