views:

20

answers:

1

I am just starting my cocoa education and I had a quick question, I see that the ability to click a word and have the mac text-to-speech functions say that text is built in automatically. (ie - for the hello world app, you can click hello world and in the menu have it say "hello world" back to you)

My question is this, is there a way for me to program the app to just loop that text automatically when someone opens the app? So, when they click the app on the dock, it opens up the window with the "Hello World" label on it and just loops saying "Hello World, Hello World,Hello World,Hello World,Hello World,..."

+1  A: 

Take another look at the documentation. Specifically the Speaking Text part. You create your synthesizer somewhere then feed it an NSString. It doesn't have to be (and shouldn't be) tied to the label.

You'll just want to wait until it's finished (via -speechSynthesizer:didFinishSpeaking: method) each time before sending it the string again. To make it stop, you could check the state (controlled by a checkbox, for example) at that point as well before continuing.

I have an example of a full implementation of NSSpeechSynthesizer's available methods here.

Joshua Nozzi