Pocketsphinx初始化失败

时间:2016-05-11 12:38:42

标签: java c eclipse java-native-interface pocketsphinx

我想用Pocketsphinx编写VoiceRecognition并用Eclipse启动它。起初我构建了pocketsphinx和sphinxbase,我能够用cmd启动pocketsphinx_continuous.exe。

现在我对c-source有一些问题,启动麦克风和识别。

    JNIEXPORT void JNICALL Java_Test_Decoder_1defaultConfig(JNIEnv *env, jobject obj)
{
    config = cmd_ln_init(NULL, ps_args(), TRUE,                   // Load the configuration structure - ps_args() passes the default values
        "-hmm", MODELDIR "/en-us/en-us",  // path to the standard english language model
        "-lm", MODELDIR "/en-us/en-us.lm.bin",                                         // custom language model (file must be present)
        "-dict", MODELDIR "/en-us/cmudict_en_us.dict",                                    // custom dictionary (file must be present)
        NULL);

    if (config == NULL) {
        cmd_ln_free_r(config);
        E_INFO("configuration failed");
    }

    ps_default_search_args(config);
    ps = ps_init(config);                                                        // initialize the pocketsphinx decoder

    if (ps == NULL) {
        cmd_ln_free_r(config);
        E_INFO("decoder failed");
    }

    E_INFO("COMPILED ON %s, AT: %s\n",__DATE__,__TIME__);


    recognize_from_microphone();                 // call the function to capture and decode speech           


    ps_free(ps);
    cmd_ln_free_r(config);
    //ad_close(ad);                                                    // close the microphone
}

static void recognize_from_microphone() {

    ad_rec_t *ad;
    int16 adbuf[2048];
    uint8 utt_started, in_speech;
    int32 k;
    char const *hyp;

    //if (ad = ad_open_dev(NULL, (int)cmd_ln_float32_r(config, "-samprate")) == NULL) { // open default microphone at default samplerate
    //  E_FATAL("Failed to open audio device\n");
    //  }

    if ((ad = ad_open()) == NULL) {     // open default microphone at default samplerate
        E_FATAL("Failed to open audio device\n");
    }

    if (ad_start_rec(ad) < 0) {
        E_FATAL("Failed to start recording\n");
    }
    if (ps_start_utt(ps) < 0)
        E_FATAL("Failed to start utterance\n");


    utt_started = FALSE;
    E_INFO("Ready....\n");

如果我用Eclipse启动它,我会收到以下错误消息:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000022dfbfc, pid=7780, tid=0x0000000000003320
#
# JRE version: OpenJDK Runtime Environment (8.0_74-b02) (build 1.8.0_74-b02)
# Java VM: OpenJDK 64-Bit Server VM (25.74-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [pocketsphinx.dll+0x1fbfc]  ps_start_utt+0x1c
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\sde\workspaceAW_4.5\pocketsphinx\hs_err_pid7780.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

它说问题在ps_start_utt函数内部,但我没有更改Default / demo函数。函数中的错误还是之前有错误?

0 个答案:

没有答案