Problem switching between OpenEars and RapidEars

Home Forums OpenEars plugins Problem switching between OpenEars and RapidEars

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

  • Author
    Posts
  • #13477
    Matt
    Participant

    Hi Everyone,

    I am working on an app where the user presses a button to enable word recognition using OpenEars. Pressing this button trigger the ‘retrospectiveWordRecognition’ method. The user can then press another button to trigger word recognition using RapidEars. Pressing this button triggers the ‘realtimeWordRecognition’ method.

    The app crashes when the user switches between the two. The debugger indicates the problem is with the ‘- (PocketsphinxController *)retroPocketsphinxController’ and ‘- (PocketsphinxController *)realPocketsphinxController’ methods.

    Has anyone experienced this problem?

    I have declared two instances of PocketsphinxController. One for OpenEars and one for RapidEars. Is this necessary?

    Regards,

    Matt

    -(IBAction)retrospectiveWordRecognition:(id)sender
    {
    retrolmGenerator = [[LanguageModelGenerator alloc] init];

    NSArray *retroWords = [NSArray arrayWithObjects:
    @”ONE”,
    @”TWO”,
    @”THREE”,
    @”FOUR”,
    @”FIVE”,
    nil];

    retroName = @”NameIWantForMyLanguageModelFiles”;

    retroErr = [retrolmGenerator generateLanguageModelFromArray:retroWords withFilesNamed:retroName];

    NSDictionary *retroLanguageGeneratorResults = nil;

    retrolmPath = nil;
    retrodicPath = nil;

    if([retroErr code] == noErr)
    {
    retroLanguageGeneratorResults = [retroErr userInfo];

    retrolmPath = [retroLanguageGeneratorResults objectForKey:@”LMPath”];

    retrodicPath = [retroLanguageGeneratorResults objectForKey:@”DictionaryPath”];
    }

    else
    {
    NSLog(@”Error: %@”,[retroErr localizedDescription]);
    }

    [self.retroPocketsphinxController startListeningWithLanguageModelAtPath:retrolmPath dictionaryAtPath:retrodicPath languageModelIsJSGF:NO];
    }

    -(IBAction)realtimeWordRecognition:(id)sender
    {
    reallmGenerator = [[LanguageModelGenerator alloc] init];

    NSArray *realWords = [NSArray arrayWithObjects:
    @”ONE”,
    @”TWO”,
    @”THREE”,
    @”FOUR”,
    @”FIVE”,
    nil];

    realName = @”NameIWantForMyLanguageModelFiles”;

    realErr = [reallmGenerator generateLanguageModelFromArray:realWords withFilesNamed:realName];

    NSDictionary *realWordsLanguageGeneratorResults = nil;

    reallmPath = nil;
    realdicPath = nil;

    if([realErr code] == noErr)
    {
    realWordsLanguageGeneratorResults = [realErr userInfo];

    reallmPath = [realWordsLanguageGeneratorResults objectForKey:@”LMPath”];

    realdicPath = [realWordsLanguageGeneratorResults objectForKey:@”DictionaryPath”];
    }

    else
    {
    NSLog(@”Error: %@”,[realErr localizedDescription]);
    }

    [self.realPocketsphinxController startRealtimeListeningWithLanguageModelAtPath:reallmPath andDictionaryAtPath:realdicPath];

    [self.realPocketsphinxController setRapidEarsToVerbose:FALSE]; // This defaults to FALSE but will give a lot of debug readout if set TRUE

    [self.realPocketsphinxController setRapidEarsAccuracy:1]; // This defaults to 20, maximum accuracy, but can be set as low as 1 to save CPU

    [self.realPocketsphinxController setFinalizeHypothesis:TRUE]; // This defaults to TRUE and will return a final hypothesis, but can be turned off to save a little CPU and will then return no final hypothesis; only partial “live” hypotheses.

    [self.realPocketsphinxController setFasterPartials:TRUE]; // This will give faster rapid recognition with less accuracy. This is what you want in most cases since more accuracy for partial hypotheses will have a delay.

    [self.realPocketsphinxController setFasterFinals:FALSE]; // This will give an accurate final recognition. You can have earlier final recognitions with less accuracy as well by setting this to TRUE.
    }

    – (PocketsphinxController *)retroPocketsphinxController
    {
    if (retroPocketsphinxController == nil)
    {
    retroPocketsphinxController = [[PocketsphinxController alloc] init];
    }

    return retroPocketsphinxController;
    }

    – (PocketsphinxController *)realPocketsphinxController
    {
    if (realPocketsphinxController == nil)
    {
    realPocketsphinxController = [[PocketsphinxController alloc] init];
    }

    return realPocketsphinxController;
    }

    #13501
    Halle Winkler
    Politepix

    Hello,

    It shouldn’t be necessary to have two instances, and it is probably harmful since they may both be accessing the driver and the VAD in a way that is unexpected due to ARC.

    Both PocketsphinxController and PocketsphinxController+RapidEars use a PocketsphinxController instance, so you should be able to use a single instance of PocketsphinxController for both, and when you want to listen with RapidEars use RapidEars’ start method of startRealtimeListeningWithLanguageModelAtPath: and when you want to listen without RapidEars use the basic PocketsphinxController startListeningWithLanguageModelAtPath: method. Just be sure that you use the stopListening method for either before you start the other one. I’ve personally used both from the same PocketsphinxController instance in the same session so I would expect it to work.

    Let me know if this helps.

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