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

📄 search_bestfirst_v2.c

📁 julius version 4.12.about sound recognition.
💻 C
📖 第 1 页 / 共 4 页
字号:
 */voidnext_word(NODE *now, NODE *new, NEXTWORD *nword, HTK_Param *param, RecogProcess *r){  HMM_Logical *lastphone, *newphone;  LOGPROB *g_src;  int   t;  int lastword;  int   i;  LOGPROB a_value;  LOGPROB tmpp;  int   startt;  int word;  TRELLIS_ATOM *tre;  LOGPROB totalscore;  BACKTRELLIS *backtrellis;  WORD_INFO *winfo;  HTK_HMM_INFO *hmminfo;  int peseqlen;  boolean ccd_flag;  StackDecode *dwrk;  dwrk = &(r->pass2);  backtrellis = r->backtrellis;  winfo = r->lm->winfo;  hmminfo = r->am->hmminfo;  peseqlen = r->peseqlen;  ccd_flag = r->ccd_flag;  word = nword->id;  lastword = now->seq[now->seqnum-1];  /* lastphone (木涟帽胳の黎片不燎) を洁洒 */  /* prepare lastphone (head phone of previous word) */  if (ccd_flag) {    /* 呵姜不燎 triphone を儡鲁帽胳に柴わせて恃步 */    /* modify triphone of last phone according to the next word */    lastphone = get_left_context_HMM(now->last_ph, winfo->wseq[word][winfo->wlen[word]-1]->name, hmminfo);    if (lastphone == NULL) {      /* fallback to the original bi/mono-phone */      /* error if the original is pseudo phone (not explicitly defined	 in hmmdefs/hmmlist) */      /* exception: word with 1 phone (triphone may exist in the next expansion */      if (now->last_ph->is_pseudo){	error_missing_left_triphone(now->last_ph, winfo->wseq[word][winfo->wlen[word]-1]->name);      }      lastphone = now->last_ph;    }  }  /* newphone (儡鲁帽胳の琐萨不燎) を洁洒 */  /* prepare newphone (tail phone of next word) */  if (ccd_flag) {    newphone = get_right_context_HMM(winfo->wseq[word][winfo->wlen[word]-1], now->last_ph->name, hmminfo);    if (newphone == NULL) {      /* fallback to the original bi/mono-phone */      /* error if the original is pseudo phone (not explicitly defined	 in hmmdefs/hmmlist) */      /* exception: word with 1 phone (triphone may exist in the next expansion */      if (winfo->wlen[word] > 1 && winfo->wseq[word][winfo->wlen[word]-1]->is_pseudo){	error_missing_right_triphone(winfo->wseq[word][winfo->wlen[word]-1], now->last_ph->name);      }      newphone = winfo->wseq[word][winfo->wlen[word]-1];    }  } else {    newphone = winfo->wseq[word][winfo->wlen[word]-1];  }    /* 帽胳事び、DFA觉轮戎规、咐胳スコアを new へ费镜ˇ构糠 */  /* inherit and update word sequence, DFA state and total LM score to 'new' */  new->score = LOG_ZERO;  for (i=0;i< now->seqnum;i++){    new->seq[i] = now->seq[i];#ifdef CM_SEARCH#ifdef CM_MULTIPLE_ALPHA    memcpy(new->cmscore[i], now->cmscore[i], sizeof(LOGPROB) * r->config->annotate.cm_alpha_num);#else    new->cmscore[i] = now->cmscore[i];#endif#endif /* CM_SEARCH */  }  new->seq[i] = word;  new->seqnum = now->seqnum+1;  new->state = nword->next_state;  new->totallscore = now->totallscore + nword->lscore;  if (ccd_flag) {    /* 肌簿棱の旺悟攫鼠として瘦赂 */    /* keep the lastphone for next scan_word() */    new->last_ph = lastphone;    new->last_ph_sp_attached = now->last_ph_sp_attached;  }  if (ccd_flag) {    /* 呵稿の1不燎(lastphone)尸をscanし·构糠したスコアを new に瘦赂 */    /* scan the lastphone and set the updated score to new->g[] */    do_viterbi_next_word(now, new, lastphone,			 hmminfo->multipath ? now->last_ph_sp_attached : FALSE,			 param, r);    g_src = new->g;  } else {    g_src = now->g;#ifdef GRAPHOUT_PRECISE_BOUNDARY    if (r->graphout) {      memcpy(new->wordend_frame, now->wordend_frame, sizeof(short)*peseqlen);      memcpy(new->wordend_gscore, now->wordend_gscore, sizeof(LOGPROB)*peseqlen);    }#endif  }        /* 肌搀の scan_word に洒えて new->g[] を恃构しておく */  /* prepare new->g[] for next scan_word() */  if (hmminfo->multipath) {    startt = peseqlen-1;  } else {    startt = peseqlen-2;  }  i = hmm_logical_state_num(newphone);  a_value = (hmm_logical_trans(newphone))->a[i-2][i-1];  if (hmminfo->multipath) {    for(t=0; t <= startt; t++) {      new->g[t] = g_src[t] + nword->lscore;    }  } else {    for(t=0; t <= startt; t++) {      new->g[t] = g_src[t+1] + a_value + nword->lscore;    }  }  /***************************************************************************/  /* 涟羹き(妈2パス),稿ろ羹き(妈1パス)トレリスを儡鲁し呵锑儡鲁爬を斧つける */  /* connect forward/backward trellis to look for the best connection time   */  /***************************************************************************/  /*-----------------------------------------------------------------*/  /* 帽胳トレリスを玫して, 肌帽胳の呵锑儡鲁爬を券斧する */  /* determine the best connection time of the new word, seeking the word     trellis */  /*-----------------------------------------------------------------*/  if (r->lmtype == LM_DFA && !r->config->pass2.looktrellis_flag) {    /* すべてのフレ〖ムにわたって呵锑を玫す */    /* search for best trellis word throughout all frame */    for(t = startt; t >= 0; t--) {      tre = bt_binsearch_atom(backtrellis, t, (WORD_ID) word);      if (tre == NULL) continue;      totalscore = new->g[t] + tre->backscore;      if (! hmminfo->multipath) {	if (newphone->is_pseudo) {	  tmpp = outprob_cd(&(r->am->hmmwrk), t, &(newphone->body.pseudo->stateset[newphone->body.pseudo->state_num-2]), param);	} else {	  tmpp = outprob_state(&(r->am->hmmwrk), t, newphone->body.defined->s[newphone->body.defined->state_num-2], param);	}	totalscore += tmpp;      }      if (new->score < totalscore) {	new->score = totalscore;	new->bestt = t;	new->estimated_next_t = tre->begintime - 1;	new->tre = tre;      }    }    return;  }  /* 呵稿に徊救したTRELLIS_ATOMの姜眉箕粗の涟稿 */  /* newの夸年箕粗は·惧淡で何脱したTRELLIS_ATOMの幌眉箕粗 */  /* この鸥倡帽胳のトレリス惧の姜眉箕粗の涟稿のみスキャンする     涟稿に息鲁して赂哼するフレ〖ムについてのみ纷换 */  /* search for best trellis word only around the estimated time */  /* 1. search forward */  for(t = (nword->tre)->endtime; t >= 0; t--) {    tre = bt_binsearch_atom(backtrellis, t, (WORD_ID) word);    if (tre == NULL) break;	/* go to 2 if the trellis word disappear */    totalscore = new->g[t] + tre->backscore;    if (! hmminfo->multipath) {      if (newphone->is_pseudo) {	tmpp = outprob_cd(&(r->am->hmmwrk), t, &(newphone->body.pseudo->stateset[newphone->body.pseudo->state_num-2]), param);      } else {	tmpp = outprob_state(&(r->am->hmmwrk), t, newphone->body.defined->s[newphone->body.defined->state_num-2], param);      }      totalscore += tmpp;    }    if (new->score < totalscore) {      new->score = totalscore;      new->bestt = t;      new->estimated_next_t = tre->begintime - 1;      new->tre = tre;    }  }  /* 2. search bckward */  for(t = (nword->tre)->endtime + 1; t <= startt; t++) {    tre = bt_binsearch_atom(backtrellis, t, (WORD_ID) word);    if (tre == NULL) break;	/* end if the trellis word disapper */    totalscore = new->g[t] + tre->backscore;    if (! hmminfo->multipath) {      if (newphone->is_pseudo) {	tmpp = outprob_cd(&(r->am->hmmwrk), t, &(newphone->body.pseudo->stateset[newphone->body.pseudo->state_num-2]), param);      } else {	tmpp = outprob_state(&(r->am->hmmwrk), t, newphone->body.defined->s[newphone->body.defined->state_num-2], param);      }      totalscore += tmpp;    }    if (new->score < totalscore) {      new->score = totalscore;      new->bestt = t;      new->estimated_next_t = tre->begintime - 1;      new->tre = tre;    }  }  /* set current LM score */  new->lscore = nword->lscore;  }/**********************************************************************//********** 介袋簿棱の栏喇                 ****************************//********** Generate an initial hypothesis ****************************//**********************************************************************//**  * <JA> * 涂えられた帽胳から介袋簿棱を栏喇する.  *  * @param new [out] 糠たに栏喇された簿棱が呈羌される * @param nword [in] 介袋簿棱帽胳の攫鼠 * @param param [in] 掐蜗パラメ〖タ误 * @param r [in] 千急借妄インスタンス * </JA> * <EN> * Generate an initial hypothesis from given word. *  * @param new [out] pointer to save the newly generated hypothesis * @param nword [in] words of the first candidates * @param param [in] input parameter vector * @param r [in] recognition process instance * * </EN> * @callgraph * @callergraph */voidstart_word(NODE *new, NEXTWORD *nword, HTK_Param *param, RecogProcess *r){  HMM_Logical *newphone;  WORD_ID word;  TRELLIS_ATOM *tre = NULL;  LOGPROB tmpp;  int t;  BACKTRELLIS *backtrellis;  WORD_INFO *winfo;  int peseqlen;  boolean ccd_flag;  boolean multipath;  backtrellis = r->backtrellis;  winfo = r->lm->winfo;  peseqlen = r->peseqlen;  ccd_flag = r->ccd_flag;  multipath = r->am->hmminfo->multipath;  /* initialize data */  word = nword->id;  new->score = LOG_ZERO;  new->seqnum = 1;  new->seq[0] = word;  new->state = nword->next_state;  new->totallscore = nword->lscore;  /* set current LM score */  new->lscore = nword->lscore;  /* cross-word triphone need not be handled on startup */  newphone = winfo->wseq[word][winfo->wlen[word]-1];  if (ccd_flag) {    new->last_ph = NULL;  }    if (r->lmtype == LM_PROB) {    new->g[peseqlen-1] = nword->lscore;  } else {    new->g[peseqlen-1] = 0;  }    for (t=peseqlen-1; t>=0; t--) {    tre = bt_binsearch_atom(backtrellis, t, word);    if (tre != NULL) {      if (r->graphout) {	new->bestt = peseqlen-1;      } else {	new->bestt = t;      }      new->score = new->g[peseqlen-1] + tre->backscore;      if (! multipath) {	if (newphone->is_pseudo) {	  tmpp = outprob_cd(&(r->am->hmmwrk), peseqlen-1, &(newphone->body.pseudo->stateset[newphone->body.pseudo->state_num-2]), param);	} else {	  tmpp = outprob_state(&(r->am->hmmwrk), peseqlen-1, newphone->body.defined->s[newphone->body.defined->state_num-2], param);	}	new->score += tmpp;      }      new->estimated_next_t = tre->begintime - 1;      new->tre = tre;      break;    }  }  if (tre == NULL) {		/* no word in backtrellis */    new->score = LOG_ZERO;  }}/**  * <JA> * 姜眉借妄¨姜眉まで茫した矢簿棱の呵姜弄なスコアをセットする.  *  * @param now [in] 姜眉まで茫した簿棱 * @param new [out] 呵姜弄な矢簿棱のスコアを呈羌する眷疥へのポインタ * @param param [in] 掐蜗パラメ〖タ误 * @param r [in] 千急借妄インスタンス * </JA> * <EN> * Hypothesis termination: set the final sentence scores of hypothesis * that has already reached to the end. *  * @param now [in] hypothesis that has already reached to the end * @param new [out] pointer to save the final sentence information * @param param [in] input parameter vectors * @param r [in] recognition process instance * </EN> * @callgraph * @callergraph */voidlast_next_word(NODE *now, NODE *new, HTK_Param *param, RecogProcess *r){  cpy_node(new, now);  if (r->ccd_flag) {    /* 呵姜不燎尸を viterbi して呵姜スコアを肋年 */    /* scan the last phone and update the final score */    if (r->am->hmminfo->multipath) {      do_viterbi_next_word(now, new, now->last_ph, now->last_ph_sp_attached, param, r);      new->score = new->final_g;    } else {      do_viterbi_next_word(now, new, now->last_ph, FALSE, param, r);      new->score = new->g[0];    }  } else {    if (r->am->hmminfo->multipath) {      new->score = now->final_g;    } else {      new->score = now->g[0];    }#ifdef GRAPHOUT_PRECISE_BOUNDARY    if (r->graphout) {      /* last boundary has moved to [peseqlen-1] in last scan_word() */      memcpy(new->wordend_frame, now->wordend_frame, sizeof(short)*r->peseqlen);      memcpy(new->wordend_gscore, now->wordend_gscore, sizeof(LOGPROB)*r->peseqlen);    }#endif  }}#endif /* PASS2_STRICT_IWCD *//* end of file */

⌨️ 快捷键说明

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