Pausing app while FliteController is speaking

Home Forums OpenEars Pausing app while FliteController is speaking

Viewing 5 posts - 1 through 5 (of 5 total)

  • Author
    Posts
  • #10523
    woodyard
    Participant

    Can anyone recommend the best way to pause the main application while FliteController is speaking?

    #10525
    Halle Winkler
    Politepix

    What do you mean by pausing the main application?

    #10532
    woodyard
    Participant

    Sorry for the poor explanation – I had one foot out the dooor at the time.

    I’m writing an application to help young children with their literacy skills. The application shows them a word, and then they have six seconds to say the word correctly. If they say it correctly, the app says “Correct”. If they say it incorrectly, the app says the word correctly.

    So – the app uses all the OpenEars components!

    Anyway – the problem I’m trying to overcome is that currently, when the timer runs out and “correct” or the word is said the next word is shown and the timer for the enxt word is starting while the FliteController is in the process of saying “correct” or saying the word that was missed. I need the app to wait for FliteController to finish speaking, and THEN move on to the next word/timer.

    I’ve tried inserting a BOOL flag into fliteDidStartSpeaking and flitedDidFInishSpeaking and then writing a convenience method that calls fliteController then “waits” using a WHILE loop based on that Boolean value, but have not been successful using that approach.

    Is there a better way to accomplish this, and if not – perhaps I’ve just missed something. Here is my convenience method and my overrides for both flite methods:

    – (void) claraSay: (NSString *)message;
    {
    [self.fliteController say:message withVoice:kVoice];
    while ( self.fliteIsSpeaking ) {
    NSLog(@”Clara is waiting….”);
    }
    }

    – (void) fliteDidStartSpeaking
    {
    NSLog(@”Flite has started speaking”); // Log it.

    self.fliteIsSpeaking=TRUE;

    }

    – (void) fliteDidFinishSpeaking
    {

    NSLog(@”Flite has finished speaking”); // Log it.

    self.fliteIsSpeaking=FALSE;

    }

    #10534
    Halle Winkler
    Politepix

    Sounds like a nice app, always happy to hear about that kind of use of OpenEars. This is more of a general application design question but I don’t mind taking a stab at it.

    I think that the most efficient way to deal with this kind of issue is to launch the follow-up method (in this case whatever the “ask next question” method is) _from_ fliteDidFinishSpeaking (as part of an OpenEarsEventsObserver instance that is instantiated in the class whether the follow-up method lives). Generally, a good pattern for that kind of approach is to have a “queue” of questions which are added to an NSMutableArray at whatever point you know what they are supposed to be, and every time fliteDidFinishSpeaking is called you check the queue to see if there are any questions left in it to ask. If there is a next question in the queue, you launch your question method using that question from fliteDidFinishSpeaking and also remove it from the queue. Eventually you will run out of questions and fliteDidFinishSpeaking will not result in another question being asked. If logic dictates that there are new questions that should be asked, you add them to the queue. Does that make sense?

    #10787
    woodyard
    Participant

    Thank you – that did the trick!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.