Pocketsphinx on android "LDA incompatible with multi-stream features" while speech recognizer setup

294 views Asked by At

I faced a problem while trying to replace English accoustic model with Russian one here:

recognizer = SpeechRecognizerSetup.defaultSetup()
                .setAcousticModel(new File(assetsDir, "ru"))

The error is: "java.lang.ClassNotFoundException: edu.cmu.pocketsphinx.SphinxBaseJNI"

From sourceforge I've downloaded all the archives and tried each set of accoustic models: zero_ru.cd_ptm_4000, zero_ru.cd_cont_4000, zero_ru.cd_semi_4000, cmusphinx-ru-5.2 by pasting them in the folder ...\models\src\main\assets\sync\en-us-ptm of the pocketsphinx-android-demo-master app. Naturally I've replaced English dictionary too. The error occured while configuring the "-hmm" stuff of speechRecognizer inside this method:

public SpeechRecognizerSetup setAcousticModel(File model) {
        return this.setString("-hmm", model.getPath());
    }

in SpeechRecognizerSetup.class of the pocketsphinx. What classes are missing? The English speech recognition works just perfect on my KitKat 4.4.2

IDE: Android Studio 2.33

Gradle version: 3.3

Android plugin version: 2.3.3

gradle.build of the app:

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'
    defaultConfig {
        applicationId "edu.cmu.sphinx.pocketsphinx"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 2
        versionName "1.1"
    }
    productFlavors {
    }
}

dependencies {
    compile project(':aars')
    compile project(':models')
    compile 'com.android.support:appcompat-v7:25.0.0'

Edited Logcat:

 E/cmusphinx: ERROR: "lda.c", line 71: LDA incompatible with multi-stream features (n_stream = 4)
 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                       Process: edu.cmu.sphinx.pocketsphinx, PID: 23373
                                                       java.lang.RuntimeException: An error occured while executing doInBackground()
                                                           at android.os.AsyncTask$3.done(AsyncTask.java:300)
                                                           at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                                                           at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                                                           at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                                                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                           at java.lang.Thread.run(Thread.java:841)
                                                        Caused by: java.lang.RuntimeException: new_Decoder returned -1
                                                           at edu.cmu.pocketsphinx.PocketSphinxJNI.new_Decoder__SWIG_1(Native Method)
                                                           at edu.cmu.pocketsphinx.Decoder.<init>(Decoder.java:43)
                                                           at edu.cmu.pocketsphinx.SpeechRecognizer.<init>(SpeechRecognizer.java:79)
                                                           at edu.cmu.pocketsphinx.SpeechRecognizerSetup.getRecognizer(SpeechRecognizerSetup.java:74)
                                                           at edu.cmu.pocketsphinx.demo.PocketSphinxActivity.setupRecognizer(PocketSphinxActivity.java:222)
                                                           at edu.cmu.pocketsphinx.demo.PocketSphinxActivity.access$000(PocketSphinxActivity.java:55)
                                                           at edu.cmu.pocketsphinx.demo.PocketSphinxActivity$1.doInBackground(PocketSphinxActivity.java:108)
                                                           at edu.cmu.pocketsphinx.demo.PocketSphinxActivity$1.doInBackground(PocketSphinxActivity.java:102)
                                                           at android.os.AsyncTask$2.call(AsyncTask.java:288)
                                                           at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
                                                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                                           at java.lang.Thread.run(Thread.java:841) 

Any help will be appreciated!

2

There are 2 answers

0
Sophour On BEST ANSWER

So in my working configuration I've used "ru.txt" dictionary from "zero_ru_cont_8k_v3.tar.gz" archive and accoustic model which is located in "zero_ru.cd_ptm_4000" directory of that archive. In my app I've left only keyword-activation search and grammar-based search. I've had to change ru.txt and menu.dict files extentions to .dict and .jsgf respectively. From this the app should work on conditions you've properly placed the lib and assets, you haven't left variables with any other words but russian to search and recognize, and didn't forget to add ant script to your build.gradle like it's explained here.

These issues should be solved:

java.lang.RuntimeException: new_Decoder returned -1

java.lang.ClassNotFoundException: edu.cmu.pocketsphinx.SphinxBaseJNI

java.util.concurrent.ExecutionException: java.lang.RuntimeException: Decoder_setJsgfFile returned -1

09-14 12:29:40.436 10908-10944/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "kws_search.c", line 528: Word 'запуск' in phrase 'запуск' is missing in the dictionary 09-14 12:30:01.029 678-949/? E/RemoteViews: ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search

09-14 12:06:09.113 2298-2339/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "dict.c", line 195: Line 545276: Phone 'o1' is mising in the acoustic model; word 'ёлочкой' ignored 09-14 12:06:09.113 2298-2339/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "dict.c", line 195: Line 545277: Phone 'o1' is mising in the acoustic model; word 'ёлочку' ignored 09-14 12:06:09.113 2298-2339/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "dict.c", line 195: Line 545278: Phone 'o1' is mising in the acoustic model; word 'ёлочной' ignored 09-14 12:06:09.113 2298-2339/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "dict.c", line 195: Line 545279: Phone 'o1' is mising in the acoustic model; word 'ёлочный' ignored 09-14 12:06:09.113 2298-2339/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "dict.c", line 195: Line 545280: Phone 'o1' is mising in the acoustic model; word 'ём' ignored 09-14 12:06:09.114 2298-2339/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "dict.c", line 195: Line 545281: Phone 'o1' is mising in the acoustic model; word 'ёмкий' ignored 09-14 12:06:09.114 2298-2339/edu.cmu.sphinx.pocketsphinx E/cmusphinx: ERROR: "dict.c", line 195: Line 545282: Phone 'o1' is mising in the acoustic model; word 'ёмкими' ignored

1
Nikolay Shmyrev On

E/cmusphinx: ERROR: "lda.c", line 71: LDA incompatible with multi-stream features (n_stream = 4)

This error means you forgot to delete feature_transform from the model folder or it remains on sdcard. Extra file in the model folder breaks model loading. You need to

  1. Clean model folder on sdcard on the phone.
  2. Make sure you do not have extra files in the assets folder.