I need to replace N-gram LMs on the fly, without reloading the whole recognizer.
It can be easily done for JSGFGrammar with loadJSGF, but I am not sure what is the correct way to do it for SimpleNGramModel.
NB: I am still using the XML configs, and get access components via lookup, since the new API requires to reload the recognizer for every single recognition input.
While I can see that e.g. component's vocabulary has been changed, the recognition output tells me that no real replacement has been made. Could you tell me whether it is possible and how?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is the valid way to change properties: ConfigurationManagerUtils.setProperty(configurationManager, "simpleNGramModel->location", LMFile.toURI().toURL().toString()).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will try it, but as far as I can see, call of ConfigurationManagerUtils.setProperty will lead to the same call of PropertySheet.setString (ConfigurationManagerUtils.java:666).
I would like to know whether such a ngram swap should work all, without reallocation of the whole decoder (or linguist).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I can see that reallocation of language model has no effect after HMMTree has been created in LexTreeLinguist. And I cannot see any existing way to force the HMMTree to be re-compiled...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I need to replace N-gram LMs on the fly, without reloading the whole recognizer.
It can be easily done for JSGFGrammar with loadJSGF, but I am not sure what is the correct way to do it for SimpleNGramModel.
NB: I am still using the XML configs, and get access components via lookup, since the new API requires to reload the recognizer for every single recognition input.
I tried to do it like this:
While I can see that e.g. component's vocabulary has been changed, the recognition output tells me that no real replacement has been made. Could you tell me whether it is possible and how?
Thanks.
You must call SimpleNGramModel#deallocate() before changing properties.
Oops, I forgot to put a line above.
I do deallocate it:
This is the valid way to change properties:
ConfigurationManagerUtils.setProperty(configurationManager, "simpleNGramModel->location", LMFile.toURI().toURL().toString()).Ok, thanks.
I will try it, but as far as I can see, call of ConfigurationManagerUtils.setProperty will lead to the same call of PropertySheet.setString (ConfigurationManagerUtils.java:666).
I would like to know whether such a ngram swap should work all, without reallocation of the whole decoder (or linguist).
Usage of ConfigurationManagerUtils#setProperty provide me with the same result: the initial LM is not changed :(
Ok, I can see that reallocation of language model has no effect after HMMTree has been created in LexTreeLinguist. And I cannot see any existing way to force the HMMTree to be re-compiled...
LexTreeLinguist.allocate()?
This causes everything to be reallocated: dictionary, acoustic model, HMM pool.
So, if anybody will face the same problem, you can add this method to LexTreeLinguist class: