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

📄 jfunc.c

📁 julius version 4.12.about sound recognition.
💻 C
📖 第 1 页 / 共 3 页
字号:
/** * @file   jfunc.c *  * <JA> * @brief  アプリケ〖ション羹けの硷」のAPI簇眶 * * このファイルには·アプリケ〖ションからJuliusLibの称怠墙を钙び叫す * API簇眶およびライブラリ步のために悸刘された硷」の簇眶が年盗されています.  *  * </JA> *  * <EN> * @brief  API functions for applications * * This file contains for API function definitions and miscellaneous * functions implemented for JuliusLib. * </EN> *  * @author Akinobu Lee * @date   Wed Aug  8 15:04:28 2007 * * $Revision: 1.5 $ *  *//* * 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> * Request engine to stop recognition.  If the engine is recognizing a * speech input, it will stop after the current recognition ended. * </EN> * <JA> * エンジンに千急借妄を办箕匿贿するよう妥滇する. この簇眶を钙叫し箕に * 不兰掐蜗を悸乖面であった眷圭·その掐蜗の千急が姜位したあとで匿贿する.  * </JA> *  * @param recog [in] engine instance * * @callgraph * @callergraph * @ingroup pauseresume *  */voidj_request_pause(Recog *recog){  /* pause recognition: will stop when the current input ends */  if (recog->process_active) {    recog->process_want_terminate = FALSE;    recog->process_want_reload = TRUE;    recog->process_active = FALSE;  }  /* control the A/D-in module to stop recording */  if (recog->jconf->input.type == INPUT_WAVEFORM) {    if (recog->adin->ad_pause != NULL) {      (*(recog->adin->ad_pause))();    }  } else {    /* feature vector input */    if (recog->jconf->input.speech_input == SP_MFCMODULE) {      if (recog->mfcclist->func.fv_pause) recog->mfcclist->func.fv_pause();    }  }}/**  * <EN> * Request engine to terminate recognition immediately.  Even if the engine * is recognizing a speech input, it will stop immediately (in this case the * current input will be lost). * </EN> * <JA> * エンジンに千急借妄を篓箕匿贿するよう妥滇する. この簇眶を钙叫し箕に * 不兰掐蜗を悸乖面の眷圭·その掐蜗を撬逮して篓郝に匿贿する.  * </JA> *  * @param recog [in] engine instance *  * @callgraph * @callergraph * @ingroup pauseresume */voidj_request_terminate(Recog *recog){  /* terminate recognition: input will terminate immidiately */  /* set flags to stop adin to terminate immediately, and     stop process */  if (recog->process_active) {    recog->process_want_terminate = TRUE;    recog->process_want_reload = TRUE;    recog->process_active = FALSE;  }  if (recog->jconf->input.type == INPUT_WAVEFORM) {    if (recog->adin->ad_terminate != NULL) {      /* control the A/D-in module to terminate recording imemdiately */      (*(recog->adin->ad_terminate))();    }  } else {    /* feature vector input */    if (recog->jconf->input.speech_input == SP_MFCMODULE) {      if (recog->mfcclist->func.fv_terminate) recog->mfcclist->func.fv_terminate();    }  }}/**  * <EN> * Resume the engine which has already paused or terminated. * </EN> * <JA> * 办箕匿贿しているエンジンを浩倡させる.  * </JA> *  * @param recog  *  * @callgraph * @callergraph * @ingroup pauseresume */void j_request_resume(Recog *recog){  if (recog->process_active == FALSE) {    recog->process_want_terminate = FALSE;    recog->process_active = TRUE;  }  /* control the A/D-in module to restart recording now */  if (recog->jconf->input.type == INPUT_WAVEFORM) {    if (recog->adin->ad_resume != NULL) {      (*(recog->adin->ad_resume))();    }  } else {    /* feature vector input */    if (recog->jconf->input.speech_input == SP_MFCMODULE) {      if (recog->mfcclist->func.fv_resume) recog->mfcclist->func.fv_resume();    }  }}/**  * <EN> Request engine to check update of all grammar and re-construct * the glocal lexicon if needed.  The actual update will be done * between input segment.  This function should be called after some * grammars are modified. *  * </EN> * <JA> * 链矢恕の恃构をチェックし·涩妥であれば千急脱辑今を浩菇蜜するよう * エンジンに妥滇する. 悸狠の借妄は肌の千急の圭粗に乖われる.  * この簇眶は矢恕を纳裁したり猴近したなど· * 矢恕リストに恃构を裁えたあとに涩ず钙ぶべきである.  *  * </JA> *  * @param recog [in] engine instance *  * @callgraph * @callergraph * @ingroup grammar */voidschedule_grammar_update(Recog *recog){  if (recog->process_active) {    /* if recognition is currently running, tell engine how/when to       re-construct global lexicon. */    switch(recog->gram_switch_input_method) {    case SM_TERMINATE:	/* discard input now and change (immediate) */      recog->process_want_terminate = TRUE;      recog->process_want_reload = TRUE;      break;    case SM_PAUSE:		/* segment input now, recognize it, and then change */      recog->process_want_terminate = FALSE;      recog->process_want_reload = TRUE;      break;    case SM_WAIT:		/* wait until the current input end and recognition completed */      recog->process_want_terminate = FALSE;      recog->process_want_reload = FALSE;      break;    }    /* After the update, recognition will restart without sleeping. */  } else {    /* If recognition is currently not running, the received       grammars are merely stored in memory here.  The re-construction of       global lexicon will be delayed: it will be re-built just before       the recognition process starts next time. */  }}/**  * <JA> * 浩菇蜜妥滇フラグをクリアする.  *  * </JA> * <EN> * Clear the grammar re-construction flag. *  * </EN> * * @param recog [in] engine instance *  * @callgraph * @callergraph * @ingroup grammar */voidj_reset_reload(Recog *recog){  recog->process_want_reload = FALSE;}/**  * <EN> * Enable debug messages in JuliusLib to log. * </EN> * <JA> * JuliusLib柒の簇眶でデバッグメッセ〖ジをログに叫蜗するようにする * </JA> * @callgraph * @callergraph * @ingroup engine */voidj_enable_debug_message(){  debug2_flag = TRUE;}/**  * <EN> * Disable debug messages in JuliusLib to log. * </EN> * <JA> * JuliusLib柒の簇眶でデバッグメッセ〖ジを叫さないようにする.  * </JA> *  * @callgraph * @callergraph * @ingroup engine */voidj_disable_debug_message(){  debug2_flag = FALSE;}/**  * <EN> * Enable verbose messages in JuliusLib to log. * </EN> * <JA> * JuliusLib柒の簇眶で肩妥メッセ〖ジをログに叫蜗するようにする.  * </JA> *  * @callgraph * @callergraph * @ingroup engine */voidj_enable_verbose_message(){  verbose_flag = TRUE;}/**  * <EN> * Disable verbose messages in JuliusLib to log. * </EN> * <JA> * JuliusLib柒の簇眶で肩妥メッセ〖ジのログ叫蜗をしないようにする.  * </JA> *  * @callgraph * @callergraph * @ingroup engine */voidj_disable_verbose_message(){  verbose_flag = FALSE;}	      /**  * Output error message and exit the program.  This is just for * internal use. *  * @param fmt [in] format string, like printf. * @param ... [in] variable length argument like printf. *  */voidj_internal_error(char *fmt, ...){  va_list ap;  int ret;  va_start(ap,fmt);  ret = vfprintf(stderr, fmt, ap);  va_end(ap);  /* clean up socket if already opened */  cleanup_socket();  exit(1);}/**  * <EN> * Load parameters from command argments, and set to each configuration * instances in jconf. * </EN> * <JA> * コマンド苞眶からパラメ〖タを粕み哈み·jconf 柒の称肋年インスタンスに * 猛を呈羌する.  * </JA> *  * @param jconf [i/o] global configuration instance * @param argc [in] number of arguments * @param argv [in] list of argument strings *  * @return 0 on success, or -1 on failure. *  * @callgraph * @callergraph * @ingroup jconf */intj_config_load_args(Jconf *jconf, int argc, char *argv[]){  JCONF_AM *am;  JCONF_LM *lm;  JCONF_SEARCH *s;  /* parse options and set variables */  if (opt_parse(argc, argv, NULL, jconf) == FALSE) {    return -1;  }  /* if multiple instances defined from init, remove initial one (id=0) */  if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {    am = jconf->am_root->next;    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);    jconf->lm_root = lm;  }  if(jconf->search_root->next != NULL && jconf->search_root->id == 0) {    s = jconf->search_root->next;    free(jconf->search_root);    jconf->search_root = s;  }  return 0;}/**  * <EN> * Load parameters from a jconf file and set to each configuration * instances in jconf. * </EN> * <JA> * jconf ファイルからパラメ〖タを粕み哈み·jconf 柒の称肋年インスタンスに * 猛を呈羌する.  * </JA> *  * @param jconf [i/o] glbal configuration instance * @param filename [in] jconf filename *  * @return 0 on sucess, or -1 on failure. *  * @callgraph * @callergraph * @ingroup jconf */intj_config_load_file(Jconf *jconf, char *filename){  JCONF_AM *am;  JCONF_LM *lm;  JCONF_SEARCH *s;  /* parse options and set variables */  if (config_file_parse(filename, jconf) == FALSE) {    return -1;  }  /* if multiple instances defined from init, remove initial one (id=0) */  if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {    am = jconf->am_root->next;    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);    jconf->lm_root = lm;  }  if(jconf->search_root->next != NULL && jconf->search_root->id == 0) {    s = jconf->search_root->next;    free(jconf->search_root);    jconf->search_root = s;  }  return 0;}/**  * <EN> * Create a new configuration instance and load parameters from command * argments. * </EN> * <JA> * コマンド苞眶からパラメ〖タを粕み哈み·その猛を呈羌した * 糠たな肋年インスタンスを充り烧けて手す.  * </JA> *  * @param argc [in] number of arguments * @param argv [in] list of argument strings *  * @return the newly allocated global configuration instance. *  * @callgraph * @callergraph * @ingroup jconf */Jconf *j_config_load_args_new(int argc, char *argv[]){  Jconf *jconf;  JCONF_AM *am;  JCONF_LM *lm;  JCONF_SEARCH *s;  jconf = j_jconf_new();  /* parse options and set variables */  if (opt_parse(argc, argv, NULL, jconf) == FALSE) {    j_jconf_free(jconf);    return NULL;  }  /* if multiple instances defined from init, remove initial one (id=0) */  if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {    am = jconf->am_root->next;    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);    jconf->lm_root = lm;  }  if(jconf->search_root->next != NULL && jconf->search_root->id == 0) {    s = jconf->search_root->next;    free(jconf->search_root);    jconf->search_root = s;  }  return jconf;}/**  * <EN> * Create a new configuration instance and load parameters from a jconf * file. * </EN> * <JA> * 糠たな肋年インスタンスを充り烧け·そこに * jconfファイルから肋年パラメ〖タを粕み哈んで手す.  * </JA> *  * @param filename [in] jconf filename *  * @return the newly allocated global configuration instance. *  * @callgraph * @callergraph * @ingroup jconf */Jconf *j_config_load_file_new(char *filename){  Jconf *jconf;  JCONF_AM *am;  JCONF_LM *lm;  JCONF_SEARCH *s;  jconf = j_jconf_new();  /* parse options and set variables */  if (config_file_parse(filename, jconf) == FALSE) {    j_jconf_free(jconf);    return NULL;  }  /* if multiple instances defined from init, remove initial one (id=0) */  if(jconf->am_root->next != NULL && jconf->am_root->id == 0) {    am = jconf->am_root->next;    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);    jconf->lm_root = lm;  }  if(jconf->search_root->next != NULL && jconf->search_root->id == 0) {    s = jconf->search_root->next;    free(jconf->search_root);

⌨️ 快捷键说明

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