Reply To: Changing Lang. Model Dynamically with Rejecto Couldn't Get Attributes of LM

Home Forums OpenEars plugins Changing Lang. Model Dynamically with Rejecto Couldn't Get Attributes of LM Reply To: Changing Lang. Model Dynamically with Rejecto Couldn't Get Attributes of LM

#1021971
Halle Winkler
Politepix

OK, I will do a permanent fix for this in the next version, but for now, look for this chunk in ContinuousModel.m:

		NSFileManager *fileManager = [[NSFileManager alloc] init];
		NSError *error = nil;
		NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:self.languageModelFileToChangeTo error:&error];
		if(error) {
			if(openears_logging == 1) NSLog(@"Error: couldn't get attributes of language model file.");
            fatalErrors++;
		} else {
			if(openears_logging == 1) NSLog(@"In this session, the requested language model will be known to Pocketsphinx as id %@.",[fileAttributes valueForKey:NSFileSystemFileNumber]);
			languageModelID = [fileAttributes valueForKey:NSFileSystemFileNumber];
		}
        
		[fileManager release];

I think this issue should be fixed if you comment this entire section above out, and change this line which precedes it:

NSNumber *languageModelID = [NSNumber numberWithInt:999];

So that the integer 999 is basically replaced with any guaranteed-to-be-unique int for that listening loop instance. So you could have a property int that increments right before it is assigned to that NSNumber, or you could derive it from a datestamp, or any similar approach to get a new number that you like. The goal is just to make sure that where it says 999 above is replaced with some other int which is definitely unique for every language model change request within a single run of the continuous listening loop.

I would expect this to work – let me know if the 2nd and later model changes start listening successfully again.