pocketsphinx-android
pocketsphinx-android copied to clipboard
Pocketshinx - add new words on language model on the fly
Hi guys, I need help. I try to add new words in current language model already set. But the new words cannot be recognized. What's wrong with this code?
String[] words = {"one", "two", "three"};
// Language model already seted. So, this lmModel is not null.
NGramModel lmModel = speechRecognizer.getDecoder().getLm("CURRENT_LM");
for (String word: words) {
int result = lmModel.addWord(word.trim().toLowerCase(Locale.ENGLISH), 1.7f);
System.out.println("Result word: " + a);
if (result < 0) {
System.out.println(word + " doesn't support. Please add word \""+ word + "\" in dictionary.");
}
}
// I have tried to remove and add this line but the result is same.
speechRecognizer.getRapidDecoder().setLm(SEARCH_ID, lmModel);
The result values are:
Result word: 7
Result word: 8
Result word: 9