📄 pass1.c
字号:
* </JA> * * @param recog [in] engine instance * * @callgraph * @callergraph */voiddecode_end_segmented(Recog *recog){ boolean ok_p; int mseclen; RecogProcess *p; int last_status; /* rejectshort 回年箕, 掐蜗が没ければここで妈1パス冯蔡を叫蜗しない */ /* suppress 1st pass output if -rejectshort and input shorter than specified */ ok_p = TRUE; if (recog->jconf->reject.rejectshortlen > 0) { mseclen = (float)recog->mfcclist->last_time * (float)recog->jconf->input.period * (float)recog->jconf->input.frameshift / 10000.0; if (mseclen < recog->jconf->reject.rejectshortlen) { last_status = J_RESULT_STATUS_REJECT_SHORT; ok_p = FALSE; } }#ifdef POWER_REJECT if (ok_p) { if (power_reject(recog)) { last_status = J_RESULT_STATUS_REJECT_POWER; ok_p = FALSE; } }#endif if (ok_p) { for(p=recog->process_list;p;p=p->next) { if (!p->live) continue; finalize_1st_pass(p, p->am->mfcc->last_time); } } else { for(p=recog->process_list;p;p=p->next) { if (!p->live) continue; p->result.status = last_status; } } if (recog->jconf->decodeopt.segment) { finalize_segment(recog); } if (recog->gmm != NULL) { /* GMM 纷换の姜位 */ gmm_end(recog); }}/** * <EN> * @brief End procedure of the first pass * * This function finish the first pass, when the input was fully * processed to the end. * * The best path at each recognition process instance will be parsed * and stored. In case of recognition error or input rejection, the * error status will be set. * * </EN> * <JA> * @brief 妈1パスの姜位借妄 * * 掐蜗が呵稿まで借妄されて姜位したときに·妈1パスの千急借妄を * 姜位させる. * * 称千急借妄インスタンスに滦して·その箕爬での妈1パスの呵锑帽胳 * 废误を呈羌する. また·千急己窃ˇ掐蜗逮笛の箕はエラ〖ステ〖タスをそ * れぞれセットする. * * </JA> * * @param recog [in] engine instance * * @callgraph * @callergraph */voiddecode_end(Recog *recog){ MFCCCalc *mfcc; int mseclen; boolean ok_p; RecogProcess *p; int last_status; for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { mfcc->segmented = FALSE; } if (recog->gmm != NULL) { /* GMM 纷换の姜位 */ gmm_end(recog); }#ifdef GMM_VAD /* もしトリガがかからないまま掐蜗姜位に茫したのなら·そのままエラ〖姜位 */ if (recog->jconf->decodeopt.segment) { if (recog->gmm) { if (recog->gc->after_trigger == FALSE) { for(p=recog->process_list;p;p=p->next) { p->result.status = J_RESULT_STATUS_ONLY_SILENCE; /* reject by decoding */ } /* ショ〖トポ〖ズセグメンテ〖ションの眷圭, 掐蜗パラメ〖タ尸充などの呵姜借妄も乖なう */ /* When short-pause segmentation enabled */ finalize_segment(recog); return; } } }#endif /* 妈1パスの呵稿のフレ〖ムの千急借妄を乖う */ /* finalize 1st pass */ for(p=recog->process_list;p;p=p->next) { if (!p->live) continue;#ifdef SPSEGMENT_NAIST if (recog->jconf->decodeopt.segment) { if (p->pass1.after_trigger == FALSE) continue; }#endif mfcc = p->am->mfcc; if (mfcc->f > 0) { get_back_trellis_end(mfcc->param, p); } } /* 姜位借妄 */ for(p=recog->process_list;p;p=p->next) { if (!p->live) continue; ok_p = TRUE; /* check rejection by no input */ if (ok_p) { mfcc = p->am->mfcc; /* 掐蜗墓がデルタの纷换に浇尸でない眷圭·掐蜗痰しとするˉ */ /* if input is short for compute all the delta coeff., terminate here */ if (mfcc->f == 0) { jlog("STAT: no input frame\n"); last_status = J_RESULT_STATUS_FAIL; ok_p = FALSE; } } /* check rejection by input length */ if (ok_p) { if (recog->jconf->reject.rejectshortlen > 0) { mseclen = (float)mfcc->param->samplenum * (float)recog->jconf->input.period * (float)recog->jconf->input.frameshift / 10000.0; if (mseclen < recog->jconf->reject.rejectshortlen) { last_status = J_RESULT_STATUS_REJECT_SHORT; ok_p = FALSE; } } }#ifdef POWER_REJECT /* check rejection by average power */ if (ok_p) { if (power_reject(recog)) { last_status = J_RESULT_STATUS_REJECT_POWER; ok_p = FALSE; } }#endif#ifdef SPSEGMENT_NAIST /* check rejection non-triggered input segment */ if (ok_p) { if (recog->jconf->decodeopt.segment) { if (p->pass1.after_trigger == FALSE) { last_status = J_RESULT_STATUS_ONLY_SILENCE; /* reject by decoding */ ok_p = FALSE; } } }#endif if (ok_p) { /* valid input segment, finalize it */ finalize_1st_pass(p, mfcc->param->samplenum); } else { /* invalid input segment */ p->result.status = last_status; } } if (recog->jconf->decodeopt.segment) { /* ショ〖トポ〖ズセグメンテ〖ションの眷圭, 掐蜗パラメ〖タ尸充などの呵姜借妄も乖なう */ /* When short-pause segmentation enabled */ finalize_segment(recog); }}/** * <JA> * @brief フレ〖ム票袋ビ〖ム玫瑚メイン簇眶∈バッチ借妄脱∷ * * 涂えられた掐蜗ベクトル误に滦して妈1パス(フレ〖ム票袋ビ〖ム玫瑚)を * 乖い·その冯蔡を叫蜗する. また链フレ〖ムに畔る帽胳姜眉を·妈2パス * のために帽胳トレリス菇陇挛に呈羌する. * * この簇眶は掐蜗ベクトル误があらかじめ评られている眷圭に脱いられる. * 妈1パスが掐蜗と事误して悸乖されるオンライン千急の眷圭· * この簇眶は脱いられず·洛わりにこのファイルで年盗されている称サブ簇眶が * 木儡 realtime-1stpass.c 柒から钙ばれる. * * @param recog [in] エンジンインスタンス * </JA> * <EN> * @brief Frame synchronous beam search: the main (for batch mode) * * This function perform the 1st recognition pass of frame-synchronous beam * search and output the result. It also stores all the word ends in every * input frame to word trellis structure. * * This function will be called if the whole input vector is already given * to the end. When online recognition, where the 1st pass will be * processed in parallel with input, this function will not be used. * In that case, functions defined in this file will be directly called * from functions in realtime-1stpass.c. * * @param recog [in] engine instance * </EN> * @callgraph * @callergraph */booleanget_back_trellis(Recog *recog){ boolean ok_p; MFCCCalc *mfcc; int rewind_frame; PROCESS_AM *am; boolean reprocess; /* initialize mfcc instances */ for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { /* mark all as valid, since all frames are fully prepared beforehand */ if (mfcc->param->samplenum == 0) mfcc->valid = FALSE; else mfcc->valid = TRUE; /* set frame pointers to 0 */ mfcc->f = 0; } /* callback of process start */#ifdef BACKEND_VAD if (recog->jconf->decodeopt.segment) { /* at first time, recognition does not start yet */ /* reset segmentation flags */ spsegment_init(recog); } else { /* execute callback for pass1 begin here */ callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); recog->triggered = TRUE; }#else if (recog->jconf->decodeopt.segment) { if (!recog->process_segment) { callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); } callback_exec(CALLBACK_EVENT_SEGMENT_BEGIN, recog); } else { callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); } callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); recog->triggered = TRUE;#endif while(1) { ok_p = TRUE; for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { if (! mfcc->valid) continue; if (mfcc->f < mfcc->param->samplenum) { mfcc->valid = TRUE; ok_p = FALSE; } else { mfcc->valid = FALSE; } } if (ok_p) { /* すべての MFCC が姜わりに茫したのでル〖プ姜位 */ /* all MFCC has been processed, end of loop */ break; } switch (decode_proceed(recog)) { case -1: /* error */ return FALSE; break; case 0: /* success */ break; case 1: /* segmented */ /* 玫瑚面们: 借妄された掐蜗は 0 から t-2 まで */ /* search terminated: processed input = [0..t-2] */ /* この箕爬で妈1パスを姜位する */ /* end the 1st pass at this point */ decode_end_segmented(recog); /* terminate 1st pass here */ return TRUE; }#ifdef BACKEND_VAD /* check up trigger in case of VAD segmentation */ if (recog->jconf->decodeopt.segment) { if (recog->triggered == FALSE) { if (spsegment_trigger_sync(recog)) { if (!recog->process_segment) { callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); } callback_exec(CALLBACK_EVENT_SEGMENT_BEGIN, recog); callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); recog->triggered = TRUE; } } }#endif if (spsegment_need_restart(recog, &rewind_frame, &reprocess) == TRUE) { /* do rewind for all mfcc here */ spsegment_restart_mfccs(recog, rewind_frame, reprocess); /* reset outprob cache for all AM */ for(am=recog->amlist;am;am=am->next) { outprob_prepare(&(am->hmmwrk), am->mfcc->param->samplenum); } } /* call frame-wise callback */ callback_exec(CALLBACK_EVENT_PASS1_FRAME, recog); /* 1フレ〖ム借妄が渴んだのでポインタを渴める */ /* proceed frame pointer */ for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { if (!mfcc->valid) continue; mfcc->f++; } if (recog->process_want_terminate) { /* termination requested */ decode_end_segmented(recog); return TRUE; } } /* 呵姜フレ〖ム借妄を乖い·千急の冯蔡叫蜗と姜位借妄を乖う */ decode_end(recog); return TRUE;}/* end of file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -