sumom****@users*****
sumom****@users*****
2008年 9月 25日 (木) 14:00:05 JST
Index: julius4/libjulius/include/julius/config.h.in diff -u julius4/libjulius/include/julius/config.h.in:1.2 julius4/libjulius/include/julius/config.h.in:1.3 --- julius4/libjulius/include/julius/config.h.in:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/include/julius/config.h.in Thu Sep 25 14:00:05 2008 @@ -28,7 +28,7 @@ * @author Akinobu LEE * @date Sat Feb 19 12:53:54 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ @@ -245,3 +245,9 @@ * */ #undef POWER_REJECT + +/** + * If defined, enable plugin support using dynamic object loading + * + */ +#undef ENABLE_PLUGIN Index: julius4/libjulius/include/julius/extern.h diff -u julius4/libjulius/include/julius/extern.h:1.6 julius4/libjulius/include/julius/extern.h:1.7 --- julius4/libjulius/include/julius/extern.h:1.6 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/include/julius/extern.h Thu Sep 25 14:00:05 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Mon Mar 7 23:19:14 2005 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -143,6 +143,7 @@ void RealTimeCMNUpdate(MFCCCalc *mfcc, Recog *recog); void RealTimeTerminate(Recog *recog); void realbeam_free(Recog *recog); +int mfcc_go(Recog *recog, int (*ad_check)(Recog *)); /* word_align.c */ void word_align(WORD_ID *words, short wnum, HTK_Param *param, Sentence *s, RecogProcess *r); @@ -173,7 +174,6 @@ void system_bootup(Recog *recog); /* m_adin.c */ boolean adin_initialize(Recog *recog); -boolean adin_initialize_user(Recog *recog, void *arg); /* m_fusion.c */ boolean j_load_am(Recog *recog, JCONF_AM *amconf); boolean j_load_lm(Recog *recog, JCONF_LM *lmconf); @@ -290,3 +290,24 @@ void result_sentence_malloc(RecogProcess *r, int num); void result_sentence_free(RecogProcess *r); void clear_result(RecogProcess *r); + +/* plugin.c */ +int plugin_get_id(char *name); +void plugin_init(); +boolean plugin_load_file(char *file); +boolean plugin_load_dir(char *dir); +void plugin_load_dirs(char *dirent); +int plugin_find_optname(char *optfuncname, char *str); +FUNC_VOID plugin_get_func(int sid, char *name); +boolean plugin_exec_engine_startup(Recog *recog); +void plugin_exec_adin_captured(short *buf, int len); +void plugin_exec_adin_triggered(short *buf, int len); +void plugin_exec_vector_postprocess(VECT *vecbuf, int veclen, int nframe); +void plugin_exec_vector_postprocess_all(HTK_Param *param); +void plugin_exec_process_result(Recog *recog); +boolean mfc_module_init(MFCCCalc *mfcc, Recog *recog); +boolean mfc_module_set_header(MFCCCalc *mfcc, Recog *recog); +boolean mfc_module_standby(MFCCCalc *mfcc); +boolean mfc_module_begin(MFCCCalc *mfcc); +boolean mfc_module_end(MFCCCalc *mfcc); +int mfc_module_read(MFCCCalc *mfcc, int *new_t); Index: julius4/libjulius/include/julius/global.h diff -u julius4/libjulius/include/julius/global.h:1.3 julius4/libjulius/include/julius/global.h:1.4 --- julius4/libjulius/include/julius/global.h:1.3 Tue Mar 18 01:58:38 2008 +++ julius4/libjulius/include/julius/global.h Thu Sep 25 14:00:05 2008 @@ -14,7 +14,7 @@ * @author Akinobu Lee * @date Sun Sep 18 23:53:17 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -31,6 +31,7 @@ #include <sent/vocabulary.h> #include <julius/wchmm.h> #include <julius/search.h> +#include <julius/plugin.h> /** * If GLOBAL_VARIABLE_DEFINE is defined, global variables are actually made. @@ -50,4 +51,8 @@ GLOBAL boolean debug2_flag GLOBAL_VAL(FALSE); GLOBAL boolean callback_debug_flag GLOBAL_VAL(FALSE); +/* function list for adin process callback */ +GLOBAL PLUGIN_ENTRY **global_plugin_list GLOBAL_VAL(NULL); +GLOBAL int global_plugin_loaded_file_num GLOBAL_VAL(0); + #endif /* __J_GLOBAL_H__ */ Index: julius4/libjulius/include/julius/jconf.h diff -u julius4/libjulius/include/julius/jconf.h:1.6 julius4/libjulius/include/julius/jconf.h:1.7 --- julius4/libjulius/include/julius/jconf.h:1.6 Thu Sep 25 13:22:57 2008 +++ julius4/libjulius/include/julius/jconf.h Thu Sep 25 14:00:05 2008 @@ -23,7 +23,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -209,6 +209,11 @@ char *ssload_filename; } frontend; + /** + * Plugin source ID when using plugin (gprune_method is GPRUNE_SEL_USER) + */ + int gprune_plugin_source; + /* pointer to next instance */ struct __jconf_am__ *next; @@ -763,15 +768,29 @@ struct { /** + * Input source type. (waveform / mfc) + * + */ + int type; + + /** * Input source. * */ int speech_input; + /** * Input device. * */ int device; + + /** + * id of the selected plug-in if using plugin + * + */ + int plugin_source; + /** * Sampling frequency * Index: julius4/libjulius/include/julius/jfunc.h diff -u julius4/libjulius/include/julius/jfunc.h:1.3 julius4/libjulius/include/julius/jfunc.h:1.4 --- julius4/libjulius/include/julius/jfunc.h:1.3 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/include/julius/jfunc.h Thu Sep 25 14:00:05 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Tue Nov 6 22:41:00 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -51,7 +51,6 @@ Jconf *j_config_load_args_new(int argc, char *argv[]); Jconf *j_config_load_file_new(char *filename); boolean j_adin_init(Recog *recog); -boolean j_adin_init_user(Recog *recog, void *arg); char *j_get_current_filename(); void j_recog_info(Recog *recog); Recog *j_create_instance_from_jconf(Jconf *jconf); Index: julius4/libjulius/include/julius/julius.h diff -u julius4/libjulius/include/julius/julius.h:1.2 julius4/libjulius/include/julius/julius.h:1.3 --- julius4/libjulius/include/julius/julius.h:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/include/julius/julius.h Thu Sep 25 14:00:05 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Mar 17 21:08:21 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -57,6 +57,9 @@ #include <sent/dfa.h> /* read Julius/Julian includes */ +#ifdef ENABLE_PLUGIN +#include <julius/plugin.h> +#endif #include <julius/multi-gram.h> #include <julius/wchmm.h> #include <julius/trellis.h> Index: julius4/libjulius/include/julius/plugin.h diff -u /dev/null julius4/libjulius/include/julius/plugin.h:1.1 --- /dev/null Thu Sep 25 14:00:05 2008 +++ julius4/libjulius/include/julius/plugin.h Thu Sep 25 14:00:05 2008 @@ -0,0 +1,109 @@ +/** + * @file plugin.h + * + * <EN> + * @brief Plugin related header + * </EN> + * + * <JA> + * @brief プラグイン用ヘッダ + * </JA> + * + * @author Akinobu Lee + * @date Sat Aug 2 13:04:15 2008 + * + * $Revision: 1.1 $ + * + */ +/* + * Copyright (c) 1991-2008 Kawahara Lab., Kyoto University + * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology + * Copyright (c) 2005-2008 Julius project team, Nagoya Institute of Technology, Nagoya Institute of Technology + * All rights reserved + */ + +#ifndef __JULIUS_PLUGIN__ +#define __JULIUS_PLUGIN__ + +#include <sent/stddefs.h> + +/** + * Plug-in file suffix + * + */ +#define PLUGIN_SUFFIX ".jpi" + +/** + * List of plugin function names + * + */ +#define PLUGIN_FUNCTION_NAMELIST { \ + "adin_get_optname", \ + "adin_get_configuration", "adin_standby", \ + "adin_open", "adin_read", "adin_close", \ + "adin_resume", "adin_pause", "adin_terminate", \ + "adin_postprocess", "adin_postprocess_triggered", \ + "fvin_get_optname", \ + "fvin_get_configuration", "fvin_standby", \ + "fvin_open", "fvin_read", "fvin_close", \ + "fvin_resume", "fvin_pause", "fvin_terminate", \ + "fvin_postprocess", \ + "calcmix_get_optname", "calcmix", "calcmix_init", "calcmix_free", \ + "result_best_str", \ + "startup"} + +/** + * Typedef for loaded module + * + */ +#if defined(_WIN32) && !defined(__CYGWIN32__) +typedef HMODULE PLUGIN_MODULE; +#else +typedef void* PLUGIN_MODULE; +#endif + +/** + * define for "none" + * + */ +#define PLUGIN_NONE NULL + +/** + * Function definition + * + */ +typedef void (*FUNC_VOID)(); +typedef char * (*FUNC_STR)(); +typedef int (*FUNC_INT)(); + +/** + * Plugin function entry + * + */ +typedef struct __j_plugin_entry__ { + int id; + int source_id; + FUNC_VOID func; + struct __j_plugin_entry__ *next; +} PLUGIN_ENTRY; + +/* include headers for dynamic loading */ +/* unix, cygwin = dlopen */ +/* mingw, VS = non (should emulate using win32 func.) */ +#ifdef _WIN32 +# ifdef __CYGWIN32__ +# include <dlfcn.h> +# else +# include <windows.h> +# include <errno.h> +# define dlopen(P,G) (void *)LoadLibrary(P) +# define dlsym(D, F) (void *)GetProcAddress((HMODULE)D, F) +# define dlclose(D) FreeLibrary((HMODULE)D) +/* dlerror() is defined in plugins.c */ +# define RTLD_LAZY 0 /* dummy */ +# endif +#else /* UNIX */ +# include <dlfcn.h> +#endif + +#endif /* __JULIUS_PLUGIN__ */ Index: julius4/libjulius/include/julius/recog.h diff -u julius4/libjulius/include/julius/recog.h:1.3 julius4/libjulius/include/julius/recog.h:1.4 --- julius4/libjulius/include/julius/recog.h:1.3 Mon Jul 7 14:50:10 2008 +++ julius4/libjulius/include/julius/recog.h Thu Sep 25 14:00:05 2008 @@ -45,13 +45,13 @@ * +- MFCCCalc[] (linked list) (generated from HMM + GMM) * +- PROCESS_AM[] (linked list) * +- *pointer to JCONF_AM - * +- *pointer to MFCCCalc + * +- *pointer to MFCCCalc * +- hmminfo, hmm_gs * +- hmmwrk - * +- multipath, ccd_flag, cmn_loaded + * +- multipath, ccd_flag, cmn_loaded * +- PROCESS_LM[] (linked list) * +- *pointer to JCONF_LM - * +- *pointer to PROCESS_AM + * +- *pointer to PROCESS_AM * +- lmtype, lmvar * +- winfo * +- ngram or grammars @@ -60,8 +60,8 @@ * +- *pointer to JCONF_SEARCH * +- *pointer to PROCESS_AM * +- *pointer to PROCESS_LM - * +- lmtype, lmvar - * +- misc. param + * +- lmtype, lmvar + * +- misc. param * +- GMMCalc * +- *JCONF_AM for GMM * +- *pointer to MFCCCalc @@ -70,7 +70,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -129,9 +129,9 @@ #ifdef UNIGRAM_FACTORING /* for wordend processing with 1-gram factoring */ LOGPROB wordend_best_score; ///< Best score of word-end nodes - int wordend_best_node; ///< Node id of the best wordend nodes + int wordend_best_node; ///< Node id of the best wordend nodes TRELLIS_ATOM *wordend_best_tre; ///< Trellis word corresponds to above - WORD_ID wordend_best_last_cword; ///< Last context-aware word of above + WORD_ID wordend_best_last_cword; ///< Last context-aware word of above #endif int totalnodenum; ///< Allocated number of nodes in @a token @@ -155,15 +155,15 @@ boolean first_sparea; ///< TRUE when we are in the first pause area int sp_duration; ///< Number of current successive sp frame #ifdef SPSEGMENT_NAIST - boolean after_trigger; ///< TRUE if speech already triggered - int trigger_duration; ///< Current speech duration at uptrigger detection - boolean want_rewind; ///< TRUE if process wants mfcc rewinding - int rewind_frame; ///< Place to rewind to + boolean after_trigger; ///< TRUE if speech already triggered + int trigger_duration; ///< Current speech duration at uptrigger detection + boolean want_rewind; ///< TRUE if process wants mfcc rewinding + int rewind_frame; ///< Place to rewind to boolean want_rewind_reprocess; ///< TRUE if requires re-processing after rewind #endif - char *pausemodelnames; ///< pause model name string to detect segment - char **pausemodel; ///< each pause model name to detect segment - int pausemodelnum; ///< num of pausemodel + char *pausemodelnames; ///< pause model name string to detect segment + char **pausemodel; ///< each pause model name to detect segment + int pausemodelnum; ///< num of pausemodel } FSBeam; @@ -205,38 +205,38 @@ NODE *current; ///< Current node for debug #ifdef CONFIDENCE_MEASURE - LOGPROB cm_alpha; ///< alpha scaling value from jconf + LOGPROB cm_alpha; ///< alpha scaling value from jconf # ifdef CM_MULTIPLE_ALPHA - LOGPROB *cmsumlist; ///< Sum of cm score for each alpha coef. - int cmsumlistlen; ///< Allocated length of cmsumlist. + LOGPROB *cmsumlist; ///< Sum of cm score for each alpha coef. + int cmsumlistlen; ///< Allocated length of cmsumlist. # endif # ifdef CM_SEARCH LOGPROB cm_tmpbestscore; ///< Temporal best score for summing up scores # ifndef CM_MULTIPLE_ALPHA - LOGPROB cm_tmpsum; ///< Sum of CM score + LOGPROB cm_tmpsum; ///< Sum of CM score # endif - int l_stacksize; ///< Local stack size for CM - int l_stacknum; ///< Num of hypo. in local stack for CM - NODE *l_start; ///< Top node of local stack for CM - NODE *l_bottom; ///< bottom node of local stack for CM + int l_stacksize; ///< Local stack size for CM + int l_stacknum; ///< Num of hypo. in local stack for CM + NODE *l_start; ///< Top node of local stack for CM + NODE *l_bottom; ///< bottom node of local stack for CM # endif # ifdef CM_NBEST - LOGPROB *sentcm = NULL; ///< Confidence score of each sentence - LOGPROB *wordcm = NULL; ///< Confidence score of each word voted from @a sentcm - int sentnum; ///< Allocated length of @a sentcm + LOGPROB *sentcm = NULL; ///< Confidence score of each sentence + LOGPROB *wordcm = NULL; ///< Confidence score of each word voted from @a sentcm + int sentnum; ///< Allocated length of @a sentcm # endif #endif /* CONFIDENCE_MEASURE */ LOGPROB *wordtrellis[2]; ///< Buffer to compute viterbi path of a word - LOGPROB *g; ///< Buffer to hold source viterbi scores - HMM_Logical **phmmseq; ///< Phoneme sequence to be computed - int phmmlen_max; ///< Maximum length of @a phmmseq. - boolean *has_sp; ///< Mark which phoneme allow short pause for multi-path mode + LOGPROB *g; ///< Buffer to hold source viterbi scores + HMM_Logical **phmmseq; ///< Phoneme sequence to be computed + int phmmlen_max; ///< Maximum length of @a phmmseq. + boolean *has_sp; ///< Mark which phoneme allow short pause for multi-path mode #ifdef GRAPHOUT_PRECISE_BOUNDARY short *wend_token_frame[2]; ///< Propagating token of word-end frame to detect corresponding end-of-words at word head LOGPROB *wend_token_gscore[2]; ///< Propagating token of scores at word-end to detect corresponding end-of-words at word head - short *wef; ///< Work area for word-end frame tokens for v2 - LOGPROB *wes; ///< Work area for word-end score tokens for v2 + short *wef; ///< Work area for word-end frame tokens for v2 + LOGPROB *wes; ///< Work area for word-end score tokens for v2 #endif } StackDecode; @@ -257,10 +257,10 @@ */ typedef struct __gmm_calc__{ LOGPROB *gmm_score; ///< Current accumurated scores for each GMM - boolean *is_voice; ///< True if corresponding model designates speech, FALSE if noise + boolean *is_voice; ///< True if corresponding model designates speech, FALSE if noise int framecount; ///< Current frame count - short OP_nstream; ///< Number of input stream for GMM + short OP_nstream; ///< Number of input stream for GMM VECT *OP_vec_stream[MAXSTREAMNUM]; ///< input vector for each stream at that frame short OP_veclen_stream[MAXSTREAMNUM]; ///< vector length for each stream @@ -272,24 +272,24 @@ VECT *OP_vec; ///< Local workarea to hold the input vector of current frame short OP_veclen; ///< Local workarea to hold the length of above HTK_HMM_Data *max_d; ///< Hold model of the maximum score - int max_i; ///< Index of max_d + int max_i; ///< Index of max_d #ifdef CONFIDENCE_MEASURE LOGPROB gmm_max_cm; ///< Hold maximum score #endif #ifdef GMM_VAD LOGPROB *rates; ///< voice rate of recent N frames (cycle buffer) - int nframe; ///< Length of rates + int nframe; ///< Length of rates boolean filled; - int framep; ///< Current frame pointer + int framep; ///< Current frame pointer - boolean in_voice; ///< TRUE if currently in voice area - boolean up_trigger; ///< TRUE when detect up trigger - boolean down_trigger; ///< TRUE when detect down trigger - boolean after_trigger; ///< TRUE when currently we are processing speech segment - boolean want_rewind; ///< TRUE if GMM wants rewinding its MFCC + boolean in_voice; ///< TRUE if currently in voice area + boolean up_trigger; ///< TRUE when detect up trigger + boolean down_trigger; ///< TRUE when detect down trigger + boolean after_trigger; ///< TRUE when currently we are processing speech segment + boolean want_rewind; ///< TRUE if GMM wants rewinding its MFCC boolean want_rewind_reprocess; ///< TRUE if GMM wants re-processing after rewind - int rewind_frame; ///< Frame to rewind - int duration; ///< Current GMM duration work + int rewind_frame; ///< Frame to rewind + int duration; ///< Current GMM duration work #endif } GMMCalc; @@ -298,7 +298,7 @@ * */ typedef struct __sentence__ { - WORD_ID word[MAXSEQNUM]; ///< Sequence of word ID + WORD_ID word[MAXSEQNUM]; ///< Sequence of word ID int word_num; ///< Number of words in the sentence LOGPROB score; ///< Likelihood (LM+AM) LOGPROB confidence[MAXSEQNUM]; ///< Word confidence scores @@ -345,6 +345,8 @@ boolean (*ad_resume)(); /// Pointer to function to pause recording boolean (*ad_pause)(); + /// Pointer to function to terminate current recording immediately + boolean (*ad_terminate)(); /// Pointer to function to read samples int (*ad_read)(SP16 *, int); @@ -366,7 +368,7 @@ int sblen; ///< Current length of @a swapbuf int rest_tail; ///< Samples not processed yet in swap buffer - ZEROCROSS zc; ///< Work area for zero-cross computation + ZEROCROSS zc; ///< Work area for zero-cross computation #ifdef HAVE_PTHREAD /* Variables related to POSIX threading */ @@ -388,6 +390,11 @@ * */ boolean adinthread_buffer_overflowed; + /** + * TRUE if adin thread ended + * + */ + boolean adinthread_ended; boolean ignore_speech_while_recog; ///< TRUE if ignore speech input between call, while waiting recognition process @@ -408,9 +415,12 @@ boolean end_of_stream; ///< TRUE if we have reached the end of stream boolean need_init; ///< if TRUE, initialize buffer on startup - DS_BUFFER *ds; ///< Filter buffer for 48-to-16 conversion + DS_BUFFER *ds; ///< Filter buffer for 48-to-16 conversion boolean rehash; ///< TRUE is want rehash at rewinding on decoder-based VAD + + boolean input_side_segment; ///< TRUE if segmentation requested by ad_read + } ADIn; /** @@ -440,7 +450,7 @@ WordGraph *wg; ///< List of word graph - CN_CLUSTER *confnet; ///< List of confusion network clusters + CN_CLUSTER *confnet; ///< List of confusion network clusters Sentence pass1; ///< Recognition result on the 1st pass @@ -642,6 +652,39 @@ */ boolean segmented; + /** + * TRUE if an input functionhas decided segmented + * + */ + boolean segmented_by_input; + + /** + * id of an plugin module if MFCC should be obtained via plugin + * + */ + int plugin_source; + + /** + * Function entry points for plugin input + * + */ + struct { + /// Pointer to function for device initialization (call once on startup) + boolean (*fv_standby)(); + /// Pointer to function to open audio stream for capturing + boolean (*fv_begin)(); + /// Pointer to function to read samples + int (*fv_read)(VECT *, int); + /// Pointer to function to close audio stream capturing + boolean (*fv_end)(); + /// Pointer to function to begin / restart recording + boolean (*fv_resume)(); + /// Pointer to function to pause recording + boolean (*fv_pause)(); + /// Pointer to function to terminate current recording immediately + boolean (*fv_terminate)(); + } func; + #ifdef POWER_REJECT float avg_power; #endif