From sumomo @ users.sourceforge.jp Fri Jun 6 11:56:11 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 06 Jun 2008 11:56:11 +0900 Subject: [Julius-cvs 179] CVS update: julius4/libsent/src/wav2mfcc Message-ID: <1212720971.004647.8198.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c diff -u julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c:1.2 julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c:1.3 --- julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c Fri Jun 6 11:56:10 2008 @@ -24,7 +24,7 @@ * @author Akinobu LEE * @date Thu Feb 17 17:43:35 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ @@ -94,7 +94,7 @@ if (para->acc) Accel(mfcc, frame_num, para); /* Cepstrum Mean Normalization */ - if(para->cmn) CMN(mfcc, frame_num, para->mfcc_dim); + if(para->cmn) CMN(mfcc, frame_num, para->mfcc_dim + (para->c0 ? 1 : 0)); return(frame_num); } From sumomo @ users.sourceforge.jp Fri Jun 6 12:20:15 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 06 Jun 2008 12:20:15 +0900 Subject: [Julius-cvs 180] CVS update: julius4/libsent/src/wav2mfcc Message-ID: <1212722415.098001.25328.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/wav2mfcc/para.c diff -u julius4/libsent/src/wav2mfcc/para.c:1.4 julius4/libsent/src/wav2mfcc/para.c:1.5 --- julius4/libsent/src/wav2mfcc/para.c:1.4 Fri May 9 14:57:47 2008 +++ julius4/libsent/src/wav2mfcc/para.c Fri Jun 6 12:20:14 2008 @@ -16,7 +16,7 @@ * @author Akinobu Lee * @date Fri Oct 27 14:55:00 2006 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -345,7 +345,12 @@ if (para->acc) fprintf(fp, "_A"); if (para->absesup) fprintf(fp, "_N"); if (para->cmn) fprintf(fp, "_Z"); - fprintf(fp, " (%d dimension from %d cepstrum)\n", para->veclen, para->mfcc_dim); + fprintf(fp, " (%d dim. from %d cepstrum", para->veclen, para->mfcc_dim); + if (para->c0) fprintf(fp, " + c0"); + if (para->energy) fprintf(fp, " + energy"); + if (para->absesup) fprintf(fp, ", abs energy supressed"); + if (para->cmn) fprintf(fp, " with CMN"); + fprintf(fp, ")\n"); fprintf(fp, "\tsample frequency = %5ld Hz\n", para->smp_freq); fprintf(fp, "\t sample period = %4ld (1 = 100ns)\n", para->smp_period); fprintf(fp, "\t window size = %4d samples (%.1f ms)\n", para->framesize, From sumomo @ users.sourceforge.jp Tue Jun 17 10:20:50 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 17 Jun 2008 10:20:50 +0900 Subject: [Julius-cvs 181] CVS update: julius4 Message-ID: <1213665650.454711.11584.nullmailer@users.sourceforge.jp> Index: julius4/Sample.jconf diff -u julius4/Sample.jconf:1.3 julius4/Sample.jconf:1.4 --- julius4/Sample.jconf:1.3 Tue May 27 18:16:39 2008 +++ julius4/Sample.jconf Tue Jun 17 10:20:50 2008 @@ -260,12 +260,16 @@ #-zmeanframe # frame-wise DC offset removal (same as HTK) #-nozmeanframe # disable "-zmeanframe" (this is default) -## Cepstral mean normalization -#-cmnload filename # load initial cepstral mean vector on startup -#-cmnsave filename # save cepstral mean vector at each input -#-cmnupdate # update initial cepstral mean at each input +## Cepstral mean / variance normalization +#-cmnload filename # load initial cep. mean / variance on startup +#-cmnsave filename # save cep. mean / variance at each input end +#-cmnupdate # update beginning cep. data at each input #-cmnnoupdate # keep initial mean, disable "-cmnupdate" #-cmnmapweight 100.0 # weight for MAP-CMN +#-cvn # enable variance normalization + +## Vocal tract length normalization (VTLN) +#-vtln 1.0 300 4800 # enable VTLN (alpha, lowerfreq, upperfreq) ## Spectral subtraction (default: disabled) #-sscalc # do SS, estimate noise from head sil From sumomo @ users.sourceforge.jp Tue Jun 17 10:20:50 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 17 Jun 2008 10:20:50 +0900 Subject: [Julius-cvs 182] CVS update: julius4/libjulius/include/julius Message-ID: <1213665650.675327.11600.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/define.h diff -u julius4/libjulius/include/julius/define.h:1.2 julius4/libjulius/include/julius/define.h:1.3 --- julius4/libjulius/include/julius/define.h:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/include/julius/define.h Tue Jun 17 10:20:50 2008 @@ -27,7 +27,7 @@ * @author Akinobu LEE * @date Mon Mar 7 15:17:26 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -268,5 +268,13 @@ #define POWER_REJECT_DEFAULT_THRES 9.0 +/** + * A test to find optimal warping factor for VTLN (EXPERIMENTAL) + * + */ +#undef DEBUG_VTLN_ALPHA_TEST +#define VTLN_RANGE 0.2 +#define VTLN_STEP 0.02 + #endif /* __J_DEFINE_H__ */ Index: julius4/libjulius/include/julius/extern.h diff -u julius4/libjulius/include/julius/extern.h:1.5 julius4/libjulius/include/julius/extern.h:1.6 --- julius4/libjulius/include/julius/extern.h:1.5 Thu May 8 14:45:02 2008 +++ julius4/libjulius/include/julius/extern.h Tue Jun 17 10:20:50 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Mon Mar 7 23:19:14 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -286,6 +286,7 @@ boolean callback_delete(Recog *recog, int id); /* recogmain.c */ +int adin_cut_callback_store_buffer(SP16 *now, int len, Recog *recog); void result_sentence_malloc(RecogProcess *r, int num); void result_sentence_free(RecogProcess *r); void clear_result(RecogProcess *r); Index: julius4/libjulius/include/julius/jfunc.h diff -u julius4/libjulius/include/julius/jfunc.h:1.2 julius4/libjulius/include/julius/jfunc.h:1.3 --- julius4/libjulius/include/julius/jfunc.h:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/include/julius/jfunc.h Tue Jun 17 10:20:50 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Tue Nov 6 22:41:00 2007 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -77,6 +77,10 @@ boolean j_remove_lm(Recog *recog, JCONF_LM *lmconf); boolean j_remove_am(Recog *recog, JCONF_AM *amconf); +#ifdef DEBUG_VTLN_ALPHA_TEST +void vtln_alpha(Recog *recog, RecogProcess *r); +#endif + /* instance.c */ MFCCCalc *j_mfcccalc_new(JCONF_AM *amconf); void j_mfcccalc_free(MFCCCalc *mfcc); From sumomo @ users.sourceforge.jp Tue Jun 17 10:20:50 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 17 Jun 2008 10:20:50 +0900 Subject: [Julius-cvs 183] CVS update: julius4/libjulius/src Message-ID: <1213665650.965805.11619.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/jfunc.c diff -u julius4/libjulius/src/jfunc.c:1.2 julius4/libjulius/src/jfunc.c:1.3 --- julius4/libjulius/src/jfunc.c:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/src/jfunc.c Tue Jun 17 10:20:50 2008 @@ -19,7 +19,7 @@ * @author Akinobu Lee * @date Wed Aug 8 15:04:28 2007 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -1497,4 +1497,57 @@ return TRUE; } +#ifdef DEBUG_VTLN_ALPHA_TEST +void +vtln_alpha(Recog *recog, RecogProcess *r) +{ + Sentence *s; + float alpha, alpha_bgn, alpha_end; + float max_alpha; + LOGPROB max_score; + PROCESS_AM *am; + MFCCCalc *mfcc; + + s = &(r->result.sent[0]); + + max_score = LOG_ZERO; + + printf("------------ begin VTLN -------------\n"); + + mfcc = r->am->mfcc; + + alpha_bgn = mfcc->para->vtln_alpha - VTLN_RANGE; + alpha_end = mfcc->para->vtln_alpha + VTLN_RANGE; + + for(alpha = alpha_bgn; alpha <= alpha_end; alpha += VTLN_STEP) { + mfcc->para->vtln_alpha = alpha; + if (InitFBank(mfcc->wrk, mfcc->para) == FALSE) { + jlog("ERROR: VTLN: InitFBank() failed\n"); + return; + } + if (wav2mfcc(recog->speech, recog->speechlen, recog) == FALSE) { + jlog("ERROR: VTLN: wav2mfcc() failed\n"); + return; + } + outprob_prepare(&(r->am->hmmwrk), mfcc->param->samplenum); + word_align(s->word, s->word_num, mfcc->param, s, r); + printf("%f: %f\n", alpha, s->align.allscore); + if (max_score < s->align.allscore) { + max_score = s->align.allscore; + max_alpha = alpha; + } + } + printf("MAX: %f: %f\n", max_alpha, max_score); + mfcc->para->vtln_alpha = max_alpha; + if (InitFBank(mfcc->wrk, mfcc->para) == FALSE) { + jlog("ERROR: VTLN: InitFBank() failed\n"); + return; + } + + printf("------------ end VTLN -------------\n"); + +} +#endif + + /* end of file */ Index: julius4/libjulius/src/m_chkparam.c diff -u julius4/libjulius/src/m_chkparam.c:1.2 julius4/libjulius/src/m_chkparam.c:1.3 --- julius4/libjulius/src/m_chkparam.c:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/src/m_chkparam.c Tue Jun 17 10:20:50 2008 @@ -20,7 +20,7 @@ * @author Akinobu LEE * @date Fri Mar 18 16:31:45 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -232,7 +232,7 @@ if (jconf->decodeopt.realtime_flag) { for(am = jconf->am_root; am; am = am->next) { if (am->analysis.cmn_update == FALSE && am->analysis.cmnload_filename == NULL) { - jlog("ERROR: m_chkparam: when \"-cmnnoupdate\", initial cepstral mean should be given by \"-cmnload\"\n"); + jlog("ERROR: m_chkparam: when \"-cmnnoupdate\", initial cepstral normalisation data should be given by \"-cmnload\"\n"); ok_p = FALSE; } } Index: julius4/libjulius/src/m_info.c diff -u julius4/libjulius/src/m_info.c:1.5 julius4/libjulius/src/m_info.c:1.6 --- julius4/libjulius/src/m_info.c:1.5 Sun Apr 27 22:06:55 2008 +++ julius4/libjulius/src/m_info.c Tue Jun 17 10:20:50 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Thu May 12 14:14:01 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -217,13 +217,23 @@ jlog("off\n"); } } - jlog(" cepstral mean norm. = "); - if (mfcc->para->cmn) { + jlog(" cepstral normalization = "); + if (mfcc->para->cmn || mfcc->para->cvn) { if (jconf->decodeopt.realtime_flag) { - jlog("real-time MAP-CMN\n"); + jlog("real-time MAP-"); } else { - jlog("sentence CMN\n"); + jlog("sentence "); } + if (mfcc->para->cmn) { + jlog("CMN"); + } + if (mfcc->para->cmn && mfcc->para->cvn) { + jlog("+"); + } + if (mfcc->para->cvn) { + jlog("CVN"); + } + jlog("\n"); } else { jlog("no\n"); } @@ -246,26 +256,29 @@ jlog("\n"); - if (jconf->decodeopt.realtime_flag && mfcc->para->cmn) { - jlog(" MAP-CMN:\n"); - jlog(" default cep. mean = "); + if (jconf->decodeopt.realtime_flag && (mfcc->para->cmn || mfcc->para->cvn)) { + jlog(" MAP-"); + if (mfcc->para->cmn) jlog("CMN"); + if (mfcc->para->cmn && mfcc->para->cvn) jlog("+"); + if (mfcc->para->cvn) jlog("CVN"); + jlog(":\n"); + jlog(" initial cep. data = "); if (mfcc->cmn.load_filename) { jlog("load from \"%s\"\n", mfcc->cmn.load_filename); } else { - jlog("not specified\n"); + jlog("none\n"); } - jlog(" initial mean weight = %6.2f\n", mfcc->cmn.map_weight); + jlog(" beginning data weight = %6.2f\n", mfcc->cmn.map_weight); if (mfcc->cmn.update) { - jlog(" initial mean update = yes, from last inputs at each input\n"); + jlog(" beginning data update = yes, from last inputs at each input\n"); } else { - jlog(" initial mean update = no, use default as initial at each input\n"); + jlog(" beginning data update = no, use default as initial at each input\n"); } if (mfcc->cmn.save_filename) { - jlog(" save cep. mean to = %s at end of each input\n", mfcc->cmn.save_filename); + jlog(" save cep. data to = file \"%s\" at end of each input\n", mfcc->cmn.save_filename); } jlog("\n"); } - } } Index: julius4/libjulius/src/m_options.c diff -u julius4/libjulius/src/m_options.c:1.8 julius4/libjulius/src/m_options.c:1.9 --- julius4/libjulius/src/m_options.c:1.8 Sat May 17 13:06:30 2008 +++ julius4/libjulius/src/m_options.c Tue Jun 17 10:20:50 2008 @@ -18,7 +18,7 @@ * @author Akinobu Lee * @date Thu May 12 18:52:07 2005 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ /* @@ -533,6 +533,23 @@ GET_TMPARG; jconf->amnow->frontend.ss_floor = atof(tmparg); continue; + } else if (strmatch(argv[i],"-cvn")) { + jconf->amnow->analysis.para.cvn = 1; + continue; + } else if (strmatch(argv[i],"-nocvn")) { + jconf->amnow->analysis.para.cvn = 0; + continue; + } else if (strmatch(argv[i],"-vtln")) { /* VTLN */ + GET_TMPARG; + jconf->amnow->analysis.para.vtln_alpha = (float)atof(tmparg); + GET_TMPARG; + jconf->amnow->analysis.para.vtln_lower = (float)atof(tmparg); + GET_TMPARG; + jconf->amnow->analysis.para.vtln_upper = (float)atof(tmparg); + continue; + } else if (strmatch(argv[i],"-novtln")) { /* disable VTLN */ + jconf->amnow->analysis.para.vtln_alpha = 1.0; + continue; } else if (strmatch(argv[i],"-48")) { /* use 48kHz input and down to 16kHz */ jconf->input.use_ds48to16 = TRUE; continue; Index: julius4/libjulius/src/m_usage.c diff -u julius4/libjulius/src/m_usage.c:1.6 julius4/libjulius/src/m_usage.c:1.7 --- julius4/libjulius/src/m_usage.c:1.6 Fri May 9 15:00:21 2008 +++ julius4/libjulius/src/m_usage.c Tue Jun 17 10:20:50 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Fri May 13 15:04:34 2005 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -155,6 +155,8 @@ fprintf(fp, " [-cmnsave file] save CMN param to file after each input\n"); fprintf(fp, " [-cmnnoupdate] not update CMN param while recog. (use with -cmnload)\n"); fprintf(fp, " [-cmnmapweight] weight value of initial cm for MAP-CMN (%6.2f)\n", jconf->am_root->analysis.cmn_map_weight); + fprintf(fp, " [-cvn] cepstral variance normalisation (%s)\n", jconf->amnow->analysis.para.cvn ? "on" : "off"); + fprintf(fp, " [-vtln alpha lowcut hicut] enable VTLN (1.0 to disable) (%f)\n", jconf->am_root->analysis.para_default.vtln_alpha); fprintf(fp, "\n Acoustic Model:\n"); fprintf(fp, " -h hmmdefsfile HMM definition file name\n"); Index: julius4/libjulius/src/realtime-1stpass.c diff -u julius4/libjulius/src/realtime-1stpass.c:1.3 julius4/libjulius/src/realtime-1stpass.c:1.4 --- julius4/libjulius/src/realtime-1stpass.c:1.3 Mon Mar 10 11:39:32 2008 +++ julius4/libjulius/src/realtime-1stpass.c Tue Jun 17 10:20:50 2008 @@ -111,7 +111,7 @@ * @author Akinobu Lee * @date Tue Aug 23 11:44:14 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -266,7 +266,7 @@ mfcc->tmpmfcc = (VECT *)mymalloc(sizeof(VECT) * para->vecbuflen); /* MAP-CMN 用の初期ケプストラム平均を読み込んで初期化する */ /* Initialize the initial cepstral mean data from file for MAP-CMN */ - if (para->cmn) mfcc->cmn.wrk = CMN_realtime_new(para->mfcc_dim, mfcc->cmn.map_weight); + if (para->cmn || para->cvn) mfcc->cmn.wrk = CMN_realtime_new(para, mfcc->cmn.map_weight); /* -cmnload 指定時, CMN用のケプストラム平均の初期値をファイルから読み込む */ /* if "-cmnload", load initial cepstral mean data from file for CMN */ if (mfcc->cmn.load_filename) { @@ -400,7 +400,7 @@ mfcc->f = 0; /* MAP-CMN の初期化 */ /* Prepare for MAP-CMN */ - if (mfcc->para->cmn) CMN_realtime_prepare(mfcc->cmn.wrk); + if (mfcc->para->cmn || mfcc->para->cvn) CMN_realtime_prepare(mfcc->cmn.wrk); } /* 準備した param 構造体のデータのパラメータ型を音響モデルとチェックする */ /* check type coherence between param and hmminfo here */ @@ -424,6 +424,11 @@ recog->triggered = FALSE; #endif +#ifdef DEBUG_VTLN_ALPHA_TEST + /* store speech */ + recog->speechlen = 0; +#endif + return TRUE; } @@ -558,7 +563,7 @@ /* CMN を計算 */ /* perform CMN */ - if (para->cmn) CMN_realtime(mfcc->cmn.wrk, tmpmfcc); + if (para->cmn || para->cvn) CMN_realtime(mfcc->cmn.wrk, tmpmfcc); return TRUE; } @@ -648,6 +653,11 @@ r = &(recog->real); +#ifdef DEBUG_VTLN_ALPHA_TEST + /* store speech */ + adin_cut_callback_store_buffer(Speech, nowlen, recog); +#endif + /* window[0..windownum-1] は前回の呼び出しで残った音声データが格納されている */ /* window[0..windownum-1] are speech data left from previous call */ @@ -929,7 +939,7 @@ mfcc->f = 0; /* MAP-CMN の初期化 */ /* Prepare for MAP-CMN */ - if (mfcc->para->cmn) CMN_realtime_prepare(mfcc->cmn.wrk); + if (mfcc->para->cmn || mfcc->para->cvn) CMN_realtime_prepare(mfcc->cmn.wrk); } #ifdef BACKEND_VAD @@ -1190,7 +1200,7 @@ } } /* a new frame has been obtained from delta buffer to tmpmfcc */ - if(para->cmn) CMN_realtime(mfcc->cmn.wrk, mfcc->tmpmfcc); + if(para->cmn || para->cvn) CMN_realtime(mfcc->cmn.wrk, mfcc->tmpmfcc); if (param_alloc(mfcc->param, mfcc->f + 1, mfcc->param->veclen) == FALSE) { jlog("ERROR: failed to allocate memory for incoming MFCC vectors\n"); return FALSE; @@ -1321,7 +1331,7 @@ } if (cmn_update_p) { /* update last CMN parameter for next spech */ - CMN_realtime_update(mfcc->cmn.wrk); + CMN_realtime_update(mfcc->cmn.wrk, mfcc->param); } else { /* do not update, because the last input is bogus */ if (verbose_flag) { Index: julius4/libjulius/src/recogmain.c diff -u julius4/libjulius/src/recogmain.c:1.4 julius4/libjulius/src/recogmain.c:1.5 --- julius4/libjulius/src/recogmain.c:1.4 Tue Mar 18 02:00:31 2008 +++ julius4/libjulius/src/recogmain.c Tue Jun 17 10:20:50 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Wed Aug 8 14:53:53 2007 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ @@ -329,7 +329,7 @@ * input segmentation. * */ -static int +int adin_cut_callback_store_buffer(SP16 *now, int len, Recog *recog) { if (recog->speechlen == 0) { /* first part of a segment */ @@ -1083,6 +1083,13 @@ /* output end of 2nd pass */ callback_exec(CALLBACK_EVENT_PASS2_END, recog); +#ifdef DEBUG_VTLN_ALPHA_TEST + if (r->am->mfcc->para->vtln_alpha == 1.0) { + /* if vtln parameter remains default, search for VTLN parameter */ + vtln_alpha(recog, r); + } +#endif + end_recog: /**********************/ /* end of recognition */ From sumomo @ users.sourceforge.jp Tue Jun 17 10:20:51 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 17 Jun 2008 10:20:51 +0900 Subject: [Julius-cvs 184] CVS update: julius4/libsent/include/sent Message-ID: <1213665651.194716.11626.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/mfcc.h diff -u julius4/libsent/include/sent/mfcc.h:1.3 julius4/libsent/include/sent/mfcc.h:1.4 --- julius4/libsent/include/sent/mfcc.h:1.3 Fri May 9 14:58:17 2008 +++ julius4/libsent/include/sent/mfcc.h Tue Jun 17 10:20:51 2008 @@ -27,7 +27,7 @@ * @author Akinobu LEE * @date Fri Feb 11 03:40:52 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ @@ -49,6 +49,7 @@ #include #include +#include #include #define DEF_SMPPERIOD 625 ///< Default sampling period in 100ns (625 = 16kHz) @@ -90,6 +91,9 @@ int raw_e; ///< 1 if using raw energy, 0 if disabled, corresponds to RAWENERGY in HTK int zmeanframe; ///< 1 if apply zero mean frame like ZMEANSOURCE in HTK int usepower; ///< 1 if use power instead of magnitude in filterbank analysis + float vtln_alpha; ///< warping factor for VTLN, corresponds to WARPFREQ in HTK + float vtln_upper; ///< hi freq. cut off for VTLN, corresponds to WARPUCUTOFF in HTK + float vtln_lower; ///< low freq. cut off for VTLN, corresponds to WARPLCUTOFF in HTK /* items below does not need to be embedded, because they can be detemined from the acoustic model header, or should be computed @@ -100,6 +104,7 @@ int c0; ///< 1 if use 0'th cepstral parameter, 0 if disabled, corresponds to _0 qualifier in HTK int absesup; ///< 1 if absolute energy should be suppressed int cmn; ///< 1 if use Cepstrum Mean Normalization, 0 if disabled, corresponds to _Z qualifier in HTK + int cvn; ///< 1 if use cepstral variance normalization, else 0 */ int mfcc_dim; ///< Number of MFCC dimensions int baselen; ///< Number of base MFCC dimension with energies int vecbuflen; ///< Vector length needed for computation @@ -166,7 +171,8 @@ * */ typedef struct { - float *mfcc_sum; ///< values of sum of MFCC parameters + float *mfcc_sum; ///< Sum of MFCC parameters + float *mfcc_var; ///< Variance sum of MFCC parameters int framenum; ///< summed number of frames } CMEAN; @@ -178,10 +184,14 @@ CMEAN *clist; ///< List of MFCC sum for previous inputs int clist_max; ///< Allocated number of CMEAN in clist int clist_num; ///< Currentlly filled CMEAN in clist - int dim; ///< Local workarea to store the number of MFCC dimension. float cweight; ///< Weight of initial cepstral mean float *cmean_init; ///< Initial cepstral mean for each input - boolean cmean_init_set; ///< TRUE if cmean_init was set + float *cvar_init; ///< Inisial cepstral standard deviation for each input + int mfcc_dim; ///< base MFCC dimension (to apply CMN) + int veclen; ///< full MFCC vector length + boolean mean; ///< TRUE if CMN is enabled + boolean var; ///< TRUE if CVN is enabled + boolean cmean_init_set; ///< TRUE if cmean_init (and cvar_init) was set CMEAN now; ///< Work area to hold current cepstral mean } CMNWork; @@ -200,7 +210,7 @@ void WMP_calc(MFCCWork *w, float *mfcc, Value *para); void WMP_free(MFCCWork *w); /* Get filterbank information */ -void InitFBank(MFCCWork *w, Value *para); +boolean InitFBank(MFCCWork *w, Value *para); void FreeFBank(FBankInfo *fb); /* Apply hamming window */ void Hamming (float *wave, int framesize, MFCCWork *w); @@ -234,6 +244,7 @@ void NormaliseLogE(float **c, int frame_num, Value *para); /* Cepstrum Mean Normalization (batch) */ void CMN(float **mfcc, int frame_num, int dim); +void MVN(float **mfcc, int frame_num, Value *para); /**** wav2mfcc-pipe.c ****/ DeltaBuf *WMP_deltabuf_new(int veclen, int windowlen); @@ -242,11 +253,11 @@ boolean WMP_deltabuf_proceed(DeltaBuf *db, float *new_mfcc); boolean WMP_deltabuf_flush(DeltaBuf *db); -CMNWork *CMN_realtime_new(int dimension, float weight); +CMNWork *CMN_realtime_new(Value *para, float weight); void CMN_realtime_free(CMNWork *c); void CMN_realtime_prepare(CMNWork *c); void CMN_realtime(CMNWork *c, float *mfcc); -void CMN_realtime_update(CMNWork *c); +void CMN_realtime_update(CMNWork *c, HTK_Param *param); boolean CMN_load_from_file(CMNWork *c, char *filename); boolean CMN_save_to_file(CMNWork *c, char *filename); From sumomo @ users.sourceforge.jp Tue Jun 17 10:20:51 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 17 Jun 2008 10:20:51 +0900 Subject: [Julius-cvs 185] CVS update: julius4/libsent/src/wav2mfcc Message-ID: <1213665651.432705.11640.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/wav2mfcc/mfcc-core.c diff -u julius4/libsent/src/wav2mfcc/mfcc-core.c:1.3 julius4/libsent/src/wav2mfcc/mfcc-core.c:1.4 --- julius4/libsent/src/wav2mfcc/mfcc-core.c:1.3 Fri May 9 14:58:17 2008 +++ julius4/libsent/src/wav2mfcc/mfcc-core.c Tue Jun 17 10:20:51 2008 @@ -17,7 +17,7 @@ * @author Akinobu Lee * @date Mon Aug 7 11:55:45 2006 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -157,6 +157,60 @@ return(1127 * log(1 + (k-1) * fres)); } +/** + * Create fbank center frequency for VTLN. + * + * @param cf [i/o] center frequency of channels in Mel, will be changed considering VTLN + * @param para [in] analysis parameter + * @param mlo [in] fbank lower bound in Mel + * @param mhi [in] fbank upper bound in Mel + * @param maxChan [in] maximum number of channels + * + */ +static boolean +VTLN_recreate_fbank_cf(float *cf, Value *para, float mlo, float mhi, int maxChan) +{ + int chan; + float minf, maxf, cf_orig, cf_new; + float scale, cu, cl, au, al; + + /* restore frequency range to non-Mel */ + minf = 700.0 * (exp(mlo / 1127.0) - 1.0); + maxf = 700.0 * (exp(mhi / 1127.0) - 1.0); + + if (para->vtln_upper > maxf) { + jlog("Error: VTLN upper cut-off greater than upper frequency bound: %.1f > %.1f\n", para->vtln_upper, maxf); + return FALSE; + } + if (para->vtln_lower < minf) { + jlog("Error: VTLN lower cut-off smaller than lower frequency bound: %.1f < %.1f\n", para->vtln_lower, minf); + return FALSE; + } + + /* prepare variables for warping */ + scale = 1.0 / para->vtln_alpha; + cu = para->vtln_upper * 2 / ( 1 + scale); + cl = para->vtln_lower * 2 / ( 1 + scale); + au = (maxf - cu * scale) / (maxf - cu); + al = (cl * scale - minf) / (cl - minf); + + for (chan = 1; chan <= maxChan; chan++) { + /* get center frequency, restore to non-Mel */ + cf_orig = 700.0 * (exp(cf[chan] / 1127.0) - 1.0); + /* do warping */ + if( cf_orig > cu ){ + cf_new = au * (cf_orig - cu) + scale * cu; + } else if ( cf_orig < cl){ + cf_new = al * (cf_orig - minf) + minf; + } else { + cf_new = scale * cf_orig; + } + /* convert the new center frequency to Mel and store */ + cf[chan] = 1127.0 * log (1.0 + cf_new / 700.0); + } + return TRUE; +} + /** * Build filterbank information and generate tables for MFCC comptutation. * @@ -165,7 +219,7 @@ * * @return the generated filterbank information. */ -void +boolean InitFBank(MFCCWork *w, Value *para) { float mlo, mhi, ms, melk; @@ -202,6 +256,13 @@ for (chan = 1; chan <= maxChan; chan++) w->fb.cf[chan] = ((float)chan / maxChan)*ms + mlo; + if (para->vtln_alpha != 1.0) { + /* Modify fbank center frequencies for VTLN */ + if (VTLN_recreate_fbank_cf(w->fb.cf, para, mlo, mhi, maxChan) == FALSE) { + return FALSE; + } + } + /* Create loChan map, loChan[fftindex] -> lower channel index */ w->fb.loChan = (short *)mymalloc((nv2 + 1) * sizeof(short)); for(k = 1, chan = 1; k <= nv2; k++){ @@ -232,6 +293,7 @@ w->sqrt2var = sqrt(2.0 / para->fbank_num); + return TRUE; } /** @@ -558,7 +620,7 @@ memset(w, 0, sizeof(MFCCWork)); /* set filterbank information */ - InitFBank(w, para); + if (InitFBank(w, para) == FALSE) return NULL; #ifdef MFCC_SINCOS_TABLE /* prepare tables */ Index: julius4/libsent/src/wav2mfcc/para.c diff -u julius4/libsent/src/wav2mfcc/para.c:1.5 julius4/libsent/src/wav2mfcc/para.c:1.6 --- julius4/libsent/src/wav2mfcc/para.c:1.5 Fri Jun 6 12:20:14 2008 +++ julius4/libsent/src/wav2mfcc/para.c Tue Jun 17 10:20:51 2008 @@ -16,7 +16,7 @@ * @author Akinobu Lee * @date Fri Oct 27 14:55:00 2006 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -54,10 +54,14 @@ para->hipass = -2; /* undef */ para->lopass = -2; /* undef */ para->cmn = -1; + para->cvn = -1; para->raw_e = -1; para->c0 = -1; //para->ss_alpha = -1; //para->ss_floor = -1; + para->vtln_alpha = -1; + para->vtln_upper = -1; + para->vtln_lower = -1; para->zmeanframe = -1; para->usepower = -1; para->delta = -1; @@ -93,10 +97,12 @@ para->enormal = FALSE; para->escale = DEF_ESCALE; para->silFloor = DEF_SILFLOOR; + para->cvn = 0; para->hipass = -1; /* disabled */ para->lopass = -1; /* disabled */ //para->ss_alpha = DEF_SSALPHA; //para->ss_floor = DEF_SSFLOOR; + para->vtln_alpha = 1.0; /* disabled */ para->zmeanframe = FALSE; para->usepower = FALSE; } @@ -123,6 +129,7 @@ para->silFloor = 50.0; para->hipass = -1; /* disabled */ para->lopass = -1; /* disabled */ + para->vtln_alpha = 1.0; /* disabled */ para->zmeanframe = FALSE; para->usepower = FALSE; } @@ -153,10 +160,14 @@ if (dst->hipass == -2) dst->hipass = src->hipass; if (dst->lopass == -2) dst->lopass = src->lopass; if (dst->cmn == -1) dst->cmn = src->cmn; + if (dst->cvn == -1) dst->cvn = src->cvn; if (dst->raw_e == -1) dst->raw_e = src->raw_e; if (dst->c0 == -1) dst->c0 = src->c0; //if (dst->ss_alpha == -1) dst->ss_alpha = src->ss_alpha; //if (dst->ss_floor == -1) dst->ss_floor = src->ss_floor; + if (dst->vtln_alpha == -1) dst->vtln_alpha = src->vtln_alpha; + if (dst->vtln_upper == -1) dst->vtln_upper = src->vtln_upper; + if (dst->vtln_lower == -1) dst->vtln_lower = src->vtln_lower; if (dst->zmeanframe == -1) dst->zmeanframe = src->zmeanframe; if (dst->usepower == -1) dst->usepower = src->usepower; if (dst->delta == -1) dst->delta = src->delta; @@ -255,6 +266,12 @@ para->escale = atof(a); } else if (strmatch(d, "SILFLOOR")) { /* -silfloor */ para->silFloor = atof(a); + } else if (strmatch(d, "WARPFREQ")) { /* -vtln (1) */ + para->vtln_alpha = atof(a); + } else if (strmatch(d, "WARPLCUTOFF")) { /* -vtln (2) */ + para->vtln_lower = atof(a); + } else if (strmatch(d, "WARPUCUTOFF")) { /* -vtln (3) */ + para->vtln_upper = atof(a); } else if (strmatch(d, "TARGETKIND")) { jlog("Warning: para: TARGETKIND skipped (will be determined by AM header)\n"); skipped = TRUE; @@ -384,4 +401,11 @@ fprintf(fp, "\t use power = "); if (para->usepower) fprintf(fp, "ON\n"); else fprintf(fp, "OFF\n"); + fprintf(fp, "\t CVN = "); + if (para->cvn) fprintf(fp, "ON\n"); + else fprintf(fp, "OFF\n"); + fprintf(fp, "\t VTLN = "); + if(para->vtln_alpha != 1.0) { + fprintf(fp, "ON, alpha=%.3f, f_low=%.1f, f_high=%.1f\n", para->vtln_alpha, para->vtln_lower, para->vtln_upper); + } else fprintf(fp, "OFF\n"); } Index: julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c diff -u julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c:1.3 julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c:1.4 --- julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c:1.3 Fri Jun 6 11:56:10 2008 +++ julius4/libsent/src/wav2mfcc/wav2mfcc-buffer.c Tue Jun 17 10:20:51 2008 @@ -24,7 +24,7 @@ * @author Akinobu LEE * @date Thu Feb 17 17:43:35 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ @@ -93,8 +93,9 @@ /* Acceleration */ if (para->acc) Accel(mfcc, frame_num, para); - /* Cepstrum Mean Normalization */ - if(para->cmn) CMN(mfcc, frame_num, para->mfcc_dim + (para->c0 ? 1 : 0)); + /* Cepstrum Mean and/or Variance Normalization */ + if (para->cmn && ! para->cvn) CMN(mfcc, frame_num, para->mfcc_dim + (para->c0 ? 1 : 0)); + else if (para->cmn || para->cvn) MVN(mfcc, frame_num, para); return(frame_num); } @@ -236,3 +237,55 @@ free(sum); free(mfcc_ave); } + +/** + * Cepstrum Mean/Variance Normalization (buffered) + * + * @param mfcc [i/o] array of MFCC vectors + * @param frame_num [in] number of frames + * @param para [in] configuration parameters + */ +void MVN(float **mfcc, int frame_num, Value *para) +{ + int i, t; + float *mfcc_mean, *mfcc_sd; + float x; + int basedim; + + basedim = para->mfcc_dim + (para->c0 ? 1 : 0); + + mfcc_mean = (float *)mycalloc(para->veclen, sizeof(float)); + if (para->cvn) mfcc_sd = (float *)mycalloc(para->veclen, sizeof(float)); + + /* get mean */ + for(i = 0; i < para->veclen; i++){ + mfcc_mean[i] = 0.0; + for(t = 0; t < frame_num; t++) + mfcc_mean[i] += mfcc[t][i]; + mfcc_mean[i] /= (float)frame_num; + } + if (para->cvn) { + /* get standard deviation */ + for(i = 0; i < para->veclen; i++){ + mfcc_sd[i] = 0.0; + for(t = 0; t < frame_num; t++) { + x = mfcc[t][i] - mfcc_mean[i]; + mfcc_sd[i] += x * x; + } + mfcc_sd[i] = sqrt(mfcc_sd[i] / (float)frame_num); + } + } + for(t = 0; t < frame_num; t++){ + if (para->cmn) { + /* mean normalization (base MFCC only) */ + for(i = 0; i < basedim; i++) mfcc[t][i] -= mfcc_mean[i]; + } + if (para->cvn) { + /* variance normalization (full MFCC) */ + for(i = 0; i < para->veclen; i++) mfcc[t][i] /= mfcc_sd[i]; + } + } + + if (para->cvn) free(mfcc_sd); + free(mfcc_mean); +} Index: julius4/libsent/src/wav2mfcc/wav2mfcc-pipe.c diff -u julius4/libsent/src/wav2mfcc/wav2mfcc-pipe.c:1.2 julius4/libsent/src/wav2mfcc/wav2mfcc-pipe.c:1.3 --- julius4/libsent/src/wav2mfcc/wav2mfcc-pipe.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/wav2mfcc/wav2mfcc-pipe.c Tue Jun 17 10:20:51 2008 @@ -20,7 +20,7 @@ * @author Akinobu LEE * @date Thu Feb 17 18:12:30 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -45,6 +45,7 @@ #include #include +#include /***********************************************************************/ /** @@ -238,12 +239,12 @@ /** * Initialize MAP-CMN at startup. * - * @param dimension [in] vector dimension + * @param para [in] MFCC computation configuration parameter * @param weight [in] initial cepstral mean weight * */ CMNWork * -CMN_realtime_new(int dimension, float weight) +CMN_realtime_new(Value *para, float weight) { int i; @@ -251,19 +252,24 @@ c = (CMNWork *)mymalloc(sizeof(CMNWork)); - c->dim = dimension; c->cweight = weight; - + c->mfcc_dim = para->mfcc_dim + (para->c0 ? 1 : 0); + c->veclen = para->veclen; + c->mean = para->cmn ? TRUE : FALSE; + c->var = para->cvn ? TRUE : FALSE; c->clist_max = CPSTEP; c->clist_num = 0; c->clist = (CMEAN *)mymalloc(sizeof(CMEAN) * c->clist_max); for(i=0;iclist_max;i++) { - c->clist[i].mfcc_sum = (float *)mymalloc(sizeof(float)*c->dim); + c->clist[i].mfcc_sum = (float *)mymalloc(sizeof(float)*c->veclen); + if (c->var) c->clist[i].mfcc_var = (float *)mymalloc(sizeof(float)*c->veclen); c->clist[i].framenum = 0; } - c->now.mfcc_sum = (float *)mymalloc(sizeof(float) * c->dim); + c->now.mfcc_sum = (float *)mymalloc(sizeof(float) * c->veclen); + if (c->var) c->now.mfcc_var = (float *)mymalloc(sizeof(float) * c->veclen); - c->cmean_init = (float *)mymalloc(sizeof(float) * c->dim); + c->cmean_init = (float *)mymalloc(sizeof(float) * c->veclen); + if (c->var) c->cvar_init = (float *)mymalloc(sizeof(float) * c->veclen); c->cmean_init_set = FALSE; return c; @@ -282,7 +288,12 @@ free(c->cmean_init); free(c->now.mfcc_sum); + if (c->var) { + free(c->cvar_init); + free(c->now.mfcc_var); + } for(i=0;iclist_max;i++) { + if (c->var) free(c->clist[i].mfcc_var); free(c->clist[i].mfcc_sum); } free(c->clist); @@ -299,7 +310,10 @@ { int d; - for(d=0;ddim;d++) c->now.mfcc_sum[d] = 0.0; + for(d=0;dveclen;d++) c->now.mfcc_sum[d] = 0.0; + if (c->var) { + for(d=0;dveclen;d++) c->now.mfcc_var[d] = 0.0; + } c->now.framenum = 0; } @@ -318,18 +332,50 @@ c->now.framenum++; if (c->cmean_init_set) { - for(d=0;ddim;d++) { - /* accumulate value of given MFCC to sum */ + /* initial data exists */ + for(d=0;dveclen;d++) { + /* accumulate current MFCC to sum */ c->now.mfcc_sum[d] += mfcc[d]; - /* calculate map-cmn and perform subtraction to the given vector */ + /* calculate map-mean */ x = c->now.mfcc_sum[d] + c->cweight * c->cmean_init[d]; y = (double)c->now.framenum + c->cweight; - mfcc[d] -= x / y; + x /= y; + if (c->var) { + /* calculate map-var */ + c->now.mfcc_var[d] += (mfcc[d] - x) * (mfcc[d] - x); + } + if (c->mean && d < c->mfcc_dim) { + /* mean normalization */ + mfcc[d] -= x; + } + if (c->var) { + /* variance normalization */ + x = c->now.mfcc_var[d] + c->cweight * c->cvar_init[d]; + y = (double)c->now.framenum + c->cweight; + mfcc[d] /= sqrt(x / y); + } } } else { - for(d=0;ddim;d++) { + /* no initial data */ + for(d=0;dveclen;d++) { + /* accumulate current MFCC to sum */ c->now.mfcc_sum[d] += mfcc[d]; - mfcc[d] -= c->now.mfcc_sum[d] / c->now.framenum; + /* calculate current mean */ + x = c->now.mfcc_sum[d] / c->now.framenum; + if (c->var) { + /* calculate current variance */ + c->now.mfcc_var[d] += (mfcc[d] - x) * (mfcc[d] - x); + } + if (c->mean && d < c->mfcc_dim) { + /* mean normalization */ + mfcc[d] -= x; + } +#if 0 /* not perform variance normalization on no initial data */ + if (c->var) { + /* variance normalization */ + mfcc[d] /= sqrt(c->now.mfcc_var[d] / c->now.framenum); + } +#endif } } } @@ -340,9 +386,9 @@ * @param c [i/o] CMN calculation work area */ void -CMN_realtime_update(CMNWork *c) +CMN_realtime_update(CMNWork *c, HTK_Param *param) { - float *tmp; + float *tmp, *tmp2; int i, d; int frames; @@ -350,15 +396,44 @@ /* this may occur by pausing just after startup */ if (c->now.framenum == 0) return; + /* re-calculate variance based on the final mean at the given param */ + if (c->var && param != NULL) { + float m, x; + if (param->samplenum != c->now.framenum) { + jlog("InternalError: CMN_realtime_update: param->samplenum != c->now.framenum\n"); + } else if (param->veclen != c->veclen) { + jlog("InternalError: CMN_realtime_update: param->veclen != c->veclen\n"); + } else { + for(d=0;dveclen;d++) { + m = c->now.mfcc_sum[d] / (float) c->now.framenum; + x = 0; + for(i=0;isamplenum;i++) { + x += (param->parvec[i][d] - m) * (param->parvec[i][d] - m); + } + c->now.mfcc_var[d] = x; + } + } + } + /* compute cepstral mean from now and previous sums up to CPMAX frames */ - for(d=0;ddim;d++) c->cmean_init[d] = c->now.mfcc_sum[d]; + for(d=0;dveclen;d++) c->cmean_init[d] = c->now.mfcc_sum[d]; + if (c->var) { + for(d=0;dveclen;d++) c->cvar_init[d] = c->now.mfcc_var[d]; + } frames = c->now.framenum; for(i=0;iclist_num;i++) { - for(d=0;ddim;d++) c->cmean_init[d] += c->clist[i].mfcc_sum[d]; + for(d=0;dveclen;d++) c->cmean_init[d] += c->clist[i].mfcc_sum[d]; + if (c->var) { + for(d=0;dveclen;d++) c->cvar_init[d] += c->clist[i].mfcc_var[d]; + } frames += c->clist[i].framenum; if (frames >= CPMAX) break; } - for(d=0;ddim;d++) c->cmean_init[d] /= (float) frames; + for(d=0;dveclen;d++) c->cmean_init[d] /= (float) frames; + if (c->var) { + for(d=0;dveclen;d++) c->cvar_init[d] /= (float) frames; + } + c->cmean_init_set = TRUE; /* expand clist if neccessary */ @@ -366,17 +441,21 @@ c->clist_max += CPSTEP; c->clist = (CMEAN *)myrealloc(c->clist, sizeof(CMEAN) * c->clist_max); for(i=c->clist_num;iclist_max;i++) { - c->clist[i].mfcc_sum = (float *)mymalloc(sizeof(float)*c->dim); + c->clist[i].mfcc_sum = (float *)mymalloc(sizeof(float)*c->veclen); + if (c->var) c->clist[i].mfcc_var = (float *)mymalloc(sizeof(float)*c->veclen); c->clist[i].framenum = 0; } } /* shift clist */ tmp = c->clist[c->clist_max-1].mfcc_sum; + if (c->var) tmp2 = c->clist[c->clist_max-1].mfcc_var; memmove(&(c->clist[1]), &(c->clist[0]), sizeof(CMEAN) * (c->clist_max - 1)); c->clist[0].mfcc_sum = tmp; + if (c->var) c->clist[0].mfcc_var = tmp2; /* copy now to clist[0] */ - memcpy(c->clist[0].mfcc_sum, c->now.mfcc_sum, sizeof(float) * c->dim); + memcpy(c->clist[0].mfcc_sum, c->now.mfcc_sum, sizeof(float) * c->veclen); + if (c->var) memcpy(c->clist[0].mfcc_var, c->now.mfcc_var, sizeof(float) * c->veclen); c->clist[0].framenum = c->now.framenum; if (c->clist_num < c->clist_max) c->clist_num++; @@ -457,17 +536,26 @@ return(FALSE); } /* check length */ - if (veclen != c->dim) { - jlog("Error: wav2mfcc-pipe: vector dimension mismatch\n"); + if (veclen != c->veclen) { + jlog("Error: wav2mfcc-pipe: cepstral dimension mismatch\n"); + jlog("Error: wav2mfcc-pipe: process = %d, file = %d\n", c->veclen, veclen); fclose_readfile(fp); return(FALSE); } /* read body */ - if (myread(c->cmean_init, sizeof(float), c->dim, fp) == FALSE) { - jlog("Error: wav2mfcc-pipe: failed to read\n"); + if (myread(c->cmean_init, sizeof(float), c->veclen, fp) == FALSE) { + jlog("Error: wav2mfcc-pipe: failed to read mean for CMN\n"); fclose_readfile(fp); return(FALSE); } + if (c->var) { + if (myread(c->cvar_init, sizeof(float), c->veclen, fp) == FALSE) { + jlog("Error: wav2mfcc-pipe: failed to read variance for CVN\n"); + fclose_readfile(fp); + return(FALSE); + } + } + if (fclose_readfile(fp) == -1) { jlog("Error: wav2mfcc-pipe: failed to close\n"); return(FALSE); @@ -492,27 +580,35 @@ { int fd; - jlog("Stat: wav2mfcc-pipe: writing current CM to file \"%s\"\n", filename); + jlog("Stat: wav2mfcc-pipe: writing current cepstral data to file \"%s\"\n", filename); if ((fd = creat(filename, 0644)) == -1) { - jlog("Error: wav2mfcc-pipe: failed to open\n"); + jlog("Error: wav2mfcc-pipe: failed to open \"%s\" to write current cepstral data\n", filename); return(FALSE); } /* write header */ - if (mywrite(&(c->dim), sizeof(int), 1, fd) == FALSE) { - jlog("Error: wav2mfcc-pipe: failed to write header\n"); + if (mywrite(&(c->veclen), sizeof(int), 1, fd) == FALSE) { + jlog("Error: wav2mfcc-pipe: cannot write header to \"%s\" as current cepstral data\n", filename); close(fd); return(FALSE); } /* write body */ - if (mywrite(c->cmean_init, sizeof(float), c->dim, fd) == FALSE) { - jlog("Error: wav2mfcc-pipe: failed to write header\n"); + if (mywrite(c->cmean_init, sizeof(float), c->veclen, fd) == FALSE) { + jlog("Error: wav2mfcc-pipe: cannot write mean to \"%s\" as current cepstral data\n", filename); close(fd); return(FALSE); } + if (c->var) { + if (mywrite(c->cvar_init, sizeof(float), c->veclen, fd) == FALSE) { + jlog("Error: wav2mfcc-pipe: cannot write variance to \"%s\" as current cepstrum\n", filename); + close(fd); + return(FALSE); + } + } + close(fd); - jlog("Stat: wav2mfcc-pipe: wrote current CM\n"); + jlog("Stat: wav2mfcc-pipe: current cepstral data written to \"%s\"\n", filename); return(TRUE); } From sumomo @ users.sourceforge.jp Thu Jun 19 01:20:55 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 19 Jun 2008 01:20:55 +0900 Subject: [Julius-cvs 186] CVS update: julius4/libjulius/src Message-ID: <1213806055.542903.18196.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/m_jconf.c diff -u julius4/libjulius/src/m_jconf.c:1.3 julius4/libjulius/src/m_jconf.c:1.4 --- julius4/libjulius/src/m_jconf.c:1.3 Wed Feb 13 17:45:27 2008 +++ julius4/libjulius/src/m_jconf.c Thu Jun 19 01:20:55 2008 @@ -37,7 +37,7 @@ * @author Akinobu Lee * @date Thu May 12 14:16:18 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -321,8 +321,8 @@ return str; } strncpy(env, bgn, len); - env[len+1] = '\0'; - + env[len] = '\0'; + /* get value */ if ((envval = getenv(env)) == NULL) { jlog("ERROR: failed to expand variable: no such variable \"%s\"\n", env); @@ -348,6 +348,7 @@ } /* go on to next */ + if (eb != 0) p++; } free(str); From sumomo @ users.sourceforge.jp Thu Jun 19 01:21:27 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 19 Jun 2008 01:21:27 +0900 Subject: [Julius-cvs 187] CVS update: julius4/libsent/src/anlz Message-ID: <1213806087.392120.18351.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/anlz/rdparam.c diff -u julius4/libsent/src/anlz/rdparam.c:1.2 julius4/libsent/src/anlz/rdparam.c:1.3 --- julius4/libsent/src/anlz/rdparam.c:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/src/anlz/rdparam.c Thu Jun 19 01:21:27 2008 @@ -25,7 +25,7 @@ * @author Akinobu LEE * @date Tue Feb 15 00:16:44 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -103,6 +103,12 @@ /* read in headers */ if(!myread((char *)&(hd->samplenum), sizeof(unsigned int), 1, fp)) return(FALSE); + /* try to detect wav file */ + if (hd->samplenum == 1380533830) { /* read string "RIFF" as an integer */ + jlog("Error: rdparam: input file is WAV file, not a parameter file\n"); + return FALSE; + } + /* try to detect and read little-endian parameters from wav2mfcc... */ if (hd->samplenum >= 60000) { /* more than 10 minutes! */ jlog("Warning: rdparam: header says it has %d frames (more than 10 minutes)\n", hd->samplenum); From sumomo @ users.sourceforge.jp Thu Jun 19 01:22:08 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 19 Jun 2008 01:22:08 +0900 Subject: [Julius-cvs 188] CVS update: julius4/libjulius/src Message-ID: <1213806128.564024.19417.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/recogmain.c diff -u julius4/libjulius/src/recogmain.c:1.5 julius4/libjulius/src/recogmain.c:1.6 --- julius4/libjulius/src/recogmain.c:1.5 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/src/recogmain.c Thu Jun 19 01:22:08 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Wed Aug 8 14:53:53 2007 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ @@ -1035,6 +1035,13 @@ if (r->config->compute_only_1pass) continue; /* if search already failed on 1st pass, skip 2nd pass */ if (r->result.status < 0) continue; + /* prepare result storage */ + if (r->lmtype == LM_DFA && r->config->output.multigramout_flag) { + result_sentence_malloc(r, r->config->output.output_hypo_maxnum * multigram_get_all_num(r->lm)); + } else { + result_sentence_malloc(r, r->config->output.output_hypo_maxnum); + } + /* do 2nd pass */ if (r->lmtype == LM_PROB) { wchmm_fbs(r->am->mfcc->param, r, 0, 0); } else if (r->lmtype == LM_DFA) { @@ -1042,12 +1049,17 @@ /* execute 2nd pass multiple times for each grammar sequencially */ /* to output result for each grammar */ MULTIGRAM *m; + boolean has_success = FALSE; for(m = r->lm->grammars; m; m = m->next) { if (m->active) { jlog("STAT: execute 2nd pass limiting words for gram #%d\n", m->id); wchmm_fbs(r->am->mfcc->param, r, m->cate_begin, m->dfa->term_num); + if (r->result.status == J_RESULT_STATUS_SUCCESS) { + has_success = TRUE; + } } } + r->result.status = (has_success == TRUE) ? J_RESULT_STATUS_SUCCESS : J_RESULT_STATUS_FAIL; } else { /* only the best among all grammar will be output */ wchmm_fbs(r->am->mfcc->param, r, 0, r->lm->dfa->term_num); Index: julius4/libjulius/src/search_bestfirst_main.c diff -u julius4/libjulius/src/search_bestfirst_main.c:1.5 julius4/libjulius/src/search_bestfirst_main.c:1.6 --- julius4/libjulius/src/search_bestfirst_main.c:1.5 Sun Apr 27 22:06:55 2008 +++ julius4/libjulius/src/search_bestfirst_main.c Thu Jun 19 01:22:08 2008 @@ -35,7 +35,7 @@ * @author Akinobu Lee * @date Thu Sep 08 11:51:12 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -1262,9 +1262,6 @@ envl_init(dwrk, peseqlen); #endif /* SCAN_BEAM */ - /* prepare result storage */ - result_sentence_malloc(r, jconf->output.output_hypo_maxnum); - /* エンベロープ探索用の単語長別展開数カウンタを初期化 */ /* initialize counters for envelope search */ if (jconf->pass2.enveloped_bestfirst_width >= 0) wb_init(dwrk); From sumomo @ users.sourceforge.jp Fri Jun 20 00:33:03 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 20 Jun 2008 00:33:03 +0900 Subject: [Julius-cvs 189] CVS update: julius4/gramtools/mkdfa/mkfa-1.44-flex Message-ID: <1213889583.350492.8017.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/mkdfa/mkfa-1.44-flex/dfa.c diff -u julius4/gramtools/mkdfa/mkfa-1.44-flex/dfa.c:1.2 julius4/gramtools/mkdfa/mkfa-1.44-flex/dfa.c:1.3 --- julius4/gramtools/mkdfa/mkfa-1.44-flex/dfa.c:1.2 Tue Dec 18 17:45:47 2007 +++ julius4/gramtools/mkdfa/mkfa-1.44-flex/dfa.c Fri Jun 20 00:33:03 2008 @@ -82,7 +82,7 @@ CLASSFLAGS unifyAccptFlag; CLASSFLAGS unifyStartFlag; - verboseMes( "[func]r_makeDFA(FA %08x)", (unsigned int)fa ); + verboseMes( "[func]r_makeDFA(FA %08x)", (long)fa ); DFAtravTotal++; if( fa->traversed == 1 ){ verboseMes( "traversed..." ); @@ -361,11 +361,11 @@ FALIST *preAtom = NULL; FALIST *curAtom = groupTop; FALIST *srcCurAtom = NULL; - int cmp; + long cmp; if( fa->group == NULL ){ while( curAtom != NULL ){ - cmp = (int)fa - (int)curAtom->fa; + cmp = (long)fa - (long)curAtom->fa; if( cmp == 0 ) return( groupTop ); if( cmp < 0 ) break; preAtom = curAtom; @@ -393,7 +393,7 @@ } break; }*/ - cmp = (int)srcCurAtom->fa - (int)curAtom->fa; + cmp = (long)srcCurAtom->fa - (long)curAtom->fa; if( cmp == 0 ) continue; if( cmp < 0 ){ groupTop = insertFAlist( groupTop, preAtom, curAtom, srcCurAtom->fa ); @@ -464,20 +464,20 @@ { verboseMes( "Created New Group" ); while( group != NULL ){ - verboseMes( " FAadr: %08x", (unsigned int)group->fa ); + verboseMes( " FAadr: %08x", (long)group->fa ); group = group->next; } } int cmpFAlist( FALIST *group1, FALIST *group2 ) { - int cmp; + long cmp; while( 1 ){ if( group1 == NULL && group2 == NULL ) return( 0 ); if( group1 == NULL ) return( -1 ); if( group2 == NULL ) return( 1 ); - cmp = (int)group1->fa - (int)group2->fa; + cmp = (long)group1->fa - (long)group2->fa; if( cmp != 0 ) return( cmp ); group1 = group1->next; group2 = group2->next;