/** * <EN> * If multiple instances defined from init, remove initial one (id=0) * </EN> * <JA> * 複数インスタンスが定義されている場合、初期インスタンス(id=0)は * 無効なので消す. * </JA> * * @param jconf [i/o] global configuration instance * * @callgraph * @callergraph * @ingroup jconf */ static void j_config_remove_initial(Jconf *jconf) { JCONF_AM *am; JCONF_LM *lm; JCONF_SEARCH *s; if(jconf->am_root->next != NULL && jconf->am_root->id == 0) { am = jconf->am_root->next; /*free(jconf->am_root);*/ j_jconf_am_free(jconf->am_root); jconf->am_root = am; } if(jconf->lm_root->next != NULL && jconf->lm_root->id == 0) { lm = jconf->lm_root->next; /*free(jconf->lm_root);*/ j_jconf_lm_free(jconf->lm_root); jconf->lm_root = lm; } if(jconf->search_root->next != NULL && jconf->search_root->id == 0) { s = jconf->search_root->next; /*free(jconf->search_root);*/ j_jconf_search_free(jconf->search_root); jconf->search_root = s; } }
/** * <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 */ boolean j_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> * @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 */ boolean j_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; }