ishan jain
ishan jain

Reputation: 681

Pocketsphinx on Android failed to find acoustic model definition mdef

I have copied so file in libs folder and sync folder and assets.lst file in the assets.I also added pocketsphinx-android-0.8-nolib.jar to the application. I also added:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

permissions to the manifest file.

Then I added code for set up SpechRecognizer

private void setUpRecognizer(){
    Assets assets = new Assets(context);
    File assetDir = assets.syncAssets();
    File modelsDir = new File(assetsDir, "models");
    recognizer = defaultSetup()
        .setAcousticModel(new File(assetsDir, "hmm/en-us-semi"))
        .setDictionary(new File(assetsDir, "dict/cmu07a.dic"))
        .setRawLogDir(assetsDir).setKeywordThreshold(1e-40f)
        .getRecognizer();
    recognizer.addListener(this);
    File modelsDir = new File(assetsDir, "models");
    recognizer = defaultSetup()
        .setAcousticModel(new File(assetsDir, "hmm/en-us-semi"))
        .setDictionary(new File(assetsDir, "dict/cmu07a.dic"))
        .setRawLogDir(assetsDir).setKeywordThreshold(1e-40f)
        .getRecognizer();
    recognizer.addListener(this);
    recognizer.addKeyphraseSearch(KWS_SEARCH, KEYPHRASE);
    File menuGrammer = new File(modelsDir, "grammar/menu.gram");
    recognizer.addGrammarSearch(MENU_SEARCH, menuGrammer);
    File digitGrammer = new File(modelsDir, "grammar/digits.gram");
    recognizer.addGrammarSearch(DIGITS_SEARCH, digitGrammer);
    File languageModel = new File(modelsDir, "lm/weather.dmp");
    recognizer.addNgramSearch(FORECAST_SEARCH, languageModel);
}

After running the application, I am getting the exception:

08-26 13:42:38.301: E/cmusphinx(14405): ERROR: "acmod.c", line 90: Folder '/storage/sdcard0/Android/data/com.perscitussln.sherbet/files/sync/hmm/en-us-semi' does not contain acoustic model definition 'mdef'

Can anyone help me to solve this problem or give me some advice?

Upvotes: 2

Views: 1401

Answers (1)

Nikolay Shmyrev
Nikolay Shmyrev

Reputation: 25220

This:

   File modelsDir = new File(assetsDir, "models");
   recognizer = defaultSetup()
        .setAcousticModel(new File(assetsDir, "hmm/en-us-semi"))

Must be changed to

   File modelsDir = new File(assetsDir, "models");
   recognizer = defaultSetup()
        .setAcousticModel(new File(modelsDir, "hmm/en-us-semi"))

or to this:

    recognizer = defaultSetup()
         .setAcousticModel(new File(assetsDir, "models/hmm/en-us-semi"))

Take care next time.

Upvotes: 2

Related Questions