Hi, I want to use PocketSphinx to caption videos. Currently, I could generate
transcript with the following code based on PocketSphinx 0.7.
#include <pocketsphinx.h>#include <stdio.h>intmain(intargc,char*argv[]){ps_decoder_t*ps;cmd_ln_t*config;FILE*fh;charconst*hyp,*uttid;int16buf[512];intrv;int32score;charaudiofile[100];inti;sprintf(audiofile,"second.wav");/*config=cmd_ln_init(NULL,ps_args(),TRUE,"-hmm",MODELDIR"/hmm/en_US/hub4wsj_sc_8k","-lm","TAR3837/3837.lm","-dict","TAR3837/3837.dic",NULL);*/config=cmd_ln_init(NULL,ps_args(),TRUE,"-hmm","TAR3837/hub4_6000","-lm","TAR3837/bn99_64000_lm.dmp","-dict","TAR3837/cmudict.06d",NULL);//Thismodelcouldnotbeloaded/*config=cmd_ln_init(NULL,ps_args(),TRUE,"-hmm","/media/New Volume/Sphinx_Modes/en_broadcastnews_16k_ptm256_5000","-lm","TAR3837/bn99_64000_lm.arpa","-dict","TAR3837/cmudict.06d",NULL);*/if(config==NULL)return1;ps=ps_init(config);if(ps==NULL)return1;fh=fopen(audiofile,"rb");if(fh==NULL){perror("Failed to open audio file");return1;}rv=ps_decode_raw(ps,fh,NULL,-1);if(rv<0)return1;hyp=ps_get_hyp(ps,&score,&uttid);if(hyp==NULL)return1;printf("Recognized: %s\n",hyp);/*fseek(fh,0,SEEK_SET);rv=ps_start_utt(ps,NULL);if(rv<0)return1;while(!feof(fh)){size_tnsamp;nsamp=fread(buf,2,512,fh);rv=ps_process_raw(ps,buf,nsamp,FALSE,FALSE);}rv=ps_end_utt(ps);if(rv<0)return1;hyp=ps_get_hyp(ps,&score,&uttid);if(hyp==NULL)return1;printf("Recognized: %s\n",hyp);*/ps_free(ps);return0;}
However, I couldn't get the time information for each word. So, could anyone
tell me how can I get the time info? In addition, Could PocketSphinx split the
long text into sentence?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I want to use PocketSphinx to caption videos. Currently, I could generate
transcript with the following code based on PocketSphinx 0.7.
However, I couldn't get the time information for each word. So, could anyone
tell me how can I get the time info? In addition, Could PocketSphinx split the
long text into sentence?
Read pocketsphinx_continuous source in pocketsphinx/src/programs/continuous.c
for details.