Skip to content

Instantly share code, notes, and snippets.

@mrmekon
Created December 8, 2011 17:13
Show Gist options
  • Save mrmekon/1447666 to your computer and use it in GitHub Desktop.
Save mrmekon/1447666 to your computer and use it in GitHub Desktop.
PyTTSX problem with GTK and threading
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment