2

I want to program a VoiceRecognition with Pocketsphinx and start it with Eclipse. At first I built pocketsphinx and sphinxbase and I was able to start pocketsphinx_continuous.exe with cmd.

Now I have some Problems with the c-source, to start the microphone and the recognition.

    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");

If i start it with Eclipse I get the following Error message:

#
# 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.
#

It says that the Problem is inside the ps_start_utt function, but I did not change the Default/demo function. Is the Mistake in the function or is there any mistake before?

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
PP600
  • 33
  • 5
  • 1
    Do you see any debug log from `E_INFO`? There is a chance that `ps_init` fails - but the program continues with a null ps which may be fatal in `ps_start_utt` – wero May 11 '16 at 14:42
  • I dont get any E_INFO because of ps == NULL... I test it with an if-condition – PP600 May 12 '16 at 07:46
  • okay I think you are right! I added E_INFO after the line ps = ps_init(config), and the program never reaches this. But i dont know where the mistake could be. And now i dont get any error anymore. – PP600 May 12 '16 at 08:58

0 Answers0