Re: NSSpeechSynthesizer from AppKit?

Ronald Oussoren <[email protected]>
Newsgroups gmane.comp.python.apple
Message-ID <[email protected]>
On 1 May, 2013, at 14:37, Yuma Antoine Decaux <[email protected]> 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

_______________________________________________
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.