Reply To: Change vocabulary array on the fly?

Home Forums OpenEars Change vocabulary array on the fly? Reply To: Change vocabulary array on the fly?

#1019414
davestrand
Participant

Here’s the function to attempt to reload based on plist data..


- (void) reLoadLanguageBasedOnNewVariables {
    
    LanguageModelGenerator *languageModelGenerator = [[LanguageModelGenerator alloc] init];
 
    
    NSArray *languageArray = [[NSArray alloc] initWithArray:[NSArray arrayWithObjects: // All capital letters.
                                                             
                                                             
                                                        
                                                             @"YES",
                                                             @"NO",
                                                             @"MAYBE",
                                                       
                                                             @"DIAPER",
                                                             
                                                             
                                                            
                                                             @"%@",[NSString stringWithFormat:@"%@", [playerIsNowAt valueForKey:@"ObjectsInLocation"]],
                                                             
                                                             nil]];
    
    NSLog(@"Checking the objects in the room are correct %@", [playerIsNowAt valueForKey:@"ObjectsInLocation"]);//Yep, it's loading the new objects
    
     NSString *name = @"VoiceGameModelFiles";
     NSError *err = [languageModelGenerator generateLanguageModelFromArray:languageArray withFilesNamed:name forAcousticModelAtPath:[AcousticModel pathToModel:@"AcousticModelEnglish"]]; // Change "AcousticModelEnglish" to "AcousticModelSpanish" to create a Spanish language model instead of an English one.

    
	NSDictionary *dynamicLanguageGenerationResultsDictionary = nil;
     
	if([err code] != noErr) {
		NSLog(@"Dynamic language generator reported error %@", [err description]);
	
    } else {
	
        dynamicLanguageGenerationResultsDictionary = [err userInfo];
		
        NSString *lmPath = [dynamicLanguageGenerationResultsDictionary objectForKey:@"LMPath"];
	NSString *dictionaryPath = [dynamicLanguageGenerationResultsDictionary objectForKey:@"DictionaryPath"];
		
        self.pathToDynamicallyGeneratedGrammar = lmPath; // We'll set our new .languagemodel file to be the one to get switched to when the words "CHANGE MODEL" are recognized.
		self.pathToDynamicallyGeneratedDictionary = dictionaryPath; // We'll set our new dictionary to be the one to get switched to when the words "CHANGE MODEL" are recognized.
        
    }
    
}