Menu

How to get word timestamps with pocketsphinx?

Help
2015-06-30
2015-06-30
  • Benjamin Gorman

    Benjamin Gorman - 2015-06-30

    I'm trying a very basic example from the tutorial, and I wanted to be able to get the word times from the recognition. In the pocketsphinx_continuous it states I can say "-time yes" as a command line parameter. However, the default ps_args() doesn't have a definition. I tried adding the definition into my own arg array but that didn't work either.

    Is this possible? Here is where I would like to specify the -time argument. I'm aware I need to generate my own arg array like so:

    const arg_t options[] = {
            POCKETSPHINX_OPTIONS,
            CMDLN_EMPTY_OPTION,
            "time -yes"
        };
    ~~~~~~
    
    
    
    ~~~~~~
    config = cmd_ln_init(NULL, options, TRUE, "-hmm", MODELDIR "/en-us/en-us", "-lm", MODELDIR "/en-us/en-us.lm.dmp", "-dict", MODELDIR "/en-us/cmudict-en-us.dict", NULL);
    
     

    Last edit: Benjamin Gorman 2015-06-30
    • Nickolay V. Shmyrev

      Benjamin

      The option "-time" is used in command line tool pocketsphinx_continuous. If you want to print times in your own code you can use the following code chunk from pocketsphinx_continuous:

      static void
      print_word_times()
      {
          int frame_rate = cmd_ln_int32_r(config, "-frate");
          ps_seg_t *iter = ps_seg_iter(ps, NULL);
          while (iter != NULL) {
              int32 sf, ef, pprob;
              float conf;
      
              ps_seg_frames(iter, &sf, &ef);
              pprob = ps_seg_prob(iter, NULL, NULL, NULL);
              conf = logmath_exp(ps_get_logmath(ps), pprob);
              printf("%s %.3f %.3f %f\n", ps_seg_word(iter), ((float)sf / frame_rate),
                     ((float) ef / frame_rate), conf);
              iter = ps_seg_next(iter);
          }
      }
      
       
  • Benjamin Gorman

    Benjamin Gorman - 2015-06-30

    That worked perfectly. Many thanks!

     

Log in to post a comment.