Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
135 views
in Technique[技术] by (71.8m points)

java - PocketSphinx android demo runtime exception

I downloaded the source code of pocket sphinx demo. I'm trying to run it but it is throwing a runtime exception. I've posted the logcat of my code.

09-09 11:45:38.980: I/System.out(7912): Sending WAIT chunk
09-09 11:45:38.980: W/ActivityThread(7912): Application edu.cmu.pocketsphinx.demo is waiting for the debugger on port 8100...
09-09 11:45:39.030: I/dalvikvm(7912): Debugger is active
09-09 11:45:39.210: I/System.out(7912): Debugger has connected
09-09 11:45:39.210: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:39.400: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:39.600: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:39.810: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:40.000: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:40.210: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:40.400: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:40.600: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:40.810: I/System.out(7912): waiting for debugger to settle...
09-09 11:45:41.010: I/System.out(7912): debugger has settled (1359)
09-09 11:45:41.930: D/dalvikvm(7912): threadid=1: still suspended after undo (sc=1 dc=1)
09-09 11:45:48.960: I/dalvikvm(7912): threadid=4: reacting to signal 3
09-09 11:45:48.960: D/dalvikvm(7912): threadid=1: still suspended after undo (sc=1 dc=1)
09-09 11:45:48.960: I/dalvikvm(7912): Wrote stack traces to '/data/anr/traces.txt'
09-09 11:45:52.310: D/dalvikvm(7912): GC_EXTERNAL_ALLOC freed 44K, 49% free 2778K/5379K, external 0K/0K, paused 26ms
09-09 11:45:58.770: D/CLIPBOARD(7912): Hide Clipboard dialog at Starting input: finished by someone else... !
09-09 11:46:05.860: D/dalvikvm(7912): GC_CONCURRENT freed 366K, 50% free 2845K/5639K, external 7K/1286K, paused 2ms+3ms
09-09 11:46:05.870: I/Assets(7912): Skipping asset models/grammar/menu.gram: checksums are equal
09-09 11:46:05.870: I/Assets(7912): Skipping asset models/grammar/digits.gram: checksums are equal
09-09 11:46:05.880: I/Assets(7912): Skipping asset models/lm/3015.lm: checksums are equal
09-09 11:46:05.890: I/Assets(7912): Skipping asset models/hmm/en-us/noisedict: checksums are equal
09-09 11:46:05.900: I/Assets(7912): Skipping asset models/hmm/en-us/mixture_weights: checksums are equal
09-09 11:46:05.900: I/Assets(7912): Skipping asset models/hmm/en-us/means: checksums are equal
09-09 11:46:05.900: I/Assets(7912): Skipping asset models/hmm/en-us/variances: checksums are equal
09-09 11:46:05.900: I/Assets(7912): Skipping asset models/hmm/en-us/transition_matrices: checksums are equal
09-09 11:46:05.910: I/Assets(7912): Skipping asset models/dict/5497.dic: checksums are equal
09-09 11:46:05.910: I/Assets(7912): Skipping asset models/hmm/en-us/feature_transform: checksums are equal
09-09 11:46:05.910: I/Assets(7912): Skipping asset models/hmm/en-us/mdef: checksums are equal
09-09 11:46:05.910: I/Assets(7912): Skipping asset models/hmm/en-us/feat.params: checksums are equal
09-09 11:46:05.910: I/Assets(7912): Skipping asset models/hmm/en-us/README: checksums are equal
09-09 11:46:15.670: D/dalvikvm(7912): Trying to load lib /data/data/edu.cmu.pocketsphinx.demo/lib/libpocketsphinx_jni.so 0x4051cbd0
09-09 11:46:15.680: D/dalvikvm(7912): Added shared lib /data/data/edu.cmu.pocketsphinx.demo/lib/libpocketsphinx_jni.so 0x4051cbd0
09-09 11:46:15.680: D/dalvikvm(7912): No JNI_OnLoad found in /data/data/edu.cmu.pocketsphinx.demo/lib/libpocketsphinx_jni.so 0x4051cbd0, skipping init
09-09 11:46:15.680: I/cmusphinx(7912): INFO: cmd_ln.c(696): Parsing command line:
09-09 11:46:15.680: I/cmusphinx(7912): Current configuration:
09-09 11:46:31.640: I/cmusphinx(7912): INFO: cmd_ln.c(696): Parsing command line:
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -nfilt 
09-09 11:46:31.640: I/cmusphinx(7912): 25 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -lowerf 
09-09 11:46:31.640: I/cmusphinx(7912): 130 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -upperf 
09-09 11:46:31.640: I/cmusphinx(7912): 6800 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -transform 
09-09 11:46:31.640: I/cmusphinx(7912): dct 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -lifter 
09-09 11:46:31.640: I/cmusphinx(7912): 22 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -feat 
09-09 11:46:31.640: I/cmusphinx(7912): 1s_c_d_dd 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -agc 
09-09 11:46:31.640: I/cmusphinx(7912): none 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -cmn 
09-09 11:46:31.640: I/cmusphinx(7912): current 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -varnorm 
09-09 11:46:31.640: I/cmusphinx(7912): no 
09-09 11:46:31.640: I/cmusphinx(7912): 
09-09 11:46:31.640: I/cmusphinx(7912):  
09-09 11:46:31.640: I/cmusphinx(7912): -cmninit 
09-09 11:46:31.640: I/cmusphinx(7912): 40 
09-09 11:46:31.640: I/cmusphinx(7912): Current configuration:
09-09 11:46:31.640: I/cmusphinx(7912): INFO: acmod.c(251): Parsed model-specific feature parameters from /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/feat.params
09-09 11:46:31.640: I/cmusphinx(7912): INFO: feat.c(715): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='current', VARNORM='no', AGC='none'
09-09 11:46:31.640: I/cmusphinx(7912): INFO: cmn.c(143): mean[0]= 12.00, mean[1..12]= 0.0
09-09 11:46:31.640: I/cmusphinx(7912): INFO: acmod.c(160): Reading linear feature transformation from /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/feature_transform
09-09 11:46:31.650: I/cmusphinx(7912): INFO: mdef.c(517): Reading model definition: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/mdef
09-09 11:46:33.430: I/cmusphinx(7912): INFO: bin_mdef.c(181): Allocating 173954 * 8 bytes (1359 KiB) for CD tree
09-09 11:46:33.570: I/cmusphinx(7912): INFO: tmat.c(206): Reading HMM transition probability matrices: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/transition_matrices
09-09 11:46:33.570: I/cmusphinx(7912): INFO: acmod.c(123): Attempting to use SCHMM computation module
09-09 11:46:33.570: I/cmusphinx(7912): INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/means
09-09 11:46:35.110: I/cmusphinx(7912): INFO: ms_gauden.c(292): 6138 codebook, 1 feature, size: 
09-09 11:46:35.110: I/cmusphinx(7912): INFO: ms_gauden.c(294):  32x32
09-09 11:46:35.110: I/cmusphinx(7912): INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/variances
09-09 11:46:36.890: I/cmusphinx(7912): INFO: ms_gauden.c(292): 6138 codebook, 1 feature, size: 
09-09 11:46:36.900: I/cmusphinx(7912): INFO: ms_gauden.c(294):  32x32
09-09 11:46:38.920: I/cmusphinx(7912): INFO: ms_gauden.c(354): 768 variance values floored
09-09 11:46:38.950: I/cmusphinx(7912): INFO: acmod.c(125): Attempting to use PTHMM computation module
09-09 11:46:38.960: I/cmusphinx(7912): INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/means
09-09 11:46:40.140: I/cmusphinx(7912): INFO: ms_gauden.c(292): 6138 codebook, 1 feature, size: 
09-09 11:46:40.140: I/cmusphinx(7912): INFO: ms_gauden.c(294):  32x32
09-09 11:46:40.140: I/cmusphinx(7912): INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/variances
09-09 11:46:40.820: I/cmusphinx(7912): INFO: ms_gauden.c(292): 6138 codebook, 1 feature, size: 
09-09 11:46:40.820: I/cmusphinx(7912): INFO: ms_gauden.c(294):  32x32
09-09 11:46:42.850: I/cmusphinx(7912): INFO: ms_gauden.c(354): 768 variance values floored
09-09 11:46:42.850: I/cmusphinx(7912): INFO: ptm_mgau.c(792): Number of codebooks exceeds 256: 6138
09-09 11:46:42.860: I/cmusphinx(7912): INFO: acmod.c(127): Falling back to general multi-stream GMM computation
09-09 11:46:42.860: I/cmusphinx(7912): INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/means
09-09 11:46:43.280: I/cmusphinx(7912): INFO: ms_gauden.c(292): 6138 codebook, 1 feature, size: 
09-09 11:46:43.280: I/cmusphinx(7912): INFO: ms_gauden.c(294):  32x32
09-09 11:46:43.280: I/cmusphinx(7912): INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/variances
09-09 11:46:43.480: I/cmusphinx(7912): INFO: ms_gauden.c(292): 6138 codebook, 1 feature, size: 
09-09 11:46:43.480: I/cmusphinx(7912): INFO: ms_gauden.c(294):  32x32
09-09 11:46:45.540: I/cmusphinx(7912): INFO: ms_gauden.c(354): 768 variance values floored
09-09 11:46:45.550: I/cmusphinx(7912): INFO: ms_senone.c(149): Reading senone mixture weights: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/mixture_weights
09-09 11:46:45.550: I/cmusphinx(7912): INFO: ms_senone.c(200): Truncating senone logs3(pdf) values by 10 bits
09-09 11:46:45.550: I/cmusphinx(7912): INFO: ms_senone.c(207): Not transposing mixture weights in memory
09-09 11:46:45.610: I/cmusphinx(7912): INFO: ms_senone.c(268): Read mixture weights for 6138 senones: 1 features x 32 codewords
09-09 11:46:45.610: I/cmusphinx(7912): INFO: ms_senone.c(320): Mapping senones to individual codebooks
09-09 11:46:45.610: I/cmusphinx(7912): INFO: ms_mgau.c(141): The value of topn: 4
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict.c(320): Allocating 4181 * 20 bytes (81 KiB) for word entries
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict.c(333): Reading main dictionary: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/dict/5497.dic
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict.c(213): Allocated 0 KiB for strings, 0 KiB for phones
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict.c(336): 76 words read
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict.c(342): Reading filler dictionary: /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/sync/models/hmm/en-us/noisedict
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict.c(213): Allocated 0 KiB for strings, 0 KiB for phones
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict.c(345): 9 words read
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict2pid.c(396): Building PID tables for dictionary
09-09 11:46:45.620: I/cmusphinx(7912): INFO: dict2pid.c(406): Allocating 46^3 * 2 bytes (190 KiB) for word-initial triphones
09-09 11:46:45.650: I/cmusphinx(7912): INFO: dict2pid.c(132): Allocated 25576 bytes (24 KiB) for word-final triphones
09-09 11:46:45.650: I/cmusphinx(7912): INFO: dict2pid.c(196): Allocated 25576 bytes (24 KiB) for single-phone word triphones
09-09 11:46:59.750: I/cmusphinx(7912): INFO: kws_search.c(417): KWS(beam: -1080, plp: -23, default threshold -450)
09-09 11:46:59.750: E/cmusphinx(7912): ERROR: "kws_search.c", line 158: The word 'taking' is missing in the dictionary
09-09 11:47:07.390: I/SpeechRecognizer(7912): Load JSGF /mnt/sdcard/Android/data/edu.cm

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could see the following errors in the log:

