Skip to content

Pocketshinx - add new words on language model on the fly #39

Description

@1Caxz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions