Created
December 8, 2011 17:13
-
-
Save mrmekon/1447666 to your computer and use it in GitHub Desktop.
PyTTSX problem with GTK and threading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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