I had great success using NSSpeechSynthesizer today, but my attempts
to use NSSpeechRecognizer haven't gone nearly so well. Here's what
I'm trying to do:
-----
from Foundation import *
import AppKit
class SRDelegate(NSObject):
def speechRecognizer_didRecognizeCommand_(self,sender,cmd):
print "speechRecognizer_didRecognizeCommand_", cmd
recog = AppKit.NSSpeechRecognizer.alloc().init()
recog.setCommands_([u"red", u"green", u"blue"])
d = SRDelegate.alloc().init()
recog.setDelegate_(d)
print "Listening..."
recog.startListening()
# Now we need a NSRunLoop...
runLoop = NSRunLoop.alloc() # note: no init() method?
runLoop.run()
-----
However, runLoop.run() returns immediately (or nearly so), instead of
waiting. Reading the docs, this is expected behavior if the run loop
doesn't have any "input sources," but I'm stumped in trying to give it
one. Unfortunately, I'm even more of a newbie to Cocoa than I am to
Python... can anyone share a clue?
Thanks,
- Joe
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig