Reply To: trying to use two "say" statements

Home Forums OpenEars trying to use two "say" statements Reply To: trying to use two "say" statements

Halle Winkler

Sure, there is sample code in the OpenEars sample app which shows how the OpenEarsEventsObserver callbacks work. The general question about how callbacks work and how Objective-C uses delegate methods as callbacks is a little beyond the scope of the support I can give in these forums, regretfully, but there is a lot of info online if you search for those keywords (e.g. “objective-c” and “delegates” and “delegate methods” and “callbacks”). Very briefly, it is a way that you can have a method in your view controller that, rather than _you_ calling it yourself to cause something to happen, some other object in your app can call the method when something happens to _it_. And when that method gets called, you know that the event you are waiting for happened, and you can take the opportunity to react to that. For instance, if you are waiting to hear that FliteController finished playing a piece of speech so you can start a new piece of speech.

In the OpenEars sample app, there is an example of how this works using the delegate method of OpenEarsEventsObserver called fliteDidFinishSpeaking. The chunk of code you can search for in the sample app looks like this:

– (void) fliteDidFinishSpeaking {
NSLog(@”Flite has finished speaking”); // Log it.
self.statusTextView.text = @”Status: Flite has finished speaking.”; // Show it in the status box.

So when FliteController finishes saying a phrase, it (rather than you) can call this callback via OpenEarsEventsObserver and you receive notification in that method that the speaking is complete and it’s an OK time to start a new phrase. When you run the sample app, this will be demonstrated when the logging statement “Flite has finished speaking” appears in the console.