📄 spsegment.c
字号:
if (debug2_flag) { jlog("DEBUG: pause exceeded %d, rewind\n", SPSEGMENT_NAIST_AUTOSHRINK_LIMIT); } return FALSE; } /* keep going */ d->want_rewind = FALSE; } else { /************************/ /* this is speech frame */ /************************/ /* increment trigger duration */ d->trigger_duration++; /* if not enough duration, not treat as up trigger */ if (d->trigger_duration < r->config->successive.sp_delay) { /* just continue detection */ return FALSE; } /***************************/ /* found speech up-trigger */ /***************************/ /* set backstep point */ if (r->am->mfcc->f < r->config->successive.sp_margin) { startframe = 0; } else { startframe = r->am->mfcc->f - r->config->successive.sp_margin; } if (debug2_flag) { jlog("DEBUG: speech triggered\n"); jlog("DEBUG: word=[%s] dur=%d\n", r->lm->winfo->woutput[wid], d->trigger_duration); jlog("DEBUG: backstep behind %d (from %d to %d) frame and start process\n", r->config->successive.sp_margin, r->am->mfcc->f, startframe); } /* if the pause segment was short, keep the context of last segment. else, reset the context */ if (r->lmtype == LM_PROB) { if (startframe > 0) { r->sp_break_last_word = WORD_INVALID; } } /* reset sp duration */ d->sp_duration = 0; /* request the caller to rewind the search to the backstep point and re-start with normal search */ d->want_rewind = TRUE; d->rewind_frame = startframe; d->want_rewind_reprocess = TRUE; /* this will enter to normal search in the next processing */ d->after_trigger = TRUE; } /* tell the caller not to segment */ return FALSE; }#endif /* SPSEGMENT_NAIST */ /* look for the best trellis word on the given time frame */ for(tre = r->backtrellis->list; tre != NULL && tre->endtime == time; tre = tre->next) { if (maxscore < tre->backscore) { maxscore = tre->backscore; tremax = tre; } count++; } if (tremax == NULL) { /* no word end: possible in the very beggining of input*/ detected = TRUE; /* assume it's in the short-pause duration */ } else if (count > 0) { /* many words found --- check if maximum is sp */ if (is_sil(tremax->wid, r)) { detected = TRUE; } }#ifdef SPSEGMENT_NAIST /************************************************************************/ /************************************************************************/ /* detected = TRUE if noise frame, or FALSE if speech frame */ /* sp惰粗积鲁チェック */ /* check sp segment duration */ if (d->first_sparea) { /* we are in the first sp segment */ if (d->in_sparea && detected) { /* sp continues */ d->sp_duration++; /* when sp continues more than -spdur plus -spmargin, it means that although a speech trigger has been detected by some reason, no actual speech has been found at first. */ /* in this case we force trigger to end this input */ if (d->sp_duration > r->config->successive.sp_delay + r->config->successive.sp_margin + r->config->successive.sp_frame_duration) { d->in_sparea = FALSE; d->first_sparea = FALSE; if (debug2_flag) { jlog("DEBUG: no valid speech starts, force trigger at %d\n", r->am->mfcc->f); } } } else if (d->in_sparea && !detected) { /* found speech frame */ d->in_sparea = FALSE; d->first_sparea = FALSE; if (debug2_flag) { jlog("DEBUG: speech segment start at %d\n", r->am->mfcc->f); } } } else { /* we are either in speech segment, or trailing sp segment */ if (!d->in_sparea) { /* we are in speech segment */ if (detected) { /* detected end of speech segment (begin of sp segment) */ /* 办箕弄に倡幌フレ〖ムとしてマ〖ク */ /* mark this frame as "temporal" begging of short-pause segment */ d->tmp_sparea_start = time;#ifdef SP_BREAK_RESUME_WORD_BEGIN if (r->lmtype == LM_PROB) { /* sp 惰粗倡幌箕爬の呵锑帽胳を瘦赂 */ /* store the best word in this frame as resuming word */ d->tmp_sp_break_last_word = tremax ? tremax->wid : WORD_INVALID; }#endif d->in_sparea = TRUE; d->sp_duration = 1; } else { /* speech continues */ /* keep recognizing */ } } else { /* we are in trailing sp segment */ if (detected) { /* short pause frame continues */ d->sp_duration++; /* keep word as the "beggining" of next sp segment */ if (r->lmtype == LM_PROB) {#ifdef SP_BREAK_RESUME_WORD_BEGIN /* if this segment has triggered by (tremax == NULL) (in case the first several frame of input), the sp word (to be used as resuming word in the next segment) is not yet set. it will be detected here */ if (d->tmp_sp_break_last_word == WORD_INVALID) { if (tremax != NULL) d->tmp_sp_break_last_word = tremax->wid; }#else /* resume word at the "end" of sp segment */ /* simply update the best sp word */ if (tremax != NULL) d->last_tre_word = tremax->wid;#endif } if (d->sp_duration >= r->config->successive.sp_frame_duration) { /* silence over, segment the recognition here */ /* store begging frame of the segment */ //d->sparea_start = d->tmp_sparea_start; r->am->mfcc->sparea_start = time - r->config->successive.sp_frame_duration; if (r->lmtype == LM_PROB) {#ifdef SP_BREAK_RESUME_WORD_BEGIN /* resume word = most likely sp word on beginning frame of the segment */ r->sp_break_last_word = d->tmp_sp_break_last_word;#else /* resume word = most likely sp word on end frame of the segment */ r->sp_break_last_word = d->last_tre_word;#endif } if (debug2_flag) { jlog("DEBUG: trailing silence end, end this segment at %d\n", r->am->mfcc->f); } d->after_trigger = FALSE; d->trigger_duration = 0; d->want_rewind = FALSE; /*** segment: [sparea_start - time-1] ***/ return(TRUE); } /* else, keep recognition */ } else { /* speech re-triggered */ /* keep recognition */ d->in_sparea = FALSE; } } } d->want_rewind = FALSE;#else /* ~SPSEGMENT_NAIST */ /************************************************************************/ /************************************************************************/ /* sp惰粗积鲁チェック */ /* check sp segment duration */ if (d->in_sparea && detected) { /* we are already in sp segment and sp continues */ d->sp_duration++; /* increment count */#ifdef SP_BREAK_RESUME_WORD_BEGIN /* resume word at the "beggining" of sp segment */ /* if this segment has triggered by (tremax == NULL) (in case the first several frame of input), the sp word (to be used as resuming word in the next segment) is not yet set. it will be detected here */ if (d->tmp_sp_break_last_word == WORD_INVALID) { if (tremax != NULL) d->tmp_sp_break_last_word = tremax->wid; }#else /* resume word at the "end" of sp segment */ /* simply update the best sp word */ if (tremax != NULL) d->last_tre_word = tremax->wid;#endif } /* sp惰粗倡幌チェック */ /* check if sp segment begins at this frame */ else if (!d->in_sparea && detected) { /* 办箕弄に倡幌フレ〖ムとしてマ〖ク */ /* mark this frame as "temporal" begging of short-pause segment */ d->tmp_sparea_start = time;#ifdef SP_BREAK_RESUME_WORD_BEGIN /* sp 惰粗倡幌箕爬の呵锑帽胳を瘦赂 */ /* store the best word in this frame as resuming word */ d->tmp_sp_break_last_word = tremax ? tremax->wid : WORD_INVALID;#endif d->in_sparea = TRUE; /* yes, we are in sp segment */ d->sp_duration = 1; /* initialize duration count */#ifdef SP_BREAK_DEBUG jlog("DEBUG: sp start %d\n", time);#endif /* SP_BREAK_DEBUG */ } /* sp 惰粗姜位チェック */ /* check if sp segment ends at this frame */ else if (d->in_sparea && !detected) { /* (time-1) is end frame of pause segment */ d->in_sparea = FALSE; /* we are not in sp segment */#ifdef SP_BREAK_DEBUG jlog("DEBUG: sp end %d\n", time);#endif /* SP_BREAK_DEBUG */ /* sp 惰粗墓チェック */ /* check length of the duration*/ if (d->sp_duration < r->config->successive.sp_frame_duration) { /* 没すぎる: 妈1パスを面们せず鲁乖 */ /* too short segment: not break, continue 1st pass */#ifdef SP_BREAK_DEBUG jlog("DEBUG: too short (%d<%d), ignored\n", d->sp_duration, r->config->successive.sp_frame_duration);#endif /* SP_BREAK_DEBUG */ } else if (d->first_sparea) { /* 呵介のsp惰粗は silB にあたるので,妈1パスを面们せず鲁乖 */ /* do not break at first sp segment: they are silB */ d->first_sparea = FALSE;#ifdef SP_BREAK_DEBUG jlog("DEBUG: first silence, ignored\n");#endif /* SP_BREAK_DEBUG */ } else { /* 惰粗姜位澄年, 妈1パスを面们して妈2パスへ */ /* break 1st pass */#ifdef SP_BREAK_DEBUG jlog("DEBUG: >> segment [%d..%d]\n", r->am->mfcc->sparea_start, time-1);#endif /* SP_BREAK_DEBUG */ /* store begging frame of the segment */ r->am->mfcc->sparea_start = d->tmp_sparea_start;#ifdef SP_BREAK_RESUME_WORD_BEGIN /* resume word = most likely sp word on beginning frame of the segment */ r->sp_break_last_word = d->tmp_sp_break_last_word;#else /* resume word = most likely sp word on end frame of the segment */ r->sp_break_last_word = d->last_tre_word;#endif /*** segment: [sparea_start - time-1] ***/ return(TRUE); } }#endif /* ~SPSEGMENT_NAIST */ #ifdef SP_BREAK_EVAL jlog("DEBUG: [%d %d %d]\n", time, count, (detected) ? 50 : 0);#endif return (FALSE);}/*******************************************************************//* 妈1パスセグメント姜位借妄 (ショ〖トポ〖ズセグメンテ〖ション脱) *//* end of 1st pass for a segment (for short pause segmentation) *//*******************************************************************//** * <JA> * @brief 绵肌デコ〖ディングのための妈1パス姜位箕の借妄 * * 绵肌デコ〖ディング蝗脱箕·この簇眶は finalize_1st_pass() 稿に钙ばれ· * そのセグメントの妈1パスの姜位借妄を乖う. 恶挛弄には· * 鲁く妈2パスのための幌姜眉帽胳のセット·および * 肌搀デコ〖ディングを浩倡するときのために·掐蜗ベクトル误の踏借妄婶尸の * コピ〖を rest_param に荒す. * * @param recog [in] エンジンインスタンス * </JA> * <EN> * @brief Finalize the first pass for successive decoding * * When successive decoding mode is enabled, this function will be * called just after finalize_1st_pass() to finish the beam search * of the last segment. The beginning and ending words for the 2nd pass * will be set according to the 1st pass result. Then the current
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -