pocketsphinxDidReceiveHypothesis not called on device – no problem in simulator

Home Forums OpenEars pocketsphinxDidReceiveHypothesis not called on device – no problem in simulator

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

  • Author
  • #1030382


    I have implemented the OpenEars offline speech recognition in my app. Everything is working fine in the simulator.
    However, when testing on the device “pocketsphinxDidReceiveHypothesis” is never called.
    “pocketsphinxDidStartListening” and “pocketsphinxDidDetectSpeech” does get called.

    I have followed the tutorial to the letter. The sample project is working as intended on simulator and device, so I have no idea what’s wrong.

    OEPocketsphinxController is not throwing an error either.

    @interface BaseViewController () <OEEventsObserverDelegate>

    - (void)viewDidLoad {
        [super viewDidLoad];
        [self pocketSphinxSetup];
    - (void)pocketSphinxSetup {
        self.openEarsEventsObserver = [[OEEventsObserver alloc] init];
        [self.openEarsEventsObserver setDelegate:self];
        OELanguageModelGenerator *lmGenerator = [[OELanguageModelGenerator alloc] init];
        NSArray *words = @[ @"CHEER", @"THANKS", @"THANK YOU", @"CONTINUE", @"END" ];
        NSString *name = @"voice";
        NSError *err = [lmGenerator generateLanguageModelFromArray:words withFilesNamed:name forAcousticModelAtPath:[OEAcousticModel pathToModel:@"AcousticModelEnglish"]];
        NSString *lmPath = nil;
        NSString *dicPath = nil;
        if(err == nil) {
            lmPath = [lmGenerator pathToSuccessfullyGeneratedLanguageModelWithRequestedName:name];
            dicPath = [lmGenerator pathToSuccessfullyGeneratedDictionaryWithRequestedName:name];
        } else {
            NSLog(@"Error: %@",[err localizedDescription]);
        [[OEPocketsphinxController sharedInstance] setActive:TRUE error:nil];
        [[OEPocketsphinxController sharedInstance] setVadThreshold:3];
        [[OEPocketsphinxController sharedInstance] startListeningWithLanguageModelAtPath:lmPath dictionaryAtPath:dicPath acousticModelAtPath:[OEAcousticModel pathToModel:@"AcousticModelEnglish"] languageModelIsJSGF:NO];
    Halle Winkler


    Please check out the post Please read before you post – how to troubleshoot and provide logging info here so you can see how to turn on and share the logging that provides troubleshooting information for this kind of issue.



    I didn’t see anything in the logging but that’s because I was using [OEPocketsphinxController sharedInstance].verbosePocketSphinx = TRUE; instead of [OELogging startOpenEarsLogging], oops.

    This is the log from OELogging:
    I guess it has something to do with AVAudioSession, no?

    Version is 2.501 on iPhone 6, 6+ and iPad Mini, all running 9.3.

    Halle Winkler


    Thanks, it would be helpful to post the logs directly here so I can correlate them to other similar issues and easily link to them in my tickets. That logging output means that some other app or other part of your app is changing the audio category to a playback-only category while the OpenEars code the logging shows execution of was in progress. You can diagnose the origin of the other calls to change the audio session category by searching for non-OpenEars invocations to the audio session. They don’t originate with OpenEars.


    That was the problem indeed, I had to set [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:&setCategoryErr];

    Thanks again!

    Halle Winkler

    Sure thing! OpenEars sets its own audio session settings so most of the time if you find yourself setting audio session settings in your app or letting another part of your app set them, it is likely to cause an issue.

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