Menu

Help with cont_ad_calib

Help
Shane
2011-04-28
2012-09-22
  • Shane

    Shane - 2011-04-28

    Hello,

    I'm trying to write a little program that uses the pocketsphinx library to do
    some continuous speech recognition. However when I try to calibrate the
    initial silence threshold (cont_ad_calib(cont)) I get a negative number
    returned to me. What are the possible reasons for this?

    Thanks in advance

     
  • Nickolay V. Shmyrev

    Hello

    It might be noisy audio or byte endian issue. If noise is too much calibration
    can fail. To get more information enable cont_ad debugging by calling

    cont_ad_set_logfp(cont_ad_t * r, FILE * fp)
    

    with stdout argument to output debug info on stdout.

     
  • Shane

    Shane - 2011-04-29

    Ok, I called cont_ad_st_logfp but it doesn't seem to have printed anything to
    the screen. Here is the line I put in:

    int res = cont_ad_set_logfp(cont,stdout);
    

    Which returns 0 to signal success but doesn't seem to do anything.

     
  • Nickolay V. Shmyrev

    Well, then maybe your ad doesn't function at all, are you sure it's not NULL?

    It's actually very easy to find that out, you can just go step by step through
    a function with a debugger.

     
  • Shane

    Shane - 2011-05-02

    I'm pretty sure it isn't. Let me give you a quick snippet of the code. It's
    basically been taken from the HelloWorld tutorial and looking at continuous.c.
    Here it is:

    #define DEFAULT_DEVICE NULL
    
    //...
    
    ps_decoder_t *ps;
    cmd_ln_t *config;
    
    config = cmd_ln_init(NULL, ps_args(), TRUE,
                    "-hmm", "../pocketsphinx-0.7/model/hmm/en_US/hub4wsj_sc_8k",
                    "-lm", "../pocketsphinx-0.7/model/lm/en/turtle.DMP",
                    "-dict", "../pocketsphinx-0.7/model/lm/en/turtle.dic",
                    NULL);
    if(config == NULL)
    {
        printf("Config Initialization failed");
        system("Pause");
        return 1;
    }
    
    //PS Initializing
    ps = ps_init(config);
    if (ps == NULL)
        return 1;
    
    //Continuous listening
    ad_rec_t* ad;
    int16 adbuf[4096];
    int32 k, ts, rem;
    cont_ad_t *cont;
    char word[256];
    
    if((ad = ad_open_dev(DEFAULT_DEVICE, DEFAULT_SAMPLES_PER_SEC)) == NULL)
    {
        printf("Falied to open audio device\n");
        system("pause");
        return 1;
    }
    
    if((cont = cont_ad_init(ad, ad_read)) == NULL)
    {
        printf("Failed to initialize voice activity detection\n");
        system("pause");
        return 1;
    }
    
    int res = cont_ad_set_logfp(cont,stdout);
    
    if(cont_ad_calib(cont) < 0)
    {
        printf("Failed to calibrate voice activity detection\n");
        system("pause");
        return 1;
    }
    
     
  • Shane

    Shane - 2011-05-02

    And it gets past the initializing of ad and the initializing of cont but
    cont_ad_calib returns -1. Is there perhaps something wrong further up in the
    code? This is basically the whole program.

     
  • Nickolay V. Shmyrev

    Hello

    In this sample you miss ad_start_rec before cont_ad_calib:

      if (ad_start_rec(ad) < 0) {
            return 1;
        }
    

    See continuous.c in src/programs for details.

     
  • Nickolay V. Shmyrev

    I've also just committed a fix to show a message when recording is not
    started, this should be easier to debug now.

     
  • Shane

    Shane - 2011-05-03

    Thank you, that was the problem. I appreciate the help!

     

Log in to post a comment.