[Pyobjc-dev] PyObjC speech
Brought to you by:
ronaldoussoren
From: Frederik De B. <fre...@pa...> - 2004-05-18 16:36:57
|
Let's talk speech! I'm having trouble using the NSSpeechSynthesizer delegates. I believe it's a problem with delegates in general. They seem to crash the application. I'm posting the code here. The problem is when then speak command is invoked. Can anybody please explain the correct way to use delegate methods in PyObjC? Is it important to implement all elements of the delegate? And is there anything on the net on the correct format for the signature? Regards, Frederik De Bleser --------------- import objc from AppKit import * class BabbleBox: def __init__(self): self.synth= NSSpeechSynthesizer.alloc().init() self.synth.setVoice_("com.apple.speech.synthesis.voice.Agnes") self.synth.setDelegate_(self) def speak(self, txt): self.synth.startSpeakingString_(txt) def speechSynthesizer_willSpeakWord_ofString_(self, synth, word, string): print "spoke", word speechSynthesizer_willSpeakWord_ofString_ = objc.selector(speechSynthesizer_willSpeakWord_ofString_, signature="v@:@zz") b = BabbleBox() b.speak("hello there") |