Home › Forums › OpenEars › not sure how to use ChangeLanguageModelToFile › Reply To: not sure how to use ChangeLanguageModelToFile
August 29, 2014 at 7:45 pm
#1022411
JonLocate
Participant
After looking through the example i modified my code to have a second language model and its paths
NSString *name = @"commandModel";
NSError *commandModel = [lmGenerator generateRejectingLanguageModelFromArray:commandVocab withFilesNamed:name withOptionalExclusions:nil usingVowelsOnly:FALSE withWeight:nil forAcousticModelAtPath:[AcousticModel pathToModel:@"AcousticModelEnglish"]];
NSDictionary *languageGeneratorResults = nil;
if([commandModel code] == noErr)
{
languageGeneratorResults = [commandModel userInfo];
// not sure if i need these file vars as they are not in the tutorial but are in the demo app
lmFile = [languageGeneratorResults objectForKey:@"LMFile"];
dicFile = [languageGeneratorResults objectForKey:@"DictionaryFile"];
lmPath = [languageGeneratorResults objectForKey:@"LMPath"];
dicPath = [languageGeneratorResults objectForKey:@"DictionaryPath"];
}
else
{
NSLog(@"Error: %@",[commandModel localizedDescription]);
}
NSString *name1 = @"BreadModel";
NSError *breadModel = [lmGenerator generateRejectingLanguageModelFromArray:breadVocab withFilesNamed:name1 withOptionalExclusions:nil usingVowelsOnly:FALSE withWeight:nil forAcousticModelAtPath:[AcousticModel pathToModel:@"AcousticModelEnglish"]];
NSDictionary *breadlanguageGeneratorResults = nil;
if([breadModel code] == noErr)
{
breadlanguageGeneratorResults = [commandModel userInfo];
breadlmFile = [breadlanguageGeneratorResults objectForKey:@"LMFile"];
breaddicFile = [breadlanguageGeneratorResults objectForKey:@"DictionaryFile"];
breadlmPath = [breadlanguageGeneratorResults objectForKey:@"LMPath"];
breaddicPath = [breadlanguageGeneratorResults objectForKey:@"DictionaryPath"];
}
else
{
NSLog(@"Error: %@",[breadModel localizedDescription]);
}
then when i want to change the model i call this
[pocketsphinxController changeLanguageModelToFile:breadlmPath withDictionary:breaddicPath];
not a lot different from the demo app yet the model doesn’t get changed and the model changed delegate method doesn’t get called. any ideas?
Thanks
Jon