Menu

Pocketsphinx Android - Dynamic keywords at runtime

Help
2015-07-02
2015-07-02
  • John Gifford

    John Gifford - 2015-07-02

    Hello,

    I have the Pocketsphinx for Android demo (latest) running and have a question about keywords.

    I have developed with the OpenEars library for iOS and I have seen the ability to dynamically add keyphrases to listen for at runtime. The recognizer will only listen for those words and nothing else.
    In the application I have to work with, the keyphrases are not known at compile-time, they come from an API that is downloaded to my app at runtime. I can expect these dynamic words to be present in the dictionary (cmudict-en-us.dict) but I want to filter down my listener to only listen to these dynamic words and not any others.

    I have tried:

    addKeyphraseSearch(tag, dynamic_word);
    - This will only work with one word at a time, I have a list of words to listen for

    addNgramSearch(tag, languageModelFile);
    - Too many results, I would like to filter this by supplying a list of words and comparing to the Hypothesis object in onPartialResult, but the library seems to confuse what I am saying with a different phrase too often for this to be reliable.

    addGrammarSearch(tag, grammarFile);
    - This works perfectly, except I cannot add/remove words from the .gram file at runtime. Since I do not know what the keywords will be, I cannot compile the app with .gram file populated. Can I edit this file at runtime to supply a list of words using file I/O?

    Thank you in advance for providing me with any solution using the pocketsphinx-android library. I apologize if the solution is very obvious, I am just not seeing it yet.

     

    Last edit: John Gifford 2015-07-02
  • John Gifford

    John Gifford - 2015-07-02

    I have seen this post, but it appears that reading from a .gram file is required for this.

    Modifying the .gram files at runtime is allowed? I would need to use file I/O to add keywords to the .gram file at runtime to accomplish this if I understand correctly.

    Thank you.

     
    • Nickolay V. Shmyrev

      Sure, you can create a file in internal storage first and then pass it to recognizer.

       
      • John Gifford

        John Gifford - 2015-07-02

        Excellent, this will work perfectly for me.

        Thank you for the support and the great work on this library!

         

Log in to post a comment.