sumom****@users*****
sumom****@users*****
2011年 5月 13日 (金) 17:38:34 JST
Index: julius4/libjulius/src/adin-cut.c diff -u julius4/libjulius/src/adin-cut.c:1.16 julius4/libjulius/src/adin-cut.c:1.17 --- julius4/libjulius/src/adin-cut.c:1.16 Fri Apr 29 14:09:15 2011 +++ julius4/libjulius/src/adin-cut.c Fri May 13 17:38:34 2011 @@ -95,7 +95,7 @@ * @author Akinobu LEE * @date Sat Feb 12 13:20:53 2005 * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * */ /* @@ -162,12 +162,17 @@ /* calc & set internal parameter from configuration */ freq = jconf->input.sfreq; samples_in_msec = (float) freq / (float)1000.0; + adin->chunk_size = jconf->detect.chunk_size; /* cycle buffer length = head margin length */ adin->c_length = (int)((float)jconf->detect.head_margin_msec * samples_in_msec); /* in msec. */ + if (adin->chunk_size > adin->c_length) { + jlog("ERROR: adin_setup_param: chunk size (%d) > header margin (%d)\n", adin->chunk_size, adin->c_length); + return FALSE; + } /* compute zerocross trigger count threshold in the cycle buffer */ adin->noise_zerocross = jconf->detect.zero_cross_num * adin->c_length / freq; /* variables that comes from the tail margin length (in wstep) */ - adin->nc_max = (int)((float)(jconf->detect.tail_margin_msec * samples_in_msec / (float)DEFAULT_WSTEP)) + 2; + adin->nc_max = (int)((float)(jconf->detect.tail_margin_msec * samples_in_msec / (float)adin->chunk_size)) + 2; adin->sbsize = jconf->detect.tail_margin_msec * samples_in_msec + (adin->c_length * jconf->detect.zero_cross_num / 200); adin->c_offset = 0; @@ -493,7 +498,7 @@ /* prepare for processing samples in temporary buffer */ /******************************************************/ - wstep = DEFAULT_WSTEP; /* process unit (should be smaller than cycle buffer) */ + wstep = a->chunk_size; /* process unit (should be smaller than cycle buffer) */ /* imax: total length that should be processed at one ad_read() call */ /* if in real-time mode and not threaded, recognition process @@ -562,6 +567,10 @@ /* 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); + a->last_trigger_len = 0; + if (a->zc.valid_len > wstep) { + a->last_trigger_len += a->zc.valid_len - wstep; + } /****************************************/ /* flush samples stored in cycle buffer */ @@ -638,6 +647,10 @@ /* reset noise counter */ a->nc = 0; + if (a->sblen > 0) { + a->last_trigger_len += a->sblen; + } + #ifdef TMP_FIX_200602 if (ad_process != NULL #ifdef HAVE_PTHREAD @@ -771,6 +784,8 @@ jlog("DEBUG: %d processed, rest_tail=%d\n", wstep, a->rest_tail); #endif } + a->last_trigger_len += wstep; + #ifdef TMP_FIX_200602 if (ad_process != NULL #ifdef HAVE_PTHREAD @@ -1316,6 +1331,7 @@ if (debug2_flag && a->input_side_segment) jlog("Stat: adin_begin: skip\n"); if (a->input_side_segment == FALSE) { a->total_captured_len = 0; + a->last_trigger_len = 0; if (a->need_zmean) zmean_reset(); if (a->ad_begin != NULL) return(a->ad_begin(file_or_dev_name)); } Index: julius4/libjulius/src/default.c diff -u julius4/libjulius/src/default.c:1.13 julius4/libjulius/src/default.c:1.14 --- julius4/libjulius/src/default.c:1.13 Fri Apr 29 14:09:15 2011 +++ julius4/libjulius/src/default.c Fri May 13 17:38:34 2011 @@ -17,7 +17,7 @@ * @author Akinobu Lee * @date Fri Feb 16 15:05:43 2007 * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * */ /* @@ -77,6 +77,7 @@ j->detect.tail_margin_msec = 400; j->detect.zero_cross_num = 60; j->detect.silence_cut = 2; /* accept device default */ + j->detect.chunk_size = 1000; #ifdef GMM_VAD j->detect.gmm_margin = DEFAULT_GMM_MARGIN; j->detect.gmm_uptrigger_thres = 0.7; Index: julius4/libjulius/src/m_info.c diff -u julius4/libjulius/src/m_info.c:1.13 julius4/libjulius/src/m_info.c:1.14 --- julius4/libjulius/src/m_info.c:1.13 Fri Apr 29 14:09:15 2011 +++ julius4/libjulius/src/m_info.c Fri May 13 17:38:34 2011 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Thu May 12 14:14:01 2005 * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * */ /* @@ -878,6 +878,7 @@ jlog("\t zerocross thres = %d / sec.\n", jconf->detect.zero_cross_num); jlog("\t head margin = %d msec.\n", jconf->detect.head_margin_msec); jlog("\t tail margin = %d msec.\n", jconf->detect.tail_margin_msec); + jlog("\t chunk size = %d samples\n", jconf->detect.chunk_size); } else { jlog("\t silence cutting = off\n"); } Index: julius4/libjulius/src/m_options.c diff -u julius4/libjulius/src/m_options.c:1.24 julius4/libjulius/src/m_options.c:1.25 --- julius4/libjulius/src/m_options.c:1.24 Fri Apr 29 14:09:15 2011 +++ julius4/libjulius/src/m_options.c Fri May 13 17:38:34 2011 @@ -18,7 +18,7 @@ * @author Akinobu Lee * @date Thu May 12 18:52:07 2005 * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * */ /* @@ -615,6 +615,11 @@ GET_TMPARG; jconf->detect.tail_margin_msec = atoi(tmparg); continue; + } else if (strmatch(argv[i],"-chunksize")) { /* chunk size for detection */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; + GET_TMPARG; + jconf->detect.chunk_size = atoi(tmparg); + continue; } else if (strmatch(argv[i],"-hipass")||strmatch(argv[i],"-hifreq")) { /* frequency of upper band limit */ if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; Index: julius4/libjulius/src/m_usage.c diff -u julius4/libjulius/src/m_usage.c:1.15 julius4/libjulius/src/m_usage.c:1.16 --- julius4/libjulius/src/m_usage.c:1.15 Fri Apr 29 14:09:15 2011 +++ julius4/libjulius/src/m_usage.c Fri May 13 17:38:34 2011 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Fri May 13 15:04:34 2005 * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * */ /* @@ -127,6 +127,7 @@ fprintf(fp, " [-zc zerocrossnum] zerocross num threshold per sec. (%d)\n", jconf->detect.zero_cross_num); fprintf(fp, " [-headmargin msec] header margin length in msec. (%d)\n", jconf->detect.head_margin_msec); fprintf(fp, " [-tailmargin msec] tail margin length in msec. (%d)\n", jconf->detect.tail_margin_msec); + fprintf(fp, " [-chunksize sample] unit length for processing (%d)\n", jconf->detect.chunk_size); fprintf(fp, "\n GMM utterance verification:\n"); fprintf(fp, " -gmm filename GMM definition file\n"); Index: julius4/libjulius/src/recogmain.c diff -u julius4/libjulius/src/recogmain.c:1.18 julius4/libjulius/src/recogmain.c:1.19 --- julius4/libjulius/src/recogmain.c:1.18 Tue May 10 21:24:51 2011 +++ julius4/libjulius/src/recogmain.c Fri May 13 17:38:34 2011 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Wed Aug 8 14:53:53 2007 * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * */ @@ -983,6 +983,12 @@ } #endif + /* output segment status */ + if (recog->adin->adin_cut_on && (jconf->input.speech_input == SP_RAWFILE || jconf->input.speech_input == SP_STDIN)) { + seclen = (float)recog->adin->last_trigger_sample / (float)jconf->input.sfreq; + jlog("STAT: triggered: [%d..%d] %.2fs from %02d:%02d:%02.2f\n", recog->adin->last_trigger_sample, recog->adin->last_trigger_sample + recog->adin->last_trigger_len, (float)(recog->adin->last_trigger_len) / (float)jconf->input.sfreq, (int)(seclen / 3600), (int)(seclen / 60), seclen - (int)(seclen / 60) * 60); + } + /* execute callback for 1st pass result */ /* result.status <0 must be skipped inside callback */ callback_exec(CALLBACK_RESULT_PASS1, recog);