Search code examples
iphonexcodeopenears

OpenEars - fliteDidFinishSpeaking not called the first time Flite is fired


A list, since it's easier to write:

• Music starts playing
• Skip to next track
• Flite speaks song title
fliteDidFinishSpeaking doesn't fire -- Why?
• Hit Play to start the music -- [musicPlayer play]; is at the end of the failing method
• Skip to next track (or just wait for the song to finish)
• Flite speaks the title of the last song -- not taking the new argument for say:
• Music restarts -- From this point on, Flite doesn't have trouble
• Skip to next track
• Flite speaks normally
• Music restarts

This only happens when the app is first launched, so there's something wrong with the initializing, either in my code or in OpenEars/Flite itself.


Solution

  • Brute force seems to be working pretty well:

    - (void)fliteWillStartSpeaking {
        [self resetFliteController];
        [fliteController say:@"some words" withVoice:curVoice];
    
        fliteDidFinish = NO;
        fliteFinishTimer = [NSTimer scheduledTimerWithTimeInterval:kFliteTimerCycle
                             target:self selector:@selector(forceFliteDidFinish)
                             userInfo:nil repeats:NO];
    }
    
    - (void)forceFliteDidFinish {
        if (!fliteDidFinish) {
            [self fliteDidFinishSpeaking];
        }
    
        [fliteFinishTimer invalidate];
    }
    

    A proper fix would be ideal, if anyone has found one.