⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search_bestfirst_v1.c

📁 julius version 4.12.about sound recognition.
💻 C
📖 第 1 页 / 共 4 页
字号:
    if (ccd_flag) {      now->tail_g_score = now->g[now->bestt];    }  }#endif  /* ----------------------- do scan ----------------------- */    /* scan倡幌爬を浮瑚 -> starttへ*/  /* search for the start frame -> set to startt */  for(t = peseqlen-1; t >=0 ; t--) {    if (#ifdef SCAN_BEAM	dwrk->g[t] > framemaxscore[t] - scan_beam_thres &&#endif	dwrk->g[t] > LOG_ZERO) {      break;    }  }  if (t < 0) {			/* no node has score > LOG_ZERO */    for(t=0;t<peseqlen;t++) {      if (ccd_flag) now->g_prev[t] = LOG_ZERO;      now->g[t] = LOG_ZERO;    }#ifdef GRAPHOUT_PRECISE_BOUNDARY    if (r->graphout) {      for(t=0;t<peseqlen;t++) {	now->wordend_frame[t] = -1;	now->wordend_gscore[t] = LOG_ZERO;      }    }#endif    goto end_of_scan;  }  startt = t;    /* clear [startt+1..peseqlen-1] */  for(t=peseqlen-1;t>startt;t--) {    if (ccd_flag) now->g_prev[t] = LOG_ZERO;    now->g[t] = LOG_ZERO;#ifdef GRAPHOUT_PRECISE_BOUNDARY    if (r->graphout) {      now->wordend_frame[t] = -1;      now->wordend_gscore[t] = LOG_ZERO;    }#endif  }  /* バッファポインタ介袋步 */  tn = 0; tl = 1;#ifdef GRAPHOUT_PRECISE_BOUNDARY  if (r->graphout) {    for(i=0;i<wordhmmnum;i++) {      dwrk->wend_token_frame[tn][i] = -1;      dwrk->wend_token_gscore[tn][i] = LOG_ZERO;    }  }#endif    if (! hmminfo->multipath) {    /* Below initialization is not needed on multipath version, since       the actual viterbi will begin at frame 0 in multipath mode in main loop */        /* 箕粗 [startt] 惧の猛を介袋步 */    /* initialize scores on frame [startt] */    for(i=0;i<wordhmmnum-1;i++) dwrk->wordtrellis[tn][i] = LOG_ZERO;    dwrk->wordtrellis[tn][wordhmmnum-1] = dwrk->g[startt] + outprob(&(r->am->hmmwrk), startt, &(whmm->state[wordhmmnum-1]), param);    if (ccd_flag) {      now->g_prev[startt] = dwrk->wordtrellis[tn][store_point];    }    now->g[startt] = dwrk->wordtrellis[tn][0];    #ifdef GRAPHOUT_PRECISE_BOUNDARY    if (r->graphout) {      if (ccd_flag) {	if (back_rescan) {	  if (wordhmmnum-1 == crossword_point) {	    dwrk->wend_token_frame[tn][wordhmmnum-1] = startt;	    dwrk->wend_token_gscore[tn][wordhmmnum-1] = dwrk->g[startt];	  } else {	    dwrk->wend_token_frame[tn][wordhmmnum-1] = -1;	    dwrk->wend_token_gscore[tn][wordhmmnum-1] = LOG_ZERO;	  }	} else {	  dwrk->wend_token_frame[tn][wordhmmnum-1] = startt;	  dwrk->wend_token_gscore[tn][wordhmmnum-1] = dwrk->g[startt];	}      } else {	dwrk->wend_token_frame[tn][wordhmmnum-1] = startt;	dwrk->wend_token_gscore[tn][wordhmmnum-1] = dwrk->g[startt];      }      now->wordend_frame[startt] = dwrk->wend_token_frame[tn][0];      now->wordend_gscore[startt] = dwrk->wend_token_gscore[tn][0];    }#endif  } /* end of hmminfo->multipath */    endt = startt;  /* メインル〖プ: startt から幌まり 0 に羹かって Viterbi 纷换 */  /* main loop: start from [startt], and compute Viterbi toward [0] */  for(t = hmminfo->multipath ? startt : startt - 1; t >= 0; t--) {        /* wordtrellisのワ〖クエリアをスワップ */    i = tn; tn = tl; tl = i;        node_exist_p = FALSE;	/* TRUE if there is at least 1 survived node in this frame */    if (hmminfo->multipath) {      /* 眉のノ〖ド [t][wordhmmnum-1]は g[] を徊救する */      /* the edge node [t][wordhmmnum-1] is equal to g[] */      /* ノ〖ド [t][wordhmmnum-2..0] についてトレリスを纷换 */      /* expand trellis for node [t][wordhmmnum-2..0] */      tmpmax_store = LOG_ZERO;    } else {          /* 眉のノ〖ド [t][wordhmmnum-1]は·柒婶莲败 か g[]の光い数になる */      /* the edge node [t][wordhmmnum-1] is either internal transitin or g[] */      tmptmp = LOG_ZERO;      for (ac=whmm->state[wordhmmnum-1].ac;ac;ac=ac->next) {	score1 = dwrk->wordtrellis[tl][ac->arc] + ac->a;	if (tmptmp < score1) {	  j = ac->arc;	  tmptmp = score1;	}      }      if (dwrk->g[t] > tmptmp) {	tmpmax = dwrk->g[t];#ifdef GRAPHOUT_PRECISE_BOUNDARY	if (r->graphout) {	  if (!back_rescan || wordhmmnum-1 == crossword_point) {	    dwrk->wend_token_frame[tn][wordhmmnum-1] = t;	    dwrk->wend_token_gscore[tn][wordhmmnum-1] = dwrk->g[t];	  } else {	    dwrk->wend_token_frame[tn][wordhmmnum-1] = dwrk->wend_token_frame[tl][j];	    dwrk->wend_token_gscore[tn][wordhmmnum-1] = dwrk->wend_token_gscore[tl][j];	  }	}#endif      } else {	tmpmax = tmptmp;#ifdef GRAPHOUT_PRECISE_BOUNDARY	if (r->graphout) {	  dwrk->wend_token_frame[tn][wordhmmnum-1] = dwrk->wend_token_frame[tl][j];	  dwrk->wend_token_gscore[tn][wordhmmnum-1] = dwrk->wend_token_gscore[tl][j];	}#endif      }      /* 眉のノ〖ドのスコアエンベロ〖プチェック: 办年升嘲なら皖とす */      /* check if the edge node is within score envelope */      if (#ifdef SCAN_BEAM	  tmpmax <= framemaxscore[t] - scan_beam_thres ||#endif	  tmpmax <= LOG_ZERO	  ) {	dwrk->wordtrellis[tn][wordhmmnum-1] = LOG_ZERO;#ifdef GRAPHOUT_PRECISE_BOUNDARY	if (r->graphout) {	  dwrk->wend_token_frame[tn][wordhmmnum-1] = -1;	  dwrk->wend_token_gscore[tn][wordhmmnum-1] = LOG_ZERO;	}#endif      } else {	node_exist_p = TRUE;	dwrk->wordtrellis[tn][wordhmmnum-1] = tmpmax + outprob(&(r->am->hmmwrk), t, &(whmm->state[wordhmmnum-1]), param);      }    } /* end of ~multipath */    /* ノ〖ド [t][wordhmmnum-2..0] についてトレリスを纷换 */    /* expand trellis for node [t][wordhmmnum-2..0] */    for(i=wordhmmnum-2;i>=0;i--) {      if (ccd_flag) {	/* 呵锑パスと呵锑スコア tmpmax を斧つける */	/* tmpmax2 は肌搀脱 g_prev[] のための呵络猛(极甘莲败を近いた呵络猛) */	/* find most likely path and the max score 'tmpmax' */	/* 'tmpmax2' is max score excluding self transition, for next g_prev[] */	if (! hmminfo->multipath) {	  if (i == store_point) {	    tmpmax2 = LOG_ZERO;	  }	}	tmpmax = LOG_ZERO;	for (ac=whmm->state[i].ac;ac;ac=ac->next) {	  if (hmminfo->multipath) {	    if (ac->arc == wordhmmnum-1) score1 = dwrk->g[t];	    else if (t + 1 > startt) score1 = LOG_ZERO;	    else score1 = dwrk->wordtrellis[tl][ac->arc];	    score1 += ac->a;	  } else {	    score1 = dwrk->wordtrellis[tl][ac->arc] + ac->a;	  }	  if (i <= crossword_point && ac->arc > crossword_point) {	    /* これは帽胳を臂える莲败 (backscan 悸乖箕) */	    /* this is a transition across word (when backscan is enabled) */	    score1 += now->lscore; /* add LM score */	  }	  if (hmminfo->multipath) {	    if (i <= store_point && ac->arc > store_point) {	      if (tmpmax_store < score1) tmpmax_store = score1;	    }	  } else {	    if (i == store_point && i != ac->arc) {	      if (tmpmax2 < score1) tmpmax2 = score1;	    }	  }	  if (tmpmax < score1) {	    tmpmax = score1;	    j = ac->arc;	  }	}	/* スコアエンベロ〖プチェック: 办年升嘲なら皖とす */	/* check if score of this node is within the score envelope */	if (#ifdef SCAN_BEAM	    tmpmax <= framemaxscore[t] - scan_beam_thres ||#endif	    tmpmax <= LOG_ZERO	    ) {  /* invalid node */	  dwrk->wordtrellis[tn][i] = LOG_ZERO;#ifdef GRAPHOUT_PRECISE_BOUNDARY	  if (r->graphout) {	    dwrk->wend_token_frame[tn][i] = -1;	    dwrk->wend_token_gscore[tn][i] = LOG_ZERO;	  }#endif	  if (! hmminfo->multipath) {	    if (i == store_point) now->g_prev[t] = LOG_ZERO;	  }	} else { /* survived node */	  if (! hmminfo->multipath) {	    if (i == store_point) now->g_prev[t] = tmpmax2;	  }#ifdef GRAPHOUT_PRECISE_BOUNDARY	  if (r->graphout) {	    if (hmminfo->multipath) {	      if ((back_rescan && i <= crossword_point && j > crossword_point)		  || j == wordhmmnum-1) {		dwrk->wend_token_frame[tn][i] = t;		dwrk->wend_token_gscore[tn][i] = tmpmax;	      } else {		dwrk->wend_token_frame[tn][i] = dwrk->wend_token_frame[tl][j];		dwrk->wend_token_gscore[tn][i] = dwrk->wend_token_gscore[tl][j];	      }	    } else {	      if (i <= crossword_point && j > crossword_point) {		dwrk->wend_token_frame[tn][i] = t;		dwrk->wend_token_gscore[tn][i] = tmpmax;	      } else {		dwrk->wend_token_frame[tn][i] = dwrk->wend_token_frame[tl][j];		dwrk->wend_token_gscore[tn][i] = dwrk->wend_token_gscore[tl][j];	      }	    }	  }#endif	  node_exist_p = TRUE;	/* at least one node survive in this frame */	  dwrk->wordtrellis[tn][i] = tmpmax;	  if (! hmminfo->multipath || i > 0) {	    /* compute output probability */	    dwrk->wordtrellis[tn][i] += outprob(&(r->am->hmmwrk), t, &(whmm->state[i]), param);	  }	}	      } else {			/* not triphone */	/* backscan 痰し: store_point, crossword_point は痰簇犯 */	/* no backscan: store_point, crossword_point ignored */	tmpmax = LOG_ZERO;	if (hmminfo->multipath) {	  for (ac=whmm->state[i].ac;ac;ac=ac->next) {	    if (ac->arc == wordhmmnum-1) score1 = dwrk->g[t];	    else if (t + 1 > startt) score1 = LOG_ZERO;	    else score1 = dwrk->wordtrellis[tl][ac->arc];	    score1 += ac->a;	    if (tmpmax < score1) {	      tmpmax = score1;	      j = ac->arc;	    }	  }	} else {	  for (ac=whmm->state[i].ac;ac;ac=ac->next) {	    score1 = dwrk->wordtrellis[tl][ac->arc] + ac->a;	    if (tmpmax < score1) {	      tmpmax = score1;	      j = ac->arc;	    }	  }	}	/* スコアエンベロ〖プチェック: 办年升嘲なら皖とす */	/* check if score of this node is within the score envelope */	if (#ifdef SCAN_BEAM	    tmpmax <= framemaxscore[t] - scan_beam_thres ||#endif	    tmpmax <= LOG_ZERO	    ) {	  /* invalid node */	  dwrk->wordtrellis[tn][i] = LOG_ZERO;#ifdef GRAPHOUT_PRECISE_BOUNDARY	  if (r->graphout) {	    dwrk->wend_token_frame[tn][i] = -1;	    dwrk->wend_token_gscore[tn][i] = LOG_ZERO;	  }#endif	} else {	  /* survived node */	  node_exist_p = TRUE;#ifdef GRAPHOUT_PRECISE_BOUNDARY	  if (r->graphout) {	    if (hmminfo->multipath) {	      if (j == wordhmmnum-1) {		dwrk->wend_token_frame[tn][i] = t;		dwrk->wend_token_gscore[tn][i] = tmpmax;	      } else {		dwrk->wend_token_frame[tn][i] = dwrk->wend_token_frame[tl][j];		dwrk->wend_token_gscore[tn][i] = dwrk->wend_token_gscore[tl][j];	      }	    } else {	      dwrk->wend_token_frame[tn][i] = dwrk->wend_token_frame[tl][j];	      dwrk->wend_token_gscore[tn][i] = dwrk->wend_token_gscore[tl][j];	    }	  }#endif	  /* score of node [t][i] has been determined here */	  dwrk->wordtrellis[tn][i] = tmpmax;	  if (! hmminfo->multipath || i > 0) {	    dwrk->wordtrellis[tn][i] += outprob(&(r->am->hmmwrk), t, &(whmm->state[i]), param);	  }	}	      }    } /* end of node loop */    /* 箕粗 t のViterbi纷换姜位. 涟羹きスコアはscanした帽胳の幌眉 */    /* Viterbi end for frame [t].  the forward score is the score of word       beginning scanned */    now->g[t] = dwrk->wordtrellis[tn][0];#ifdef GRAPHOUT_PRECISE_BOUNDARY    if (r->graphout) {      now->wordend_frame[t] = dwrk->wend_token_frame[tn][0];      now->wordend_gscore[t] = dwrk->wend_token_gscore[tn][0];    }#endif    if (hmminfo->multipath) {      /* triphone 箕, 肌檬のために store_point のデ〖タをg_prevに瘦赂 */      /* store the scores crossing the store_point to g_prev, for next scan */      if (ccd_flag) {	/* the max arc crossing the store_point always selected as tmpmax_score */ 	tmpmax_store -= store_point_maxarc;	if (tmpmax_store < LOG_ZERO) tmpmax_store = LOG_ZERO;	now->g_prev[t] = tmpmax_store;      }    }    /* store the number of last computed frame */    if (node_exist_p) endt = t;        /* scanした帽胳の妈1パスでの幌眉箕癸より黎まで t が渴んでおり·かつ       この t においてスコアエンベロ〖プによって栏き荒ったノ〖ドが办つも       痰かったならば,このフレ〖ムで纷换を虑ち磊りそれ笆惧黎([0..t-1])は       纷换しない */    /* if frame 't' already reached the beginning frame of scanned word       in 1st pass and no node was survived in this frame (all nodes pruned       by score envelope), terminate computation at this frame and       do not computer further frame ([0..t-1]). */    if (t < now->estimated_next_t && (!node_exist_p)) {      /* clear the rest scores */      for (i=t-1;i>=0;i--) {	now->g[i] = LOG_ZERO;#ifdef GRAPHOUT_PRECISE_BOUNDARY	if (r->graphout) {	  now->wordend_frame[i] = -1;	  now->wordend_gscore[i] = LOG_ZERO;	}#endif	if (ccd_flag) now->g_prev[i] = LOG_ZERO;      }      /* terminate loop */      break;    }      } /* end of time loop */    if (debug2_flag) jlog("DEBUG: scanned: [%3d-%3d]\n", endt, startt); end_of_scan:  if (hmminfo->multipath) {    /* 涟羹きスコアの呵姜猛を纷换 (觉轮 0 から箕粗 0 への莲败) */    /* compute the total forward score (transition from state 0 to frame 0 */    if (endt == 0) {      tmpmax = LOG_ZERO;      for(ac=whmm->state[0].ac;ac;ac=ac->next) {	score1 = dwrk->wordtrellis[tn][ac->arc] + ac->a;	if (tmpmax < score1) tmpmax = score1;      }      now->final_g = score1;    } else {      now->final_g = LOG_ZERO;    }  }    /* 肌搀 backscan のための攫鼠呈羌 */  /* store data for next backscan */  if (ccd_flag) {    if (store_point == (hmminfo->multipath ? wordhmmnum - 2 : wordhmmnum - 1)) {      /* last_ph痰し·かつ帽胳の不燎墓=1の眷圭、肌搀の scan_word() で	 帽胳链挛がもう办刨浩纷换される. この眷圭,	 g_prev は·このscan_wordを倡幌する涟のスコアを掐れておく涩妥がある */      /* if there was no 'last_ph' and the scanned word consists of only	 1 phone, the whole word should be re-computed in the future scan_word().	 So the next 'g_prev[]' should be the initial forward scores	 before we begin Viterbi (= g[t]). */      for (t = startt; t>=0; t--) {	now->g_prev[t] = dwrk->g[t];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -