Pregenerate Language Model

Home Forums OpenEars Pregenerate Language Model

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

  • Author
    Posts
  • #1017342
    abshih
    Participant

    Hello,

    I believe I read the tutorial and it mentions that you can pregenerate this language model so users don’t have to generate the language model each time the app initializes the pocketsphinx.

    Currently, I am generating the language model on initialization and for some reason it works most of the time, however if I add words it will sometimes crash. I also get warnings

    sih_add WARNING: repeated hashing of ‘REFRESH’, older value will be overridden.
    sih_add WARNING: repeated hashing of ‘THREE’, older value will be overridden.

    Here is the code I use:

     LanguageModelGenerator *lmGenerator = [[LanguageModelGenerator alloc] init];
                    
                    NSArray *words = [NSArray arrayWithObjects:@"OPEN REQUEST", @"ONE", @"TWO",@"THREE", @"FOUR", @"FIVE", @"SIX", @"SEVEN", @"EIGHT", @"NINE", @"ZERO", @"CURRENT STATUS", @"UNASSIGNED TAB", @"MY OPEN TAB", @"MY TEAM TAB", @"PENDING TAB", @"AUTO REFRESH ON", @"AUTO REFRESH OFF", @"SELECT ROW", @"PAGE UP", @"PAGE DOWN", nil];
                    NSString *name = @"HDMLanguageModel";
                    NSError *err = [lmGenerator generateLanguageModelFromArray:words withFilesNamed:name];
                    
                    
                    NSDictionary *languageGeneratorResults = nil;
                    
                    NSString *lmPath = nil;
                    NSString *dicPath = nil;
                    
                    if([err code] == noErr) {
                        
                        languageGeneratorResults = [err userInfo];
                        
                        lmPath = [languageGeneratorResults objectForKey:@"LMPath"];
                        dicPath = [languageGeneratorResults objectForKey:@"DictionaryPath"];
                        
                    } else {
                        NSLog(@"Error: %@",[err localizedDescription]);
                    }
                    
                    //STARTING LISTENING
                    [self.pocketsphinxController startListeningWithLanguageModelAtPath:lmPath dictionaryAtPath:dicPath languageModelIsJSGF:NO];
    
    #1017345
    Halle Winkler
    Politepix

    If you are reporting a crash, you must turn on OpenEarsLogging and verbosePocketsphinx as I described twice in your other question. Please read the post I linked to in that question and turn on all logging and post the output.

    #1017346
    abshih
    Participant

    Hello Halle,

    I have verbose turned on, but I have no experienced the crash since turning on Verbose. I am wondering how do you pre-generate the language so I don’t have to do the above code everytime I want to start PocketSphinx,

    Thanks,
    Alan

    #1017347
    Halle Winkler
    Politepix

    You can read this to learn how to create a model in advance:
    https://www.politepix.com/2012/11/02/openears-tips-1-create-a-language-model-before-runtime-from-a-text-file/

    Please don’t report any more crashing issues unless you are willing to post logs.

    #1017352
    abshih
    Participant

    Hello Halle,

    If I have verbose mode turned on. I will post back if I experience the issue again.

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