From sumomo @ users.sourceforge.jp Fri Nov 14 01:36:56 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 01:36:56 +0900 Subject: [Julius-cvs 336] CVS update: julius4/libsent/src/adin Message-ID: <1226594216.455549.5006.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/adin/adin_file.c diff -u julius4/libsent/src/adin/adin_file.c:1.3 julius4/libsent/src/adin/adin_file.c:1.4 --- julius4/libsent/src/adin/adin_file.c:1.3 Thu May 8 14:43:40 2008 +++ julius4/libsent/src/adin/adin_file.c Fri Nov 14 01:36:56 2008 @@ -56,7 +56,7 @@ * @author Akinobu LEE * @date Sun Feb 13 13:31:20 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -86,7 +86,7 @@ static unsigned int sfreq; ///< Sampling frequency in Hz, specified by adin_standby() static char speechfilename[MAXPATHLEN]; ///< Buffer to hold input file name - +static char *stdin_buf = NULL; /* read .wav data with endian conversion */ /* (all .wav datas are in little endian) */ @@ -106,7 +106,7 @@ myread(void *buf, size_t unitbyte, int unitnum, FILE *fp) { int tmp; - if ((tmp = myfread(buf, unitbyte, unitnum, fp)) < unitnum) { + if ((tmp = fread(buf, unitbyte, unitnum, fp)) < unitnum) { return(FALSE); } #ifdef WORDS_BIGENDIAN @@ -246,7 +246,7 @@ char dummy[4]; if (filename != NULL) { - if ((fp = fopen_readfile(filename)) == NULL) { + if ((fp = fopen(filename, "r")) == NULL) { jlog("Error: adin_file: failed to open %s\n",filename); return(FALSE); } @@ -257,12 +257,16 @@ jlog("Error: adin_file: _setmode() failed\n"); } #endif + if (stdin_buf == NULL) { + stdin_buf = (char *)mymalloc(BUFSIZ); + setvbuf(stdin, stdin_buf, _IOFBF, BUFSIZ); + } } /* check first 4 byte to detect Microsoft WAVE format */ - if (myfread(dummy, 1, 4, fp) < 4) { + if (fread(dummy, 1, 4, fp) < 4) { jlog("Error: adin_file: size less than 4 bytes?\n",filename); - fclose_readfile(fp); + fclose(fp); return(FALSE); } if (dummy[0] == 'R' && @@ -274,7 +278,7 @@ has_pre = FALSE; if (setup_wav(fp) == FALSE) { jlog("Error: adin_file: error in parsing wav header at %s\n",filename); - fclose_readfile(fp); + fclose(fp); return(FALSE); } } else { @@ -300,7 +304,7 @@ FILE *fp; fp = gfp; - if (fclose_readfile(fp) != 0) { + if (fclose(fp) != 0) { jlog("Error: adin_file: failed to close file\n"); return FALSE; } @@ -398,7 +402,15 @@ fp = gfp; if (wav_p) { - cnt = myfread(buf, sizeof(SP16), sampnum, fp); + cnt = fread(buf, sizeof(SP16), sampnum, fp); + if (cnt == 0) { + if (feof(fp)) return -1; /* EOF */ + if (ferror(fp)) { + jlog("Error: adin_file: an error occured while reading file\n"); + adin_file_close(); + return -2; /* error */ + } + } if (nowlen + cnt > maxlen) { cnt = maxlen - nowlen; } @@ -407,19 +419,27 @@ if (has_pre) { buf[0] = pre_data[0]; buf[1] = pre_data[1]; has_pre = FALSE; - cnt = myfread(&(buf[2]), sizeof(SP16), sampnum - 2, fp); - if (cnt > 0) cnt += 2; + cnt = fread(&(buf[2]), sizeof(SP16), sampnum - 2, fp); + if (cnt == 0) { + if (feof(fp)) return -1; /* EOF */ + if (ferror(fp)) { + jlog("Error: adin_file: an error occured file reading file\n"); + adin_file_close(); + return -2; /* error */ + } + } + cnt += 2; } else { - cnt = myfread(buf, sizeof(SP16), sampnum, fp); - } - } - if (cnt == 0) { /* error or EOF */ - if (myfeof(fp) == 1) { /* EOF */ - return -1; + cnt = fread(buf, sizeof(SP16), sampnum, fp); + if (cnt == 0) { + if (feof(fp)) return -1; /* EOF */ + if (ferror(fp)) { + jlog("Error: adin_file: an error occured file reading file\n"); + adin_file_close(); + return -2; /* error */ + } + } } - jlog("Error: adin_file: an error occured file reading file\n"); - adin_file_close(); - return -2; /* error */ } /* all .wav data are in little endian */ /* assume .raw data are in big endian */ @@ -469,6 +489,7 @@ adin_stdin_begin() { if (feof(stdin)) { /* already reached the end of input stream */ + jlog("Error: adin_stdin: stdin reached EOF\n"); return FALSE; /* terminate search here */ } else { /* open input stream */ @@ -476,7 +497,7 @@ jlog("Error: adin_stdin: failed to read speech data from stdin\n"); return FALSE; } - jlog("Stat: adin_stding: reading wavedata from stdin...\n"); + jlog("Stat: adin_stdin: reading wavedata from stdin...\n"); } return TRUE; } @@ -496,23 +517,38 @@ if (wav_p) { cnt = myfread(buf, sizeof(SP16), sampnum, stdin); + if (cnt == 0) { + if (feof(stdin)) return -1; /* EOF */ + if (ferror(stdin)) { + jlog("Error: adin_stdin: an error occured while reading stdin\n"); + return -2; /* error */ + } + } } else { if (has_pre) { buf[0] = pre_data[0]; buf[1] = pre_data[1]; has_pre = FALSE; cnt = fread(&(buf[2]), sizeof(SP16), sampnum - 2, stdin); - if (cnt > 0) cnt += 2; + if (cnt == 0) { + if (feof(stdin)) return -1; /* EOF */ + if (ferror(stdin)) { + jlog("Error: adin_stdin: an error occured while reading stdin\n"); + return -2; /* error */ + } + } + cnt += 2; } else { cnt = fread(buf, sizeof(SP16), sampnum, stdin); + if (cnt == 0) { + if (feof(stdin)) return -1; /* EOF */ + if (ferror(stdin)) { + jlog("Error: adin_stdin: an error occured while reading stdin\n"); + return -2; /* error */ + } + } } } - if (cnt == 0) { - if (ferror(stdin)) { /* error */ - jlog("Error: adin_file: an error occured file reading file\n"); - return -2; /* error */ - } - return -1; /* EOF */ - } + /* all .wav data are in little endian */ /* assume .raw data are in big endian */ #ifdef WORDS_BIGENDIAN From sumomo @ users.sourceforge.jp Fri Nov 14 01:55:52 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 01:55:52 +0900 Subject: [Julius-cvs 337] CVS update: julius4/libjulius/include/julius Message-ID: <1226595352.493906.22289.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/extern.h diff -u julius4/libjulius/include/julius/extern.h:1.7 julius4/libjulius/include/julius/extern.h:1.8 --- julius4/libjulius/include/julius/extern.h:1.7 Thu Sep 25 14:00:05 2008 +++ julius4/libjulius/include/julius/extern.h Fri Nov 14 01:55:52 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Mon Mar 7 23:19:14 2005 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -109,9 +109,9 @@ void malloc_wordtrellis(RecogProcess *r); void free_wordtrellis(StackDecode *dwrk); void scan_word(NODE *now, HTK_Param *param, RecogProcess *r); -void next_word(NODE *now, NODE *new, NEXTWORD *nword, HTK_Param *param, RecogProcess *r); -void start_word(NODE *new, NEXTWORD *nword, HTK_Param *param, RecogProcess *r); -void last_next_word(NODE *now, NODE *new, HTK_Param *param, RecogProcess *r); +void next_word(NODE *now, NODE *newParam, NEXTWORD *nword, HTK_Param *param, RecogProcess *r); +void start_word(NODE *newParam, NEXTWORD *nword, HTK_Param *param, RecogProcess *r); +void last_next_word(NODE *now, NODE *newParam, HTK_Param *param, RecogProcess *r); /* wav2mfcc.c */ boolean wav2mfcc(SP16 speech[], int speechlen, Recog *recog); From sumomo @ users.sourceforge.jp Fri Nov 14 01:55:52 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 01:55:52 +0900 Subject: [Julius-cvs 338] CVS update: julius4/libsent/include/sent Message-ID: <1226595352.667846.22297.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/htk_hmm.h diff -u julius4/libsent/include/sent/htk_hmm.h:1.5 julius4/libsent/include/sent/htk_hmm.h:1.6 --- julius4/libsent/include/sent/htk_hmm.h:1.5 Tue Sep 30 12:58:18 2008 +++ julius4/libsent/include/sent/htk_hmm.h Fri Nov 14 01:55:52 2008 @@ -16,7 +16,7 @@ * @author Akinobu LEE * @date Thu Feb 10 19:36:47 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -428,16 +428,16 @@ char *get_cov_str(short covtype); char *get_dur_str(short durtype); /* rdhmmdef_trans.c */ -void trans_add(HTK_HMM_INFO *hmm, HTK_HMM_Trans *new); +void trans_add(HTK_HMM_INFO *hmm, HTK_HMM_Trans *newParam); HTK_HMM_Trans *get_trans_data(FILE *, HTK_HMM_INFO *); void def_trans_macro(char *, FILE *, HTK_HMM_INFO *); /* rdhmmdef_state.c */ HTK_HMM_State *get_state_data(FILE *, HTK_HMM_INFO *); void def_state_macro(char *, FILE *, HTK_HMM_INFO *); HTK_HMM_State *state_lookup(HTK_HMM_INFO *hmm, char *keyname); -void state_add(HTK_HMM_INFO *hmm, HTK_HMM_State *new); +void state_add(HTK_HMM_INFO *hmm, HTK_HMM_State *newParam); /* rdhmmdef_mpdf.c */ -void mpdf_add(HTK_HMM_INFO *hmm, HTK_HMM_PDF *new); +void mpdf_add(HTK_HMM_INFO *hmm, HTK_HMM_PDF *newParam); HTK_HMM_PDF *mpdf_lookup(HTK_HMM_INFO *hmm, char *keyname); HTK_HMM_PDF *get_mpdf_data(FILE *fp, HTK_HMM_INFO *hmm, int mix_num, short stream_id); void def_mpdf_macro(char *name, FILE *fp, HTK_HMM_INFO *hmm); @@ -445,22 +445,22 @@ HTK_HMM_Dens *get_dens_data(FILE *, HTK_HMM_INFO *); void def_dens_macro(char *, FILE *, HTK_HMM_INFO *); HTK_HMM_Dens *dens_lookup(HTK_HMM_INFO *hmm, char *keyname); -void dens_add(HTK_HMM_INFO *hmm, HTK_HMM_Dens *new); +void dens_add(HTK_HMM_INFO *hmm, HTK_HMM_Dens *newParam); /* rdhmmdef_var.c */ HTK_HMM_Var *get_var_data(FILE *, HTK_HMM_INFO *); void def_var_macro(char *, FILE *, HTK_HMM_INFO *); -void var_add(HTK_HMM_INFO *hmm, HTK_HMM_Var *new); +void var_add(HTK_HMM_INFO *hmm, HTK_HMM_Var *newParam); /* rdhmmdef_streamweight.c */ HTK_HMM_StreamWeight *get_streamweight_data(FILE *fp, HTK_HMM_INFO *hmm); void def_streamweight_macro(char *, FILE *, HTK_HMM_INFO *); -void sw_add(HTK_HMM_INFO *hmm, HTK_HMM_StreamWeight *new); +void sw_add(HTK_HMM_INFO *hmm, HTK_HMM_StreamWeight *newParam); /* rdhmmdef_data.c */ void def_HMM(char *, FILE *, HTK_HMM_INFO *); HTK_HMM_Data *htk_hmmdata_new(HTK_HMM_INFO *); -void htk_hmmdata_add(HTK_HMM_INFO *hmm, HTK_HMM_Data *new); +void htk_hmmdata_add(HTK_HMM_INFO *hmm, HTK_HMM_Data *newParam); /* rdhmmdef_tiedmix.c */ void tmix_read(FILE *fp, HTK_HMM_PDF *mpdf, HTK_HMM_INFO *hmm); -void codebook_add(HTK_HMM_INFO *hmm, GCODEBOOK *new); +void codebook_add(HTK_HMM_INFO *hmm, GCODEBOOK *newParam); /* rdhmmdef_regtree.c */ void def_regtree_macro(char *name, FILE *fp, HTK_HMM_INFO *hmm); /* rdhmmdef_hmmlist.c */ From sumomo @ users.sourceforge.jp Fri Nov 14 02:20:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 02:20:05 +0900 Subject: [Julius-cvs 339] CVS update: julius4/gramtools/mkdfa/mkfa-1.44-flex Message-ID: <1226596805.948908.31962.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/mkdfa/mkfa-1.44-flex/triplet.c diff -u julius4/gramtools/mkdfa/mkfa-1.44-flex/triplet.c:1.2 julius4/gramtools/mkdfa/mkfa-1.44-flex/triplet.c:1.3 --- julius4/gramtools/mkdfa/mkfa-1.44-flex/triplet.c:1.2 Tue Dec 18 17:45:47 2007 +++ julius4/gramtools/mkdfa/mkfa-1.44-flex/triplet.c Fri Nov 14 02:20:05 2008 @@ -150,7 +150,7 @@ FAQ *newFAQ; if( fa != NULL ){ - if( (newFAQ = malloc( sizeof(newFAQ) )) == NULL ){ + if( (newFAQ = malloc( sizeof(FAQ) )) == NULL ){ errMes( "Can't malloc queue for breadth-first search of triplet list" ); } newFAQ->fa = fa; From sumomo @ users.sourceforge.jp Fri Nov 14 04:44:09 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 04:44:09 +0900 Subject: [Julius-cvs 340] CVS update: julius4/libjulius/include/julius Message-ID: <1226605449.318680.9099.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/recog.h diff -u julius4/libjulius/include/julius/recog.h:1.4 julius4/libjulius/include/julius/recog.h:1.5 --- julius4/libjulius/include/julius/recog.h:1.4 Thu Sep 25 14:00:05 2008 +++ julius4/libjulius/include/julius/recog.h Fri Nov 14 04:44:09 2008 @@ -70,7 +70,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -421,6 +421,9 @@ boolean input_side_segment; ///< TRUE if segmentation requested by ad_read + unsigned int total_captured_len; + unsigned int last_trigger_sample; + } ADIn; /** From sumomo @ users.sourceforge.jp Fri Nov 14 04:44:09 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 04:44:09 +0900 Subject: [Julius-cvs 341] CVS update: julius4/libjulius/src Message-ID: <1226605449.483030.9107.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/adin-cut.c diff -u julius4/libjulius/src/adin-cut.c:1.8 julius4/libjulius/src/adin-cut.c:1.9 --- julius4/libjulius/src/adin-cut.c:1.8 Thu Sep 25 14:00:06 2008 +++ julius4/libjulius/src/adin-cut.c Fri Nov 14 04:44:09 2008 @@ -95,7 +95,7 @@ * @author Akinobu LEE * @date Sat Feb 12 13:20:53 2005 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ /* @@ -194,6 +194,8 @@ adin->rehash = FALSE; + adin->total_captured_len = 0; + return TRUE; } @@ -417,6 +419,8 @@ plugin_exec_adin_captured(&(a->buffer[a->bp]), cnt); #endif callback_exec_adin(CALLBACK_ADIN_CAPTURED, recog, &(a->buffer[a->bp]), cnt); + /* record total number of captured samples */ + a->total_captured_len += cnt; } /*************************************************/ @@ -532,7 +536,7 @@ /*********************************************************/ i = 0; while (i + wstep <= imax) { - + if (a->adin_cut_on) { /********************/ @@ -552,12 +556,13 @@ /*****************************************************/ /* process off, trigger on: detect speech triggering */ /*****************************************************/ - a->is_valid_data = TRUE; /* start processing */ a->nc = 0; #ifdef THREAD_DEBUG jlog("DEBUG: detect on\n"); #endif + /* record time */ + a->last_trigger_sample = a->total_captured_len - a->current_len + i + wstep - a->zc.valid_len; callback_exec(CALLBACK_EVENT_SPEECH_START, recog); /****************************************/ From sumomo @ users.sourceforge.jp Fri Nov 14 04:46:55 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 04:46:55 +0900 Subject: [Julius-cvs 342] CVS update: julius4/adintool Message-ID: <1226605615.418725.11598.nullmailer@users.sourceforge.jp> Index: julius4/adintool/adintool.c diff -u julius4/adintool/adintool.c:1.4 julius4/adintool/adintool.c:1.5 --- julius4/adintool/adintool.c:1.4 Thu Sep 25 14:00:04 2008 +++ julius4/adintool/adintool.c Fri Nov 14 04:46:55 2008 @@ -35,7 +35,7 @@ * @author Akinobu LEE * @date Wed Mar 23 20:43:32 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -81,6 +81,7 @@ static boolean pause_each = FALSE; ///< If set to TRUE, adintool will pause automatically at each input end and wait for resume command static boolean loose_sync = FALSE; ///< If set to TRUE, adintool will do loose synchronization for resume among servers static int rewind_msec = 0; +static int trigger_sample; /** * ヘルプを表示して終了する @@ -157,6 +158,7 @@ break; case 'f': jconf->input.speech_input = SP_RAWFILE; + jconf->detect.silence_cut = 1; break; case 's': jconf->input.speech_input = SP_STDIN; @@ -283,7 +285,7 @@ static boolean opt_nosegment(Jconf *jconf, char *arg[], int argnum) { - jconf->detect.silence_cut = FALSE; + jconf->detect.silence_cut = 0; return TRUE; } static boolean @@ -923,7 +925,11 @@ return FALSE; } } - printf("%s: %d samples (%.2f sec.)\n", outpath, speechlen, (float)speechlen / (float)sfreq); + printf("%s: %d samples (%.2f sec.) [%6d (%5.2fs) - %6d (%5.2fs)]\n", + outpath, speechlen, + (float)speechlen / (float)sfreq, + trigger_sample, (float)trigger_sample / (float)sfreq, + trigger_sample + speechlen, (float)(trigger_sample + speechlen) / (float)sfreq); writing_file = FALSE; } @@ -944,6 +950,11 @@ exit(1); } +static void +record_trigger_time(Recog *recog, void *data) +{ + trigger_sample = recog->adin->last_trigger_sample; +} /** * @@ -1118,6 +1129,11 @@ #endif } + /*********************/ + /* add some callback */ + /*********************/ + callback_add(recog, CALLBACK_EVENT_SPEECH_START, record_trigger_time, NULL); + /**************************************/ /* display input/output configuration */ @@ -1159,7 +1175,7 @@ fprintf(stderr, "failed to begin input stream\n"); } /* exit recording */ - break; + goto record_end; } /*********************************/ @@ -1224,7 +1240,10 @@ adin_send_end_of_segment(); } /* output info */ - printf("sent: %d samples (%.2f sec.)\n", speechlen, (float)speechlen / (float)sfreq); + printf("sent: %d samples (%.2f sec.) [%6d (%5.2fs) - %6d (%5.2fs)]\n", + speechlen, (float)speechlen / (float)sfreq, + trigger_sample, (float)trigger_sample / (float)sfreq, + trigger_sample + speechlen, (float)(trigger_sample + speechlen) / (float)sfreq); } } @@ -1273,6 +1292,8 @@ } /* to the next input stream (i.e. next input file in SP_RAWFILE) */ + record_end: + if (speech_output == SPOUT_FILE) { if (continuous_segment) { printf("recorded total %d samples (%.2f sec.) segmented to %s.%04d - %s.%04d files\n", total_speechlen, (float)total_speechlen / (float)sfreq, filename, 0, filename, sid-1); From sumomo @ users.sourceforge.jp Fri Nov 14 13:12:12 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 13:12:12 +0900 Subject: [Julius-cvs 343] CVS update: julius4/julius Message-ID: <1226635932.038476.24536.nullmailer@users.sourceforge.jp> Index: julius4/julius/module.c diff -u julius4/julius/module.c:1.8 julius4/julius/module.c:1.9 --- julius4/julius/module.c:1.8 Fri Oct 17 08:43:25 2008 +++ julius4/julius/module.c Fri Nov 14 13:12:11 2008 @@ -324,6 +324,7 @@ q = p; while(*q != '\0' && *q != '\r' && *q != '\n') { if (*q < '0' || *q > '9') break; + q++; } if (*q == '\0' || *q == '\r' || *q == '\n') { /* numeric */ gid = atoi(p); @@ -358,6 +359,7 @@ q = p; while(*q != '\0' && *q != '\r' && *q != '\n') { if (*q < '0' || *q > '9') break; + q++; } if (*q == '\0' || *q == '\r' || *q == '\n') { /* numeric */ gid = atoi(p); @@ -394,6 +396,7 @@ q = p; while(*q != '\0' && *q != '\r' && *q != '\n') { if (*q < '0' || *q > '9') break; + q++; } if (*q == '\0' || *q == '\r' || *q == '\n') { /* numeric */ gid = atoi(p); From sumomo @ users.sourceforge.jp Fri Nov 14 13:12:12 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 13:12:12 +0900 Subject: [Julius-cvs 344] CVS update: julius4/libjulius/include/julius Message-ID: <1226635932.177734.24544.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/extern.h diff -u julius4/libjulius/include/julius/extern.h:1.8 julius4/libjulius/include/julius/extern.h:1.9 --- julius4/libjulius/include/julius/extern.h:1.8 Fri Nov 14 01:55:52 2008 +++ julius4/libjulius/include/julius/extern.h Fri Nov 14 13:12:12 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Mon Mar 7 23:19:14 2005 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ /* @@ -243,6 +243,7 @@ int multigram_deactivate(int gid, PROCESS_LM *lm); boolean multigram_load_all_gramlist(PROCESS_LM *lm); int multigram_get_gram_from_category(int category, PROCESS_LM *lm); +int multigram_get_gram_from_wid(WORD_ID wid, PROCESS_LM *lm); int multigram_get_all_num(PROCESS_LM *lm); void multigram_free_all(MULTIGRAM *root); From sumomo @ users.sourceforge.jp Fri Nov 14 13:12:12 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 14 Nov 2008 13:12:12 +0900 Subject: [Julius-cvs 345] CVS update: julius4/libjulius/src Message-ID: <1226635932.341262.24553.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/beam.c diff -u julius4/libjulius/src/beam.c:1.9 julius4/libjulius/src/beam.c:1.10 --- julius4/libjulius/src/beam.c:1.9 Fri Oct 17 08:43:25 2008 +++ julius4/libjulius/src/beam.c Fri Nov 14 13:12:12 2008 @@ -42,7 +42,7 @@ * @author Akinobu LEE * @date Tue Feb 22 17:00:45 2005 * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * */ /* @@ -657,7 +657,11 @@ s->score = tmp->backscore; s->score_lm = 0.0; s->score_am = tmp->backscore; - s->gram_id = 0; + if (multigram_get_all_num(r->lm) > 0) { + s->gram_id = multigram_get_gram_from_wid(s->word[0], r->lm); + } else { + s->gram_id = 0; + } s->align.filled = FALSE; } /* free work area for sort */ @@ -677,7 +681,11 @@ s->score = best->backscore; s->score_lm = 0.0; s->score_am = best->backscore; - s->gram_id = 0; + if (multigram_get_all_num(r->lm) > 0) { + s->gram_id = multigram_get_gram_from_wid(s->word[0], r->lm); + } else { + s->gram_id = 0; + } s->align.filled = FALSE; } Index: julius4/libjulius/src/multi-gram.c diff -u julius4/libjulius/src/multi-gram.c:1.7 julius4/libjulius/src/multi-gram.c:1.8 --- julius4/libjulius/src/multi-gram.c:1.7 Fri Oct 17 23:49:20 2008 +++ julius4/libjulius/src/multi-gram.c Fri Nov 14 13:12:12 2008 @@ -47,7 +47,7 @@ * @author Akinobu Lee * @date Sat Jun 18 23:45:18 2005 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -970,6 +970,44 @@ return(-1); } +/** + * + * 単語IDから属する文法を得る. + * + * @param wid 単語ID + * @param lm [i/o] 言語処理インスタンス + * + * @return 単語の属する文法のIDを返す. + * + * + * Get which grammar the given word belongs to. + * + * @param wid word ID + * @param lm [i/o] LM processing instance + * + * @return the id of the belonging grammar. + * + * @callgraph + * @callergraph + * @ingroup grammar + */ +int +multigram_get_gram_from_wid(WORD_ID wid, PROCESS_LM *lm) +{ + MULTIGRAM *m; + int wb, we; + + for(m = lm->grammars; m; m = m->next) { + if (m->newbie) continue; + wb = m->word_begin; + we = wb + m->winfo->num; + if (wb <= wid && wid < we) { /* found */ + return(m->id); + } + } + return(-1); +} + /** * From sumomo @ users.sourceforge.jp Sun Nov 16 21:28:04 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Sun, 16 Nov 2008 21:28:04 +0900 Subject: [Julius-cvs 346] CVS update: julius4/libjulius/include/julius Message-ID: <1226838484.191206.12856.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/extern.h diff -u julius4/libjulius/include/julius/extern.h:1.9 julius4/libjulius/include/julius/extern.h:1.10 --- julius4/libjulius/include/julius/extern.h:1.9 Fri Nov 14 13:12:12 2008 +++ julius4/libjulius/include/julius/extern.h Sun Nov 16 21:28:03 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Mon Mar 7 23:19:14 2005 * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * */ /* @@ -99,6 +99,7 @@ /* search_bestfirst_main.c */ void segment_set_last_nword(NODE *hypo, RecogProcess *r); +void pass2_finalize_on_no_result(RecogProcess *r, boolean use_1pass_as_final); void wchmm_fbs(HTK_Param *param, RecogProcess *r, int cate_bgn, int cate_num); /* search_bestfirst_v?.c */ @@ -152,6 +153,7 @@ void word_rev_align(WORD_ID *revwords, short wnum, HTK_Param *param, Sentence *s, RecogProcess *r); void phoneme_rev_align(WORD_ID *revwords, short wnum, HTK_Param *param, Sentence *s, RecogProcess *r); void state_rev_align(WORD_ID *revwords, short wnum, HTK_Param *param, Sentence *s, RecogProcess *r); +void do_alignment_all(RecogProcess *r, HTK_Param *param); /* m_usage.c */ void opt_terminate(); From sumomo @ users.sourceforge.jp Sun Nov 16 21:28:04 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Sun, 16 Nov 2008 21:28:04 +0900 Subject: [Julius-cvs 347] CVS update: julius4/libjulius/src Message-ID: <1226838484.481911.12870.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/recogmain.c diff -u julius4/libjulius/src/recogmain.c:1.7 julius4/libjulius/src/recogmain.c:1.8 --- julius4/libjulius/src/recogmain.c:1.7 Thu Sep 25 14:00:06 2008 +++ julius4/libjulius/src/recogmain.c Sun Nov 16 21:28:04 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Wed Aug 8 14:53:53 2007 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ @@ -576,6 +576,7 @@ boolean ok_p; boolean process_segment_last; boolean on_the_fly; + boolean pass2_p; jconf = recog->jconf; @@ -1050,9 +1051,38 @@ } } + /* for instances with "-1pass", copy 1st pass result as final */ + /* execute stack-decoding search */ + /* they will be skipepd in the next pass */ + for(r=recog->process_list;r;r=r->next) { + if (!r->live) continue; + /* skip if 1st pass was failed */ + if (r->result.status < 0) continue; + if (r->config->compute_only_1pass) { + if (verbose_flag) { + jlog("%02d %s: \"-1pass\" specified, output 1st pass result as a final result\n", r->config->id, r->config->name); + } + /* prepare result storage */ + result_sentence_malloc(r, 1); + /* finalize result when no hypothesis was obtained */ + pass2_finalize_on_no_result(r, TRUE); + } + } + /***********************************************/ /* 2nd-pass --- forward search with heuristics */ /***********************************************/ + pass2_p = FALSE; + for(r=recog->process_list;r;r=r->next) { + if (!r->live) continue; + /* if [-1pass] is specified, skip 2nd pass */ + if (r->config->compute_only_1pass) continue; + /* if search already failed on 1st pass, skip 2nd pass */ + if (r->result.status < 0) continue; + pass2_p = TRUE; + } + if (pass2_p) callback_exec(CALLBACK_EVENT_PASS2_BEGIN, recog); + #if !defined(PASS2_STRICT_IWCD) || defined(FIX_35_PASS2_STRICT_SCORE) /* adjust trellis score not to contain outprob of the last frames */ for(r=recog->process_list;r;r=r->next) { @@ -1073,11 +1103,9 @@ #endif /* execute stack-decoding search */ - callback_exec(CALLBACK_EVENT_PASS2_BEGIN, recog); - for(r=recog->process_list;r;r=r->next) { if (!r->live) continue; - /* if [-1pass] is specified, skip 2nd pass */ + /* if [-1pass] is specified, just copy from 1st pass result */ if (r->config->compute_only_1pass) continue; /* if search already failed on 1st pass, skip 2nd pass */ if (r->result.status < 0) continue; @@ -1113,6 +1141,15 @@ } } + /* do forced alignment if needed */ + for(r=recog->process_list;r;r=r->next) { + if (!r->live) continue; + /* if search failed on 2nd pass, skip this */ + if (r->result.status < 0) continue; + /* do needed alignment */ + do_alignment_all(r, r->am->mfcc->param); + } + /* output result */ callback_exec(CALLBACK_RESULT, recog); #ifdef ENABLE_PLUGIN @@ -1123,6 +1160,8 @@ ok_p = FALSE; for(r=recog->process_list;r;r=r->next) { if (!r->live) continue; + if (r->config->compute_only_1pass) continue; + if (r->result.status < 0) continue; if (r->config->graph.lattice) ok_p = TRUE; } if (ok_p) callback_exec(CALLBACK_RESULT_GRAPH, recog); @@ -1131,6 +1170,8 @@ ok_p = FALSE; for(r=recog->process_list;r;r=r->next) { if (!r->live) continue; + if (r->config->compute_only_1pass) continue; + if (r->result.status < 0) continue; if (r->config->graph.confnet) ok_p = TRUE; } if (ok_p) callback_exec(CALLBACK_RESULT_CONFNET, recog); @@ -1142,7 +1183,7 @@ } /* output end of 2nd pass */ - callback_exec(CALLBACK_EVENT_PASS2_END, recog); + if (pass2_p) callback_exec(CALLBACK_EVENT_PASS2_END, recog); #ifdef DEBUG_VTLN_ALPHA_TEST if (r->am->mfcc->para->vtln_alpha == 1.0) { Index: julius4/libjulius/src/search_bestfirst_main.c diff -u julius4/libjulius/src/search_bestfirst_main.c:1.7 julius4/libjulius/src/search_bestfirst_main.c:1.8 --- julius4/libjulius/src/search_bestfirst_main.c:1.7 Thu Aug 7 18:27:35 2008 +++ julius4/libjulius/src/search_bestfirst_main.c Sun Nov 16 21:28:04 2008 @@ -35,7 +35,7 @@ * @author Akinobu Lee * @date Thu Sep 08 11:51:12 2005 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -1099,19 +1099,96 @@ /* if in sp segmentation mode, */ /* set the last context-aware word for next recognition */ if (r->lmtype == LM_PROB && r->config->successive.enabled && num == 1) segment_set_last_nword(now, r); - /* do forced alignment if needed */ - if (r->config->annotate.align_result_word_flag) word_rev_align(now->seq, now->seqnum, param, &(r->result.sent[r->result.sentnum-1]), r); - if (r->config->annotate.align_result_phoneme_flag) phoneme_rev_align(now->seq, now->seqnum, param, &(r->result.sent[r->result.sentnum-1]), r); - if (r->config->annotate.align_result_state_flag) state_rev_align(now->seq, now->seqnum, param, &(r->result.sent[r->result.sentnum-1]), r); free_node(now); } - r->result.status = J_RESULT_STATUS_SUCCESS; /* free the rest */ if (now != NULL) free_node(now); free_all_nodes(*r_start); } +/** + * + * @brief Post-process of 2nd pass when no result is obtained. + * + * This is a post-process for the 2nd pass which should be called when + * the 2nd pass has no result. This will occur when the 2nd pass was + * executed but failed with no sentence candidate, or skipped by + * an option. + * + * When the 2nd argument is set to TRUE, the result of the 1st pass + * will be copied as final result of 2nd pass and the recognition + * status flag is set to SUCCESS. If FALSE, recognition status will + * be set to FAILED. On sp-segment decoding, the initial hypothesis + * marker for the next input segment will be set up from the 1st pass + * result also. + * + * @param r [in] recognition process instance + * @param use_1pass_as_final [in] when TRUE the 1st pass result will be used as final recognition result of 2nd pass. + * + * + * + * @brief 第2パスの解が得られない場合の終了処理 + * + * 第2パスが失敗した場合や第2パスが実行されない設定の場合の + * 認識終了処理を行う.use_1pass_as_final が TRUE のとき, + * 第1パスの結果を第2パスの結果としてコピーして格納し,認識成功とする. + * FALSE時は認識失敗とする. + * また,sp-segment 時は,次の認識区間用の初期仮説設定も第1パスの + * 結果から行う. + * + * @param r [in] 認識処理インスタンス + * @param use_1pass_as_final [in] TRUE 時第1パスの結果を第2パス結果に格納する + * + * + */ +void +pass2_finalize_on_no_result(RecogProcess *r, boolean use_1pass_as_final) +{ + NODE *now; + int i, j; + + /* 探索失敗 */ + /* search failed */ + + /* make temporal hypothesis data from the result of previous 1st pass */ + now = newnode(r); + for (i=0;ipass1_wnum;i++) { + now->seq[i] = r->pass1_wseq[r->pass1_wnum-1-i]; + } + now->seqnum = r->pass1_wnum; + now->score = r->pass1_score; +#ifdef CONFIDENCE_MEASURE + /* fill in null values */ +#ifdef CM_MULTIPLE_ALPHA + for(j=0;jannotate.cm_alpha_num;j++) { + for(i=0;iseqnum;i++) now->cmscore[i][j] = 0.0; + } +#else + for(i=0;iseqnum;i++) now->cmscore[i] = 0.0; +#endif +#endif /* CONFIDENCE_MEASURE */ + + if (r->lmtype == LM_PROB && r->config->successive.enabled) { + /* if in sp segment mode, */ + /* find segment restart words from 1st pass result */ + segment_set_last_nword(now, r); + } + + if (use_1pass_as_final) { + /* 第1パスの結果をそのまま出力する */ + /* output the result of the previous 1st pass as a final result. */ + store_result_pass2(now, r); + r->result.status = J_RESULT_STATUS_SUCCESS; + } else { + /* store output as failure */ + r->result.status = J_RESULT_STATUS_FAIL; + //callback_exec(CALLBACK_RESULT, r); + } + + free_node(now); +} + /**********************************************************************/ /********* Main stack decoding function *******************************/ @@ -2052,58 +2129,16 @@ /* output */ if (dwrk->finishnum == 0) { /* if search failed */ - /* 探索失敗 */ - /* search failed */ - /* make temporal hypothesis data from the result of previous 1st pass */ - now = newnode(r); - for (i=0;ipass1_wnum;i++) { - now->seq[i] = r->pass1_wseq[r->pass1_wnum-1-i]; - } - now->seqnum = r->pass1_wnum; - now->score = r->pass1_score; -#ifdef CONFIDENCE_MEASURE - /* fill in null values */ -#ifdef CM_MULTIPLE_ALPHA - for(j=0;jannotate.cm_alpha_num;j++) { - for(i=0;iseqnum;i++) now->cmscore[i][j] = 0.0; - } -#else - for(i=0;iseqnum;i++) now->cmscore[i] = 0.0; -#endif -#endif /* CONFIDENCE_MEASURE */ - - if (r->lmtype == LM_PROB && r->config->successive.enabled) { - /* if in sp segment mode, */ - /* find segment restart words from 1st pass result */ - segment_set_last_nword(now, r); - } - - if (r->config->sw.fallback_pass1_flag) { - /* 第1パスの結果をそのまま出力する */ - /* output the result of the previous 1st pass as a final result. */ - if (verbose_flag) { - jlog("%02d %s: got no candidates, output 1st pass result as a final result\n", r->config->id, r->config->name); - } - /* do forced alignment if needed */ - if (jconf->annotate.align_result_word_flag) word_rev_align(now->seq, now->seqnum, param, &(r->result.pass1), r); - if (jconf->annotate.align_result_phoneme_flag) phoneme_rev_align(now->seq, now->seqnum, param, &(r->result.pass1), r); - if (jconf->annotate.align_result_state_flag) state_rev_align(now->seq, now->seqnum, param, &(r->result.pass1), r); - - /* store output as final result */ - store_result_pass2(now, r); - - } else { - /* store output as failure */ - if (verbose_flag) { + /* finalize result when no hypothesis was obtained */ + if (verbose_flag) { + if (r->config->sw.fallback_pass1_flag) { + jlog("%02d %s: got no candidates, output 1st pass result as a final result\n", r->config->id, r->config->name); + } else { jlog("WARNING: %02d %s: got no candidates, search failed\n", r->config->id, r->config->name); } - - r->result.status = J_RESULT_STATUS_FAIL; - //callback_exec(CALLBACK_RESULT, r); } - - free_node(now); + pass2_finalize_on_no_result(r, r->config->sw.fallback_pass1_flag); } else { /* if at least 1 candidate found */ @@ -2116,6 +2151,8 @@ and output them here */ if (debug2_flag) jlog("DEBUG: done\n"); result_reorder_and_output(&r_start, &r_bottom, &r_stacknum, jconf->output.output_hypo_maxnum, r, param); + + r->result.status = J_RESULT_STATUS_SUCCESS; //callback_exec(CALLBACK_RESULT, r); //callback_exec(CALLBACK_EVENT_PASS2_END, r); } Index: julius4/libjulius/src/word_align.c diff -u julius4/libjulius/src/word_align.c:1.3 julius4/libjulius/src/word_align.c:1.4 --- julius4/libjulius/src/word_align.c:1.3 Fri Feb 15 03:25:14 2008 +++ julius4/libjulius/src/word_align.c Sun Nov 16 21:28:04 2008 @@ -33,7 +33,7 @@ * @author Akinobu Lee * @date Sat Sep 24 16:09:46 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -529,4 +529,38 @@ free(words); } +/** + * + * 認識結果に対して必要なアラインメントを全て実行する. + * + * @param r [i/o] 認識処理インスタンス + * @param param [in] 入力特徴ベクトル列 + * + * + * Do required forced alignment for the recognition results + * + * @param r [i/o] recognition process instance + * @param param [in] input parameter vectors + * + * @callgraph + * @callergraph + */ +void +do_alignment_all(RecogProcess *r, HTK_Param *param) +{ + int n; + Sentence *s; + + for(n = 0; n < r->result.sentnum; n++) { + s = &(r->result.sent[n]); + /* do forced alignment if needed */ + if (r->config->annotate.align_result_word_flag) + word_align(s->word, s->word_num, param, s, r); + if (r->config->annotate.align_result_phoneme_flag) + phoneme_align(s->word, s->word_num, param, s, r); + if (r->config->annotate.align_result_state_flag) + state_align(s->word, s->word_num, param, s, r); + } +} + /* end of file */ From sumomo @ users.sourceforge.jp Tue Nov 18 17:46:59 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 18 Nov 2008 17:46:59 +0900 Subject: [Julius-cvs 348] CVS update: julius4/libjulius/src Message-ID: <1226998019.282369.18843.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/recogmain.c diff -u julius4/libjulius/src/recogmain.c:1.8 julius4/libjulius/src/recogmain.c:1.9 --- julius4/libjulius/src/recogmain.c:1.8 Sun Nov 16 21:28:04 2008 +++ julius4/libjulius/src/recogmain.c Tue Nov 18 17:46:59 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Wed Aug 8 14:53:53 2007 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ @@ -1058,6 +1058,8 @@ if (!r->live) continue; /* skip if 1st pass was failed */ if (r->result.status < 0) continue; + /* already stored on word recognition, so skip this */ + if (r->lmvar == LM_DFA_WORD) continue; if (r->config->compute_only_1pass) { if (verbose_flag) { jlog("%02d %s: \"-1pass\" specified, output 1st pass result as a final result\n", r->config->id, r->config->name);