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

📄 instance.c

📁 julius version 4.12.about sound recognition.
💻 C
📖 第 1 页 / 共 2 页
字号:
/** * @file   instance.c *  * <EN> * @brief  Allocate/free various instances * </EN> *  * <JA> * @brief  称硷インスタンスの充り烧けおよび倡庶 * </JA> *  * @author Akinobu Lee * @date   Sun Oct 28 18:06:20 2007 * * $Revision: 1.3 $ *  *//* * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology * All rights reserved */#include <julius/juliuslib.h>/**  * <EN> * Allocate a new MFCC calculation instance * </EN> * <JA> * MFCC纷换インスタンスを糠たに充り烧ける.  * </JA> *  * @param amconf [in] acoustic model configuration parameters *  * @return the newly allocated MFCC calculation instance. * * @callgraph * @callergraph *  */MFCCCalc *j_mfcccalc_new(JCONF_AM *amconf){  MFCCCalc *mfcc;  mfcc = (MFCCCalc *)mymalloc(sizeof(MFCCCalc));  memset(mfcc, 0, sizeof(MFCCCalc));  mfcc->param = NULL;  mfcc->rest_param = NULL;  mfcc->frontend.ssbuf = NULL;  mfcc->cmn.loaded = FALSE;  mfcc->plugin_source = -1;  if (amconf) {    mfcc->para = &(amconf->analysis.para);    mfcc->hmm_loaded = (amconf->analysis.para_hmm.loaded == 1) ? TRUE : FALSE;    mfcc->htk_loaded = (amconf->analysis.para_htk.loaded == 1) ? TRUE : FALSE;    mfcc->wrk = WMP_work_new(mfcc->para);    if (mfcc->wrk == NULL) {      jlog("ERROR: j_mfcccalc_new: failed to initialize MFCC computation\n");      return NULL;    }    mfcc->cmn.load_filename = amconf->analysis.cmnload_filename;    mfcc->cmn.update = amconf->analysis.cmn_update;    mfcc->cmn.save_filename = amconf->analysis.cmnsave_filename;    mfcc->cmn.map_weight = amconf->analysis.cmn_map_weight;    mfcc->frontend.ss_alpha = amconf->frontend.ss_alpha;    mfcc->frontend.ss_floor = amconf->frontend.ss_floor;    mfcc->frontend.sscalc = amconf->frontend.sscalc;    mfcc->frontend.sscalc_len = amconf->frontend.sscalc_len;    mfcc->frontend.ssload_filename = amconf->frontend.ssload_filename;  }  mfcc->next = NULL;  return mfcc;}/**  * <EN> * Free an MFCC calculation instance. * </EN> * <JA> * MFCC纷换インスタンスを倡庶する * </JA> *  * @param mfcc [i/o] MFCC calculation instance *  * @callgraph * @callergraph */voidj_mfcccalc_free(MFCCCalc *mfcc){  if (mfcc->rest_param) free_param(mfcc->rest_param);  if (mfcc->param) free_param(mfcc->param);  if (mfcc->wrk) WMP_free(mfcc->wrk);  if (mfcc->tmpmfcc) free(mfcc->tmpmfcc);  if (mfcc->db) WMP_deltabuf_free(mfcc->db);  if (mfcc->ab) WMP_deltabuf_free(mfcc->ab);  if (mfcc->cmn.wrk) CMN_realtime_free(mfcc->cmn.wrk);  if (mfcc->frontend.ssbuf) free(mfcc->frontend.ssbuf);  if (mfcc->frontend.mfccwrk_ss) WMP_free(mfcc->frontend.mfccwrk_ss);  free(mfcc);}/**  * <EN> * Allocate a new acoustic model processing instance. * </EN> * <JA> * 不读モデル纷换インスタンスを糠たに充り烧ける.  * </JA> * * @param recog [i/o] engine instance * @param amconf [in] AM configuration to assign *  * @return newly allocated acoustic model processing instance. *  * @callgraph * @callergraph */PROCESS_AM *j_process_am_new(Recog *recog, JCONF_AM *amconf){  PROCESS_AM *new, *atmp;  /* allocate memory */  new = (PROCESS_AM *)mymalloc(sizeof(PROCESS_AM));  memset(new, 0, sizeof(PROCESS_AM));  /* assign configuration */  new->config = amconf;  /* append to last */  new->next = NULL;  if (recog->amlist == NULL) {    recog->amlist = new;  } else {    for(atmp = recog->amlist; atmp->next; atmp = atmp->next);    atmp->next = new;  }    return new;}/**  * <EN> * Free an acoustic model processing instance. * </EN> * <JA> * 不读モデル纷换インスタンスを倡庶する.  * </JA> *  * @param am [i/o] AM process instance *  * @callgraph * @callergraph */voidj_process_am_free(PROCESS_AM *am){  if (am->hmminfo) hmminfo_free(am->hmminfo);  if (am->hmm_gs) hmminfo_free(am->hmm_gs);  /* not free am->jconf  */  /* HMMWork hmmwrk */  outprob_free(&(am->hmmwrk));  free(am);}/**  * <EN> * Allocate a new language model processing instance. * </EN> * <JA> * 咐胳モデル纷换インスタンスを糠たに充り烧ける.  * </JA> * * @param recog [i/o] engine instance * @param lmconf [in] LM configuration to assign *  * @return newly allocated language model processing instance. *  * @callgraph * @callergraph */PROCESS_LM *j_process_lm_new(Recog *recog, JCONF_LM *lmconf){  PROCESS_LM *new, *ltmp;  /* allocate memory */  new = (PROCESS_LM *)mymalloc(sizeof(PROCESS_LM));  memset(new, 0, sizeof(PROCESS_LM));  /* assign config */  new->config = lmconf;  /* initialize some values */  new->lmtype = lmconf->lmtype;  new->lmvar = lmconf->lmvar;  new->gram_maxid = 0;  new->global_modified = FALSE;  /* append to last */  new->next = NULL;  if (recog->lmlist == NULL) {    recog->lmlist = new;  } else {    for(ltmp = recog->lmlist; ltmp->next; ltmp = ltmp->next);    ltmp->next = new;  }  return new;}/**  * <EN> * Free a language model processing instance. * </EN> * <JA> * 咐胳モデル纷换インスタンスを倡庶する.  * </JA> *  * @param lm [i/o] LM process instance *  * @callgraph * @callergraph */voidj_process_lm_free(PROCESS_LM *lm){  if (lm->winfo) word_info_free(lm->winfo);  if (lm->ngram) ngram_info_free(lm->ngram);  if (lm->grammars) multigram_free_all(lm->grammars);  if (lm->dfa) dfa_info_free(lm->dfa);  /* not free lm->jconf  */  free(lm);}/**  * <EN> * Allocate a new recognition process instance. * </EN> * <JA> * 千急借妄インスタンスを糠たに栏喇する.  * </JA> * * @param recog [i/o] engine instance * @param sconf [in] SEARCH configuration to assign *  * @return the newly allocated recognition process instance. *  * @callgraph * @callergraph */RecogProcess *j_recogprocess_new(Recog *recog, JCONF_SEARCH *sconf){  RecogProcess *new, *ptmp;  /* allocate memory */  new = (RecogProcess *)mymalloc(sizeof(RecogProcess));  memset(new, 0, sizeof(RecogProcess));  new->live = FALSE;  new->active = 0;  new->next = NULL;  /* assign configuration */  new->config = sconf;  /* append to last */  new->next = NULL;  if (recog->process_list == NULL) {    recog->process_list = new;  } else {    for(ptmp = recog->process_list; ptmp->next; ptmp = ptmp->next);    ptmp->next = new;  }  return new;}/**  * <EN> * Free a recognition process instance * </EN> * <JA> * 千急借妄インスタンスを倡庶する.  * </JA> *  * @param process [i/o] recognition process instance *  * @callgraph * @callergraph */voidj_recogprocess_free(RecogProcess *process){  /* not free jconf, am, lm here */  /* free part of StackDecode work area */#ifdef CONFIDENVE_MEASURE#ifdef CM_MULTIPLE_ALPHA  free(process->pass2.cmsumlist);#endif#ifdef CM_NBEST;  free(process->pass2.sentcm);  free(process->pass2.wordcm);#endif#endif  /* free wchmm */  if (process->wchmm) wchmm_free(process->wchmm);  /* free backtrellis */  if (process->backtrellis) bt_free(process->backtrellis);  /* free pass1 work area */  fsbeam_free(&(process->pass1));  free(process);}/**  * <EN> * Allocate a new acoustic model (AM) parameter structure. * Default parameter values are set to it. * </EN> * <JA> * 不读モデル(AM)パラメ〖タ菇陇挛を糠たに充り烧ける. * 柒婶メンバにはデフォルト猛が呈羌される. * </JA> *  * @return the newly allocated AM parameter structure *  * @callgraph * @callergraph * @ingroup jconf */JCONF_AM *j_jconf_am_new(){  JCONF_AM *new;  new = (JCONF_AM *)mymalloc(sizeof(JCONF_AM));  jconf_set_default_values_am(new);  new->next = NULL;  return new;}/**  * <EN> * Release an acoustic model (AM) parameter structure * Default parameter values are set to it. * </EN> * <JA> * 不读モデル(AM)パラメ〖タ菇陇挛を豺庶する.  * 柒婶メンバにはデフォルト猛が呈羌される.  * </JA> *  * @param amconf [in] AM configuration * * @callgraph * @callergraph * @ingroup jconf *  */voidj_jconf_am_free(JCONF_AM *amconf){  free(amconf);}/**  * <EN> * Register AM configuration to global jconf. * Returns error if the same name already exist in the jconf. * </EN> * <JA> * 不读モデル(AM)パラメ〖タ菇陇挛を jconf に判峡するˉ * jconf柒に票じ叹涟のモジュ〖ルが贷に判峡されている眷圭はエラ〖となるˉ * </JA> *  * @param jconf [i/o] global jconf * @param amconf [in] AM configuration to register * @param name [in] module name * * @return TRUE on success, FALSE on failure *  * @callgraph * @callergraph * @ingroup jconf */booleanj_jconf_am_regist(Jconf *jconf, JCONF_AM *amconf, char *name){  JCONF_AM *atmp;  if (!name) {    jlog("ERROR: j_jconf_am_regist: no name specified to register an AM conf\n");    return FALSE;  }  for(atmp = jconf->am_root; atmp; atmp = atmp->next) {    if (strmatch(atmp->name, name)) {      jlog("ERROR: j_jconf_am_regist: failed to regist an AM conf: the same name \"%s\" already exist\n", atmp->name);      return FALSE;    }  }  /* set name */  strncpy(amconf->name, name, JCONF_MODULENAME_MAXLEN);  /* append to last */  amconf->next = NULL;  if (jconf->am_root == NULL) {    amconf->id = 1;    jconf->am_root = amconf;  } else {    for(atmp = jconf->am_root; atmp->next; atmp = atmp->next);    amconf->id = atmp->id + 1;    atmp->next = amconf;  }  return TRUE;}/**  * <EN> * Allocate a new language model (LM) parameter structure. * Default parameter values are set to it. * </EN> * <JA> * 咐胳モデル (LM) パラメ〖タ菇陇挛を糠たに充り烧ける * 柒婶メンバにはデフォルト猛が呈羌される.  * </JA> *  * @return the newly allocated LM parameter structure.

⌨️ 快捷键说明

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