开发者

Intro to Cocoa Speech question

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 a开发者_如何学Cutomatically. (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,..."


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