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

📄 jfunc.c

📁 julius version 4.12.about sound recognition.
💻 C
📖 第 1 页 / 共 3 页
字号:
 * * @callgraph * @callergraph * @ingroup jfunc_process *  */booleanj_process_deactivate_by_id(Recog *recog, int id){  RecogProcess *r;  for(r=recog->process_list;r;r=r->next) {    if (r->config->id == id) {      /* book to be inactive at next interval */      r->active = -1;      break;    }  }  if (!r) {			/* not found */    jlog("ERROR: j_process_deactivate_by_id: no SR instance whose id is \"%02d\", cannot deactivate\n", id);    return FALSE;  }  /* tell engine to update */  recog->process_want_reload = TRUE;  return TRUE;}/**  * <EN> * Activate a recognition process instance that has been made inactive, by * its name. * The process will actually starts at the next recognition interval. * </EN> * <JA> * 办箕匿贿されていた千急借妄インスタンスの瓢侯を浩倡させる.  * 悸狠に浩倡するのは肌の不兰千急の圭粗である.  * </JA> *  * @param recog [i/o] engine instance * @param name [in] SR name to activate *  * @return TRUE on success, or FALSE on failure. * * @callgraph * @callergraph * @ingroup jfunc_process *  */booleanj_process_activate(Recog *recog, char *name){  RecogProcess *r;  for(r=recog->process_list;r;r=r->next) {    if (strmatch(r->config->name, name)) {      /* book to be active at next interval */      r->active = 1;      break;    }  }  if (!r) {			/* not found */    jlog("ERROR: j_process_activate: no SR instance named \"%s\", cannot activate\n", name);    return FALSE;  }  /* tell engine to update */  recog->process_want_reload = TRUE;  return TRUE;}/**  * <EN> * Activate a recognition process instance that has been made inactive, by * the ID. * The process will actually starts at the next recognition interval. * </EN> * <JA> * 办箕匿贿されていた千急借妄インスタンスの瓢侯を浩倡させる(ID回年). * 悸狠に浩倡するのは肌の不兰千急の圭粗である.  * </JA> *  * @param recog [i/o] engine instance * @param id [in] SR ID to activate *  * @return TRUE on success, or FALSE on failure. * * @callgraph * @callergraph * @ingroup jfunc_process *  */booleanj_process_activate_by_id(Recog *recog, int id){  RecogProcess *r;  for(r=recog->process_list;r;r=r->next) {    if (r->config->id == id) {      /* book to be active at next interval */      r->active = 1;      break;    }  }  if (!r) {			/* not found */    jlog("ERROR: j_process_activate_by_id: no SR instance whose id is \"%02d\", cannot activate\n", id);    return FALSE;  }  /* tell engine to update */  recog->process_want_reload = TRUE;  return TRUE;}/**  * <EN> * @brief  Create a new recognizer with a new LM and SR configurations. *  * This function creates new LM process instance and recognition process * instance corresponding to the given LM and SR configurations. * AM process to be assigned to them is the current default AM. * Both the new LM and SR will be assigned the same instance name. * </EN> * <JA> * @brief  LM および SR 肋年に答づき千急借妄プロセスを纳裁する.  * * この簇眶は涂えられたLM肋年およびSR肋年デ〖タに答づき·糠たな * LMインスタンスおよび千急プロセスインスタンスをエンジン柒婶に * 栏喇する. AMについては附哼のデフォルトAMが极瓢弄に脱いられる.  * 叹涟はLMインスタンス·千急プロセスインスタンスとも票じ叹涟が * あたえられる.  * </JA> *  * @param recog [i/o] engine instance * @param lmconf [in] a new LM configuration * @param sconf [in] a new SR configuration * @param name [in] name of the new instances *  * @return TRUE on success, FALSE on error. *  * @callgraph * @callergraph * @ingroup jfunc_process */booleanj_process_add_lm(Recog *recog, JCONF_LM *lmconf, JCONF_SEARCH *sconf, char *name){  /* add lmconf to global config */  if (j_jconf_lm_regist(recog->jconf, lmconf, name) == FALSE) {    jlog("ERROR: j_process_add_lm: failed to regist new LM conf as \"%s\"\n", name);    return FALSE;  }  /* assign lmconf and default amconf to the sconf */  sconf->amconf = j_get_amconf_default(recog->jconf);  sconf->lmconf = lmconf;  /* add the sconf to global config */  if (j_jconf_search_regist(recog->jconf, sconf, name) == FALSE) {    jlog("ERROR: j_process_add_lm: failed to regist new SR conf as \"%s\"\n", name);    j_jconf_search_free(sconf);    return FALSE;  }  /* finalize the whole parameters */  if (j_jconf_finalize(recog->jconf) == FALSE) {    jlog("ERROR: j_process_add_lm: failed to finalize the updated whole jconf\n");    return FALSE;  }  /* create LM process intance for the lmconf, and load LM */  if (j_load_lm(recog, lmconf) == FALSE) {    jlog("ERROR: j_process_add_lm: failed to load LM \"%s\"\n", lmconf->name);    return FALSE;  }  /* create recognition process instance for the sconf, and setup for recognition */  if (j_launch_recognition_instance(recog, sconf) == FALSE) {    jlog("ERROR: j_process_add_lm: failed to start a new recognizer instance \"%s\"\n", sconf->name);    return FALSE;  }  /* the created process will be live=FALSE, active = 1, so     the new recognition instance is dead now but     will be made live at next session */  /* tell engine to update */  recog->process_want_reload = TRUE;  return TRUE;}/**  * <EN> * Remove a recognition process instance. * The specified search conf will also be released and destroyed * inside this function. * </EN> * <JA> * 千急借妄インスタンスを猴近する.  * 回年されたSEARCH肋年もこの簇眶柒で豺庶ˇ猴近される.  * </JA> *  * @param recog [in] engine instance * @param sconf [in] SEARCH configuration corresponding to the target * recognition process to remove *  * @return TRUE on success, or FALSE on failure. *  * @callgraph * @callergraph * @ingroup jfunc_process */booleanj_process_remove(Recog *recog, JCONF_SEARCH *sconf){  RecogProcess *r, *r_prev;  JCONF_SEARCH *sc, *sc_prev;  if (sconf == NULL) {    jlog("ERROR: j_process_remove: sconf == NULL\n");    return FALSE;  }  /* find corresponding process in engine and remove it from list */  r_prev = NULL;  for(r=recog->process_list;r;r=r->next) {    if (r->config == sconf) {      if (r_prev == NULL) {	recog->process_list = r->next;      } else {	r_prev->next = r->next;      }      break;    }    r_prev = r;  }  if (!r) {    jlog("ERROR: j_process_remove: specified sconf %02d %s not found in recogprocess, removal failed\n", sconf->id, sconf->name);    return FALSE;  }  /* remove config from list in engine */  sc_prev = NULL;  for(sc=recog->jconf->search_root;sc;sc=sc->next) {    if (sc == sconf) {      if (sc_prev == NULL) {	recog->jconf->search_root = sc->next;      } else {	sc_prev->next = sc->next;      }      break;    }    sc_prev = sc;  }  if (!sc) {    jlog("ERROR: j_process_remove: sconf %02d %s not found\n", sconf->id, sconf->name);  }  /* free them */  j_recogprocess_free(r);  if (verbose_flag) jlog("STAT: recogprocess %02d %s removed\n", sconf->id, sconf->name);  j_jconf_search_free(sconf);  /* tell engine to update */  recog->process_want_reload = TRUE;  return TRUE;}/**  * <EN> * Remove an LM process instance. * The specified lm conf will also be released and destroyed * inside this function. * </EN> * <JA> * 咐胳モデルインスタンスを猴近する.  * 回年された咐胳モデル肋年もこの簇眶柒で豺庶ˇ猴近される.  * </JA> *  * @param recog [in] engine instance * @param lmconf [in] LM configuration corresponding to the target * LM process to remove *  * @return TRUE on success, or FALSE on failure. *  * @callgraph * @callergraph * @ingroup jfunc_process */booleanj_process_lm_remove(Recog *recog, JCONF_LM *lmconf){  RecogProcess *r;  PROCESS_LM *lm, *lm_prev;  JCONF_LM *l, *l_prev;  if (lmconf == NULL) {    jlog("ERROR: j_process_lm_remove: lmconf == NULL\n");    return FALSE;  }  /* check if still used by a process */  for(r=recog->process_list;r;r=r->next) {    if (r->config->lmconf == lmconf) {      jlog("ERROR: j_process_lm_remove: specified lmconf %02d %s still used in a recogprocess %02d %s\n", lmconf->id, lmconf->name, r->config->id, r->config->name);      return FALSE;    }  }  /* find corresponding LM process in engine and remove it from list */  lm_prev = NULL;  for(lm=recog->lmlist;lm;lm=lm->next) {    if (lm->config == lmconf) {      if (lm_prev == NULL) {	recog->lmlist = lm->next;      } else {	lm_prev->next = lm->next;      }      break;    }    lm_prev = lm;  }  if (!lm) {    jlog("ERROR: j_process_lm_remove: specified lmconf %02d %s not found in LM process, removal failed\n", lmconf->id, lmconf->name);    return FALSE;  }  /* remove config from list in engine */  l_prev = NULL;  for(l=recog->jconf->lm_root;l;l=l->next) {    if (l == lmconf) {      if (l_prev == NULL) {	recog->jconf->lm_root = l->next;      } else {	l_prev->next = l->next;      }      break;    }    l_prev = l;  }  if (!l) {    jlog("ERROR: j_process_lm_remove: lmconf %02d %s not found\n", lmconf->id, lmconf->name);    return FALSE;  }  /* free them */  j_process_lm_free(lm);  if (verbose_flag) jlog("STAT: LM process %02d %s removed\n", lmconf->id, lmconf->name);  j_jconf_lm_free(lmconf);  /* tell engine to update */  recog->process_want_reload = TRUE;  return TRUE;}/**  * <EN> * Remove an AM process instance (experimental). * The specified am conf will also be released and destroyed * inside this function. * </EN> * <JA> * 咐胳モデルインスタンスを猴近する∈悸赋面∷. * 回年された咐胳モデル肋年もこの簇眶柒で豺庶ˇ猴近される.  * </JA> *  * @param recog [in] engine instance * @param amconf [in] AM configuration corresponding to the target * AM process to remove *  * @return TRUE on success, or FALSE on failure. *  * @callgraph * @callergraph * @ingroup jfunc_process */booleanj_process_am_remove(Recog *recog, JCONF_AM *amconf){  RecogProcess *r;  PROCESS_LM *lm;  PROCESS_AM *am, *am_prev;  JCONF_AM *a, *a_prev;  if (amconf == NULL) {    jlog("ERROR: j_process_am_remove: amconf == NULL\n");    return FALSE;  }  /* check if still used by a process */  for(r=recog->process_list;r;r=r->next) {    if (r->config->amconf == amconf) {      jlog("ERROR: j_process_am_remove: specified amconf %02d %s still used in a recogprocess %02d %s\n", amconf->id, amconf->name, r->config->id, r->config->name);      return FALSE;    }  }  /* check if still used by a LM process */  for(lm=recog->lmlist;lm;lm=lm->next) {    if (lm->am->config == amconf) {      jlog("ERROR: j_process_am_remove: specified amconf %02d %s still used in a LM %02d %s\n", amconf->id, amconf->name, lm->config->id, lm->config->name);      return FALSE;    }  }  /* find corresponding AM process in engine and remove it from list */  am_prev = NULL;  for(am=recog->amlist;am;am=am->next) {    if (am->config == amconf) {      if (am_prev == NULL) {	recog->amlist = am->next;      } else {	am_prev->next = am->next;      }      break;    }    am_prev = am;  }  if (!am) {    jlog("ERROR: j_process_am_remove: specified amconf %02d %s not found in AM process, removal failed\n", amconf->id, amconf->name);    return FALSE;  }  /* remove config from list in engine */  a_prev = NULL;  for(a=recog->jconf->am_root;a;a=a->next) {    if (a == amconf) {      if (a_prev == NULL) {	recog->jconf->am_root = a->next;      } else {	a_prev->next = a->next;      }      break;    }    a_prev = a;  }  if (!a) {    jlog("ERROR: j_process_am_remove: amconf %02d %s not found\n", amconf->id, amconf->name);    return FALSE;  }  /* free them */  j_process_am_free(am);  if (verbose_flag) jlog("STAT: AM process %02d %s removed\n", amconf->id, amconf->name);  j_jconf_am_free(amconf);  /* tell engine to update */  recog->process_want_reload = TRUE;  return TRUE;}#ifdef DEBUG_VTLN_ALPHA_TESTvoidvtln_alpha(Recog *recog, RecogProcess *r){  Sentence *s;  float alpha, alpha_bgn, alpha_end;  float max_alpha;  LOGPROB max_score;  PROCESS_AM *am;  MFCCCalc *mfcc;  SentenceAlign *align;  s = &(r->result.sent[0]);  align = result_align_new();  max_score = LOG_ZERO;  printf("------------ begin VTLN -------------\n");  mfcc = r->am->mfcc;  alpha_bgn = mfcc->para->vtln_alpha - VTLN_RANGE;  alpha_end = mfcc->para->vtln_alpha + VTLN_RANGE;  for(alpha = alpha_bgn; alpha <= alpha_end; alpha += VTLN_STEP) {    mfcc->para->vtln_alpha = alpha;    if (InitFBank(mfcc->wrk, mfcc->para) == FALSE) {      jlog("ERROR: VTLN: InitFBank() failed\n");      return;    }    if (wav2mfcc(recog->speech, recog->speechlen, recog) == FALSE) {      jlog("ERROR: VTLN: wav2mfcc() failed\n");      return;    }    outprob_prepare(&(r->am->hmmwrk), mfcc->param->samplenum);    word_align(s->word, s->word_num, mfcc->param, align, r);    printf("%f: %f\n", alpha, align->allscore);    if (max_score < align->allscore) {      max_score = align->allscore;      max_alpha = alpha;    }  }  printf("MAX: %f: %f\n", max_alpha, max_score);  mfcc->para->vtln_alpha = max_alpha;  if (InitFBank(mfcc->wrk, mfcc->para) == FALSE) {    jlog("ERROR: VTLN: InitFBank() failed\n");    return;  }  printf("------------ end VTLN -------------\n");  result_align_free(align);}#endif/* end of file */

⌨️ 快捷键说明

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