i`m trying to do exactly what the author of this thread did/solved:
Recognizing multiple keywords using PocketSphinx
he says the grammar-file should be something like this to avoid detection of words not in grammar-file:
up /1e-1/
down /1e-1/
left /1e-1/
right /1e-1/
forwards /1e-1/
backwards /1e-1/
....but it doesnt work if it is exactly like this. I can do it like this:
#JSGF V1.0;
grammar digits;
public <digits> = /1e-1/ left |
/1e-1/ right;
but this doesnt change anything, neither does /1.0/ change anything. It keeps detecting false words as left/right.
Putting the threshold on the right side of each word (like the author) leads to app-crashing.
Can someone help me on this?
UPDATE:
i solved it, by using addKeywordSearch in the function setupRecognizer(File assetsDir). It was still like in the PocketSphinx-Demo addGrammarSearch in my case. For completeness (just like the setupRecognizer function of the author of the linked question):
private void setupRecognizer(File assetsDir)
{
File modelsDir = new File(assetsDir, "models");
recognizer = defaultSetup().setAcousticModel(new File(modelsDir, "hmm/en-us-semi"))
.setDictionary(new File(modelsDir, "dict/cmu07a.dic"))
.setRawLogDir(assetsDir).setKeywordThreshold(1e-20f)
.getRecognizer();
recognizer.addListener(this);
File digitsGrammar = new File(modelsDir, "grammar/digits.gram");
recognizer.addKeywordSearch(DIGITS_SEARCH, digitsGrammar);
}
it then works if the grammar file looks (also like the author posted) exactly like this:
up /1e-1/
down /1e-1/
left /1e-1/
right /1e-1/
forwards /1e-1/
backwards /1e-1/