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

📄 beam.c

📁 julius version 4.12.about sound recognition.
💻 C
📖 第 1 页 / 共 5 页
字号:
 * 妈1パスの冯蔡呈羌脱エリア (r->result.pass1) に澄年冯蔡を呈羌する.  * また澄年箕は r->have_determine に TRUE が掐る.  *  * @param r [in] 千急借妄インスタンス * @param t [in] 附哼の掐蜗フレ〖ム * </JA> * <EN> * Determine word hypothesis before end of input (EXPERIMENT).  When * determined, the determined word will be stored to the result area * for the 1st pass (r->result.pass1).  r->have_determine will be * set to TRUE when determinized. *  * @param r [in] recognition process instance * @param t [in] current input frame * </EN> */static voidcheck_determine_word(RecogProcess *r, int t){  TRELLIS_ATOM *tre;  TRELLIS_ATOM *tremax;  LOGPROB maxscore;  /* bt->list is ordered by time frame */  maxscore = LOG_ZERO;  tremax = NULL;  tre = r->backtrellis->list;  while (tre != NULL && tre->endtime == t) {    if (maxscore < tre->backscore) {      maxscore = tre->backscore;      tremax = tre;    }    tre = tre->next;  }  r->result.status = J_RESULT_STATUS_SUCCESS;  r->result.num_frame = t;  if (maxscore != LOG_ZERO) {    //    if ((tre = determine_word(recog, t, tremax, 0.9, 17)) != NULL) {    if ((tre = determine_word(r, t, tremax, r->config->pass1.determine_score_thres, r->config->pass1.determine_duration_thres)) != NULL) {      r->result.pass1.word[0] = tremax->wid;      r->result.pass1.word_num = 1;      r->result.pass1.score = tremax->backscore;      r->result.pass1.score_lm = 0.0;      r->result.pass1.score_am = tremax->backscore;      r->result.num_frame = t;      //callback_exec(CALLBACK_RESULT_PASS1_DETERMINED, r);    }  }  }#endif /* DETERMINE *//**  * <JA> * 妈1パスの借妄面に·あるフレ〖ムまでのベストパスを山绩する.  *  * @param r [i/o] 千急借妄インスタンス * @param t [in] 附哼の掐蜗フレ〖ム * </JA> * <EN> * Output the current best word sequence ending * at a specified time frame in the course of the 1st pass. *  * @param r [i/o] recognition process instance * @param t [in] current input frame * </EN> */static voidbt_current_max(RecogProcess *r, int t){  int wordlen;  TRELLIS_ATOM *tre;  TRELLIS_ATOM *tremax;  LOGPROB maxscore;  LOGPROB lscore;  /* bt->list is ordered by time frame */  maxscore = LOG_ZERO;  tremax = NULL;  tre = r->backtrellis->list;  while (tre != NULL && tre->endtime == t) {    if (maxscore < tre->backscore) {      maxscore = tre->backscore;      tremax = tre;    }    tre = tre->next;  }  r->result.status = J_RESULT_STATUS_SUCCESS;  r->result.num_frame = t;  if (maxscore == LOG_ZERO) {    r->result.pass1.word_num = 0;  } else {    if (r->lmvar == LM_DFA_WORD) {      r->result.pass1.word[0] = tremax->wid;      r->result.pass1.word_num = 1;      r->result.pass1.score = tremax->backscore;      r->result.pass1.score_lm = 0.0;      r->result.pass1.score_am = tremax->backscore;    } else {      lscore = trace_backptr(r->result.pass1.word, &wordlen, tremax, r->lm->winfo);      r->result.pass1.word_num = wordlen;      r->result.pass1.score = tremax->backscore;      r->result.pass1.score_lm = lscore;      r->result.pass1.score_am = tremax->backscore;    }  }  //callback_exec(CALLBACK_RESULT_PASS1_INTERIM, r);}/**  * <JA> * 妈1パスの借妄面に·あるフレ〖ム惧の呵锑帽胳を山绩する(デバッグ脱) *  * @param r [i/o] 千急借妄インスタンス * @param t [in] 附哼の掐蜗フレ〖ム * </JA> * <EN> * Output the current best word on a specified time frame in the course * of the 1st pass. *  * @param r [i/o] recognition process instance * @param t [in] current input frame * </EN> */static voidbt_current_max_word(RecogProcess *r, int t){  TRELLIS_ATOM *tre;  TRELLIS_ATOM *tremax;  LOGPROB maxscore;  WORD_ID w;  /* bt->list は箕粗界に呈羌されている */  /* bt->list is order by time */  maxscore = LOG_ZERO;  tremax = NULL;  tre = r->backtrellis->list;  while (tre != NULL && tre->endtime == t) {    if (maxscore < tre->backscore) {      maxscore = tre->backscore;      tremax = tre;    }    tre = tre->next;  }  if (maxscore != LOG_ZERO) {    jlog("DEBUG: %3d: ",t);    w = tremax->wid;    jlog("\"%s [%s]\"(id=%d)",	 r->lm->winfo->wname[w], r->lm->winfo->woutput[w], w);    jlog(" [%d-%d] %f", tremax->begintime, t, tremax->backscore);    w = tremax->last_tre->wid;    if (w != WORD_INVALID) {      jlog(" <- \"%s [%s]\"(id=%d)\n",	       r->lm->winfo->wname[w], r->lm->winfo->woutput[w], w);    } else {      jlog(" <- bgn\n");    }  }}/* -------------------------------------------------------------------- *//*                 ビ〖ム玫瑚面のト〖クンを胺うサブ簇眶                 *//*                functions to handle hypothesis tokens                 *//* -------------------------------------------------------------------- *//**  * <JA> * 妈1パスのビ〖ム玫瑚脱の介袋ワ〖クエリアを澄瘦する.  * 颅りない眷圭は玫瑚面に瓢弄に凯墓される.  * * @param d [i/o] 妈1パス玫瑚借妄脱ワ〖クエリア * @param n [in] 腾菇陇步辑今のノ〖ド眶 * @param ntoken_init [in] 呵介に澄瘦するト〖クンの眶 * </JA> * <EN> * Allocate initial work area for beam search on the 1st pass. * If filled while search, they will be expanded on demand. *  * @param d [i/o] work area for 1st pass recognition processing * @param n [in] number of nodes in lexicon tree * @param ntoken_init [in] number of token space to be allocated at first * </EN> */static voidmalloc_nodes(FSBeam *d, int n, int ntoken_init){  d->totalnodenum = n;  d->token     = (TOKENID *)mymalloc(sizeof(TOKENID) * d->totalnodenum);  //d->maxtnum = ntoken_init;  if (d->maxtnum < ntoken_init) d->maxtnum = ntoken_init;  d->tlist[0]  = (TOKEN2 *)mymalloc(sizeof(TOKEN2) * d->maxtnum);  d->tlist[1]  = (TOKEN2 *)mymalloc(sizeof(TOKEN2) * d->maxtnum);  d->tindex[0] = (TOKENID *)mymalloc(sizeof(TOKENID) * d->maxtnum);  d->tindex[1] = (TOKENID *)mymalloc(sizeof(TOKENID) * d->maxtnum);  //d->expand_step = ntoken_step;  d->nodes_malloced = TRUE;  d->expanded = FALSE;}/**  * <JA> * 妈1パスのビ〖ム玫瑚脱のワ〖クエリアを凯ばして浩澄瘦する.  * * @param d [i/o] 妈1パス玫瑚借妄脱ワ〖クエリア * </JA> * <EN> * Re-allocate work area for beam search on the 1st pass. *  * @param d [i/o] work area for 1st pass recognition processing * </EN> */static voidexpand_tlist(FSBeam *d){  d->maxtnum += d->expand_step;  d->tlist[0]  = (TOKEN2 *)myrealloc(d->tlist[0],sizeof(TOKEN2) * d->maxtnum);  d->tlist[1]  = (TOKEN2 *)myrealloc(d->tlist[1],sizeof(TOKEN2) * d->maxtnum);  d->tindex[0] = (TOKENID *)myrealloc(d->tindex[0],sizeof(TOKENID) * d->maxtnum);  d->tindex[1] = (TOKENID *)myrealloc(d->tindex[1],sizeof(TOKENID) * d->maxtnum);  if (debug2_flag) jlog("STAT: token space expanded to %d\n", d->maxtnum);  d->expanded = TRUE;}/**  * <EN> * Clear nodes for the next input.  Julius will call this function for * each input to re-set the work area for the beam search.  If the size * of tree lexicon has been changed since the last input, Julius will * free and re-allocate the work area. * </EN> * <JA> * ノ〖ド攫鼠を介袋步する. Julius は·腾菇陇步辑今のサイズが木涟の掐蜗 * 箕と恃步がないときは·この簇眶によってノ〖ド攫鼠を介袋步するだけで * よい. サイズが恃构されているときはノ〖ドを倡庶ˇ浩澄瘦する.  * </JA> *  * @param d [i/o] work area for 1st pass recognition processing * @param ntoken_step [in] required token step *  */static voidprepare_nodes(FSBeam *d, int ntoken_step){  d->tnum[0] = d->tnum[1] = 0;  if (d->expand_step < ntoken_step) d->expand_step = ntoken_step;}/**  * <JA> * 妈1パスのビ〖ム玫瑚脱のワ〖クエリアを链て豺庶する.  * * @param d [i/o] 妈1パス玫瑚借妄脱ワ〖クエリア *  * </JA> * <EN> * Free all the work area for beam search on the 1st pass. *  * @param d [i/o] work area for 1st pass recognition processing *  * </EN> */static voidfree_nodes(FSBeam *d){  if (d->nodes_malloced) {    free(d->token);    free(d->tlist[0]);    free(d->tlist[1]);    free(d->tindex[0]);    free(d->tindex[1]);    d->nodes_malloced = FALSE;  }}/**  * <JA> * ト〖クンスペ〖スをリセットする.  *  * @param d [i/o] 妈1パス玫瑚借妄脱ワ〖クエリア * @param tt [in] ワ〖クエリアID (0 または 1) * </JA> * <EN> * Reset the token space. *  * @param d [i/o] work area for 1st pass recognition processing * @param tt [in] work area id (0 or 1) * </EN> */static voidclear_tlist(FSBeam *d, int tt){  d->tnum[tt] = 0;}/**  * <JA> * アクティブト〖クンリストをクリアする.  *  * @param d [i/o] 妈1パス玫瑚借妄脱ワ〖クエリア * @param tt [in] 木涟のワ〖クエリアID (0 または 1) * </JA> * <EN> * Clear the active token list. *  * @param d [i/o] work area for 1st pass recognition processing * @param tt [in] work area id of previous frame (0 or 1) * </EN> */static voidclear_tokens(FSBeam *d, int tt){  int j;  /* initialize active token list: only clear ones used in the last call */  for (j=0; j<d->tnum[tt]; j++) {    d->token[d->tlist[tt][j].node] = TOKENID_UNDEFINED;  }}/**  * <JA> * ト〖クンスペ〖スから糠たなト〖クンを艰りだす.  *  * @param d [i/o] 妈1パス玫瑚借妄脱ワ〖クエリア *  * @return 糠たに艰り叫されたト〖クンのID * </JA> * <EN> * Assign a new token from token space. *  * @param d [i/o] work area for 1st pass recognition processing  * @return the id of the newly assigned token. * </EN> */static TOKENIDcreate_token(FSBeam *d){  TOKENID newid;  int tn;  tn = d->tn;  newid = d->tnum[tn];  d->tnum[tn]++;  while (d->tnum[tn]>=d->maxtnum) expand_tlist(d);  d->tindex[tn][newid] = newid;#ifdef WPAIR  /* initialize link */  d->tlist[tn][newid].next = TOKENID_UNDEFINED;#endif  return(newid);}/**  * <JA> * @brief  腾菇陇步辑今のノ〖ドにト〖クンを充り烧ける.  * * 腾菇陇步辑今のノ〖ドのアクティブト〖クンリストにト〖クンを瘦赂する.  * またト〖クンスペ〖スにおいてト〖クンからノ〖ド戎规へのリンクを瘦赂する.  *  * 贷にト〖クンがある眷圭は·糠たなト〖クンによって惧今きされる. なお * WPAIR 回年箕はそのリストに糠たなト〖クンを纳裁する.  *  * @param d [i/o] 妈1パス玫瑚借妄脱ワ〖クエリア * @param node [in] 腾菇陇步辑今のノ〖ド戎规 * @param tkid [in] ト〖クン戎规 * </JA> * <EN> * @brief  Assign token to a node on tree lexicon * * Save the token id to the specified node in the active token list. * Also saves the link to the node from the token in token space. * * If a token already exist on the node, it will be overridden by the new one. * If WPAIR is defined, the new token will be simply added to the list of * active tokens on the node. *  * @param d [i/o] work area for 1st pass recognition processing * @param node [in] node id on the tree lexicon * @param tkid [in] token id to be assigned * </EN> */static voidnode_assign_token(FSBeam *d, int node, TOKENID tkid){#ifdef WPAIR  /* add to link list */  d->tlist[d->tn][tkid].next = d->token[node];#endif  d->token[node] = tkid;  d->tlist[d->tn][tkid].node = node;}/** 

⌨️ 快捷键说明

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