09-09 11:47:26.250: E/cmusphinx(7912): ERROR: "fsg_search.c", line 142: The word 'nine' is missing in the dictionary
09-09 11:46:59.750: E/cmusphinx(7912): ERROR: "kws_search.c", line 158: The word 'taking' is missing in the dictionary

Looks like your dictionary is incompatible with your changes. You need to make sure dictionary contains all required words.

And, I see you made some changes but most of them are incomplete. For example you commented the code to setup named searches in setupRecognizer but didn't change switch code, so it still tries to switch to older searches. You can try something like this, it should work:

package edu.cmu.pocketsphinx.demo;

import static android.widget.Toast.makeText;
import static edu.cmu.pocketsphinx.SpeechRecognizerSetup.defaultSetup;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import edu.cmu.pocketsphinx.Assets;
import edu.cmu.pocketsphinx.Hypothesis;
import edu.cmu.pocketsphinx.RecognitionListener;
import edu.cmu.pocketsphinx.SpeechRecognizer;

public class PocketSphinxActivity extends Activity implements
        RecognitionListener {

    private static final String KWS_SEARCH = "KEYPHRASE";
    private static final String DICTATION_SEARCH = "DICTATION";

    private static final String KEYPHRASE = "MORNING";

    private SpeechRecognizer recognizer;
    private HashMap<String, Integer> captions;

    @Override
    public void onCreate(Bundle state) {
        super.onCreate(state);

        // Prepare the data for UI
        captions = new HashMap<String, Integer>();
        captions.put(KWS_SEARCH, R.string.kws_caption);
        captions.put(DICTATION_SEARCH, R.string.forecast_caption);
        setContentView(R.layout.main);
        ((TextView) findViewById(R.id.caption_text))
                .setText("Preparing the recognizer");

        // Recognizer initialization is a time-consuming and it involves IO,
        // so we execute it in async task

        new AsyncTask<Void, Void, Exception>() {
            @Override
            protected Exception doInBackground(Void... params) {
                try {
                    Assets assets = new Assets(PocketSphinxActivity.this);

                    File assetDir = assets.syncAssets();

                    setupRecognizer(assetDir);

                    recognizer.startListening(KWS_SEARCH);

                } catch (IOException e) {
                    return e;
                }
                return null;
            }

            @Override
            protected void onPostExecute(Exception result) {
                if (result != null) {
                    ((TextView) findViewById(R.id.caption_text))
                            .setText("Failed to init recognizer " + result);
                } else {
                    switchSearch(KWS_SEARCH);
                }
            }
        }.execute();
    }

    @Override
    public void onPartialResult(Hypothesis hypothesis) {
        String text = hypothesis.getHypstr();
        Log.d("Spoken text",text);

        if (text.equals(KEYPHRASE))
            switchSearch(DICTATION_SEARCH);

        else
            ((TextView) findViewById(R.id.result_text)).setText(text);
    }

    @Override
    public void onResult(Hypothesis hypothesis) {
        ((TextView) findViewById(R.id.result_text)).setText("");
        if (hypothesis != null) {
            String text = hypothesis.getHypstr();
            makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onBeginningOfSpeech() {
    }

    @Override
    public void onEndOfSpeech() {
        Log.d("end","In end of speech");
        if (DICTATION_SEARCH.equals(recognizer.getSearchName()))
            switchSearch(KWS_SEARCH);
    }

    private void switchSearch(String searchName) {
        recognizer.stop();
        recognizer.startListening(searchName);
        String caption = getResources().getString(captions.get(searchName));
        ((TextView) findViewById(R.id.caption_text)).setText(caption);
    }

    private void setupRecognizer(File assetsDir) {
        File modelsDir = new File(assetsDir, "models");
        recognizer = defaultSetup()
                .setAcousticModel(new File(modelsDir, "hmm/en-us"))
                .setDictionary(new File(modelsDir, "dict/5497.dic"))
                .setRawLogDir(assetsDir).setKeywordThreshold(1e-20f)
                .setFloat("-beam", 1e-30f)
                .getRecognizer();
        recognizer.addListener(this);

        // Create keyword-activation search.
        recognizer.addKeyphraseSearch(KWS_SEARCH, KEYPHRASE);

        // Create language model search.
        File languageModel = new File(modelsDir, "lm/3015.lm");
        recognizer.addNgramSearch(DICTATION_SEARCH, languageModel);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...