[Pythonmac-SIG] NSSpeechSynthesizer from AppKit?

Ronald Oussoren ronaldoussoren at mac.com
Wed May 1 15:43:17 CEST 2013


On 1 May, 2013, at 14:37, Yuma Antoine Decaux <jamyad7 at gmail.com> wrote:

> Hi,
> 
> I've been trying to find a way to have speech output on an assignment GUI i'm working on for uni in Tkinter (they are forcing me) and since none of the UI elements on it are accessible, i'm trying to use either pyobjc with AppKit and some event handlers in Tkinter to get speech synthesis.
> 
> I've just successfully installed pyobjc and looked at the API notes. I couldn't find NSSynthesizer. Is this not available?
> 
> Just asking before i go any further.

NSSpeechSyntheziser is supported. There is nothing useful to mention beyond what's in the Apple documentation for the class, hence it is not mentioned in the API notes.

The following should work:

   from Cocoa import NSSpeechSynthesizer
   
   sp = NSSpeachSynthesizer.alloc().initWithVoice_(None) # use default voice
   sp.startSpeakingString_("hello world")

You should probably ensure that the synthesizer object hangs around until it is done speaking.

Ronald



More information about the Pythonmac-SIG mailing list