📄 spsegment.c
字号:
* input will be shrinked to the segmented length and the unprocessed * region are copied to rest_param for the next decoding. * * @param recog [in] engine instance * </EN> * @callgraph * @callergraph */voidfinalize_segment(Recog *recog){ int spstart; RecogProcess *r; MFCCCalc *mfcc; boolean ok_p; /* トレリス幌姜眉における呵锑帽胳を妈2パスの幌姜眉帽胳として呈羌 */ /* fix initial/last word hypothesis of the next 2nd pass to the best word hypothesis at the first/last frame in backtrellis*/ for(r=recog->process_list;r;r=r->next) { if (!r->live) continue; if (r->lmtype == LM_PROB) { set_terminal_words(r); } } /* パラメ〖タを, 海妈1パスが姜位したセグメント惰粗と荒りの惰粗に尸充する. ただし儡鲁婶のsp惰粗婶尸(sparea_start..len-1)は≈のりしろ∽として尉数に コピ〖する */ /* Divide input parameter into two: the last segment and the rest. The short-pause area (sparea_start..len-1) is considered as "tab", copied in both parameters */ /* param[sparea_start..framelen] -> rest_param param[0..len-1] -> param [sparea_start...len-1] overlapped */ ok_p = FALSE; for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { if (mfcc->segmented) { spstart = mfcc->sparea_start; ok_p = TRUE; break; } } if (ok_p) { /* the input was segmented in an instance */ /* shrink all param the len and store restart parameters in rest_param */ /* for each mfcc */ if (verbose_flag) jlog("STAT: segmented: next decoding will restart from %d\n", spstart); for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { if (verbose_flag) jlog("STAT: MFCC%02d: segmented: processed length=%d\n", mfcc->id, mfcc->last_time); /* copy the rest to mfcc->rest_param and shrink mfcc->param */ mfcc_copy_to_rest_and_shrink(mfcc, spstart, mfcc->last_time); } /* reset last_word info */ for(r=recog->process_list;r;r=r->next) { if (!r->live) continue; r->sp_break_last_nword_allow_override = TRUE; } } else { /* last segment is on end of input: no rest parameter */ for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { mfcc->rest_param = NULL; } /* reset last_word info */ for(r=recog->process_list;r;r=r->next) { if (!r->live) continue; r->sp_break_2_begin_word = WORD_INVALID; r->sp_break_last_word = WORD_INVALID; r->sp_break_last_nword = WORD_INVALID; r->sp_break_last_nword_allow_override = FALSE; } }}#ifdef BACKEND_VAD/** * <EN> * Initialize parameters for decoder/GMM-based VAD. * This will be called before recognition start for each segment. * </EN> * <JA> * Decode/GMM-based VAD のためにパラメ〖タを介袋步する. * 称掐蜗セグメントの千急借妄を幌める涟に钙ばれる. * </JA> * * @param recog [i/o] engine instance * * @callgraph * @callergraph */voidspsegment_init(Recog *recog){ RecogProcess *p; /* at first time, recognition does not start yet */#ifdef SPSEGMENT_NAIST for(p=recog->process_list;p;p=p->next) { p->pass1.after_trigger = FALSE; p->pass1.trigger_duration = 0; }#endif#ifdef GMM_VAD if (recog->gmm) { recog->gc->after_trigger = FALSE; recog->gc->duration = 0; }#endif recog->triggered = FALSE;}/** * <EN> * @brief Detect speech up-trigger and synhronize among instances. * * This function inspects all recognition instancces and gmm components * to see if any of them has detected trigger up (beginning of speech) * at the last recognition process. If trigger has been detected, * set trigger-up status for all the instances. * </EN> * <JA> * @brief 不兰惰粗倡幌の浮叫およびインスタンス粗票袋. * * 链ての千急借妄インスタンスとGMM借妄婶について·木涟の千急借妄で * トリガアップ∈不兰惰粗倡幌∷が冉年されたかどうかを拇べる. * 倡幌された眷圭は·链ての千急借妄インスタンスでアップトリガをマ〖クする. * </JA> * * @param recog [in] engine instance * * @return TRUE if triggered, or FALSE if not. * * @callgraph * @callergraph */booleanspsegment_trigger_sync(Recog *recog){ RecogProcess *p; boolean ok_p; ok_p = FALSE; if (recog->jconf->decodeopt.segment) {#ifdef SPSEGMENT_NAIST for(p = recog->process_list; p; p = p->next) { if (!p->live) continue; if (p->pass1.after_trigger) { ok_p = TRUE; break; } }#endif#ifdef GMM_VAD if (recog->gmm) { if (recog->gc->after_trigger) { ok_p = TRUE; } }#endif } if (ok_p) { /* up trigger detected */#ifdef SPSEGMENT_NAIST for(p = recog->process_list; p; p = p->next) { if (!p->live) continue; p->pass1.after_trigger = TRUE; }#endif#ifdef GMM_VAD if (recog->gmm) { recog->gc->after_trigger = TRUE; }#endif } return ok_p;}#endif /* BACKEND_VAD *//** * <EN> * @brief Check if rewind and restart of recognition is needed. * * This function checks if an instance requires rewinding of input * samples, and if recognition re-processing is needed after rewinding. * * </EN> * <JA> * @brief 船き提しと千急浩倡の涩妥拉をチェックする. * * 不兰千急借妄において船き提しが涩妥がどうか拇べ·涩妥な眷圭は * フレ〖ム眶と·船き提した稿に船提し尸の千急借妄を乖うかどうかを手す. * </JA> * * @param recog [in] engine instance * @param rf_ret [out] length of frame to rewind * @param repro_ret [out] TRUE if re-process is required after rewinding * * @return TRUE if rewinding is required, or FALSE if not. * * @callgraph * @callergraph */booleanspsegment_need_restart(Recog *recog, int *rf_ret, boolean *repro_ret){#ifdef SPSEGMENT_NAIST RecogProcess *p;#endif boolean ok_p; int rewind_frame; boolean reprocess; ok_p = FALSE; if (recog->jconf->decodeopt.segment) {#ifdef SPSEGMENT_NAIST /* check for rewind request from each process */ for(p = recog->process_list; p; p = p->next) { if (!p->live) continue; if (p->pass1.want_rewind) { p->pass1.want_rewind = FALSE; rewind_frame = p->pass1.rewind_frame; reprocess = p->pass1.want_rewind_reprocess; ok_p = TRUE; break; } }#endif /* SPSEGMENT_NAIST */#ifdef GMM_VAD if (recog->gmm) { if (recog->gc->want_rewind) { recog->gc->want_rewind = FALSE;#ifdef SPSEGMENT_NAIST /* set to earlier one */ if (rewind_frame > recog->gc->rewind_frame) rewind_frame = recog->gc->rewind_frame;#else rewind_frame = recog->gc->rewind_frame;#endif reprocess = recog->gc->want_rewind_reprocess; ok_p = TRUE; } }#endif *rf_ret = rewind_frame; *repro_ret = reprocess; } return(ok_p);}/** * <EN> * @brief Execute rewinding. * * This function will set re-start point for the following processing, * and shrink the parameters for the rewinded part. The re-start point * is 0 (beginning of rest samples) for recognition restart, or * simply go back to the specified rewind frames for non restart. * * </EN> * <JA> * @brief 船き提し借妄 * * 肌搀の掐蜗借妄の倡幌爬を疯年し·船き提し尸パラメ〖タを低める. * 浩倡回年の眷圭倡幌爬はパラメ〖タの黎片に·それ笆嘲の眷圭は船提した * 尸だけ提った疤弥にセットされる. * * </JA> * * @param recog [i/o] engine instance * @param rewind_frame [in] frame length to rewind * @param reprocess [in] TRUE if re-processing recognition is required for the following processing * * @callgraph * @callergraph */voidspsegment_restart_mfccs(Recog *recog, int rewind_frame, boolean reprocess){ MFCCCalc *mfcc; for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { if (!mfcc->valid) continue; /* set last segmented time */ mfcc->last_time = mfcc->f - 1; /* reset frame pointers */ if (reprocess) { /* set all mfcc to initial point for re-process the whole frames */ mfcc->f = -1; } else { /* just bring back to the new last point after shrink */ mfcc->f -= rewind_frame; } /* shrink the current mfcc */ mfcc_shrink(mfcc, rewind_frame); }}/* end of file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -