1

I'm trying to test some basic keyword recognition in a Fragment using this pocket sphinx android library. I've got the project jar set up and correctly added as a dependency, I've added the .so files to the jniLibs folder as instructed in this tutorial http://cmusphinx.sourceforge.net/wiki/tutorialandroid

Everything seems to work fine as far as the other searches(digits, etc)..But for some reason I can't get keyword search to work. I'm getting a crash with a very clear and explicit error message. It's basically saying that a bunch of words aren't found in the dictionary.

04-19 14:35:59.930    6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'EH' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'SH' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'Z' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'SH' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'ZH' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'ZH' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'ZH' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'ZH' is missing in the dictionary
04-19 14:35:59.930    6086-6107/? E/cmusphinx﹕ ERROR: "kws_search.c", line 165: The word 'SH' is missing in the dictionary

I'm using the dictionary that comes packaged with the library, the "cmu-en-us.dict", which in fact doesn't seem to have these capitalized words included at all.

So then I searched around and found this one http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b

When I added that to the project, and tried to reference that dictionary instead. I got the same errors as before, but now saying that the words in the previous dictionary I was using(cmu-en-us.dict) was missing.

I'm not sure what I'm doing wrong. But I just followed the set up tutorial and also used the code from the demo project's Activity here https://github.com/cmusphinx/pocketsphinx-android-demo/blob/master/app/src/main/java/edu/cmu/pocketsphinx/demo/PocketSphinxActivity.java

Oh, and here's how I'm setting up my SpeechRecognizer

private void setupRecognizer(File assetsDir) throws IOException {
    // The recognizer can be configured to perform multiple searches
    // of different kind and switch between them
    Log.d("RecipeSearchFragment", "setupRecognizer");
    mRecognizer = defaultSetup()
            .setAcousticModel(new File(assetsDir, "en-us-ptm"))
            .setDictionary(new File(assetsDir, "cmudict-en-us.dict"))


                    // To disable logging of raw audio comment out this call (takes a lot of space on the device)
            .setRawLogDir(assetsDir)

                    // Threshold to tune for keyphrase to balance between false alarms and misses
            .setKeywordThreshold(1e-45f)

                    // Use context-independent phonetic search, context-dependent is too slow for mobile
            .setBoolean("-allphone_ci", true)

            .getRecognizer();
    mRecognizer.addListener(this);

    /** In your application you might not need to add all those searches.
     * They are added here for demonstration. You can leave just one.
     */


    mRecognizer.addKeywordSearch(KWS_SEARCH, new File(assetsDir, "cmudict-en-us.dict"));

    mRecognizer.startListening(KWS_SEARCH);

}

Anyone else ever run into this? What am I doing wrong here?

Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94
Jade Byfield
  • 4,668
  • 5
  • 30
  • 41

1 Answers1

0

Keyword search is configured with a keyphrase list file. Keyphrase list file lists keyphrases one per line:

Recognizing multiple keywords using PocketSphinx

You incorrectly used dictionary as a keyword list file in the following line:

mRecognizer.addKeywordSearch(KWS_SEARCH, new File(assetsDir, "cmudict-en-us.dict"));

It is not a good idea.

Community
  • 1
  • 1
Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • Thanks for the comment! I figured I was doing something incorrectly. So basically I would have to configure my own keyphrase list file with a set of predefined words to look for? I thought the library could be used to recognize dynamic words like "eggs" or "bird". At least for my use case, I wouldn't be able to know what word the user will have said ahead of time. Can I accomplish this with pocket sphinx? – Jade Byfield Apr 19 '15 at 19:47
  • http://stackoverflow.com/questions/25949295/cmusphinx-pocketsphinx-recognize-all-or-large-amount-of-english-words?rq=1 – Nikolay Shmyrev Apr 19 '15 at 19:52
  • for me, , I was passing lower case "ok" so its case sensitive also – Hamza Oct 29 '18 at 20:41