On Oct 14, 2008, at 4:06 PM, Joe Strout wrote:

Poking around in Foundation, sure enough, NSSpeechSynthesizer isn't there. A lot of other stuff is, like NSError, though. Where should NSSpeechSynthesizer be imported from, and why don't I need any other imports in my PyObjC source file?

Sheesh, I really need to find an email client with a 5-minute outgoing mail delay... somehow, pressing the "Send" key always seems to kick my brain into gear.

In this case, I discovered the "Find Selected Text in Documentation" contextual menu command in XCode, which led me to the NSSpeechSynthesizer Class Reference, which points out that this is in the AppKit framework. So, modifying my earlier attempt a bit...

>>> import AppKit
>>> synth = AppKit.NSSpeechSynthesizer.alloc().initWithVoice_(None)
>>> synth.startSpeakingString_(u"Hello world!")
True

...and it works! Certainly not as easy as "speak", but easy enough. And in its own way, it's very cool that you can read the Apple docs for any (?) Cocoa class and just use it as-is from Python.

Man, it's good to be back!

Cheers,
- Joe


--
Joe Strout
[EMAIL PROTECTED]

Words of wisdom from Helen Philpot:
<http://margaretandhelen.wordpress.com/2008/10/07/maverick-my-ass/>

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to