Julius 4.2
libsent/include/sent/hmm_calc.h
説明を見る。
00001 
00019 /*
00020  * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University
00021  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00022  * Copyright (c) 2005-2011 Julius project team, Nagoya Institute of Technology
00023  * All rights reserved
00024  */
00025 
00026 #ifndef __SENT_HMM_CALC_H__
00027 #define __SENT_HMM_CALC_H__
00028 
00029 #include <sent/stddefs.h>
00030 #include <sent/htk_hmm.h>
00031 #include <sent/htk_param.h>
00032 
00044 enum{GPRUNE_SEL_UNDEF, GPRUNE_SEL_NONE, GPRUNE_SEL_SAFE, GPRUNE_SEL_HEURISTIC, GPRUNE_SEL_BEAM, GPRUNE_SEL_USER};
00045 
00053 #define TMBEAMWIDTH 5.0
00054 
00056 typedef struct {
00057   LOGPROB score;                
00058   int id;               
00059 } MIXCACHE;
00060 
00065 typedef struct __hmmwork__{
00066 
00067   /* pointer to functions, selected by model configuration */
00068 
00070   LOGPROB (*calc_outprob)(struct __hmmwork__ *);
00071 
00073   LOGPROB (*calc_outprob_state)(struct __hmmwork__ *);
00074 
00076   void (*compute_gaussset)(struct __hmmwork__ *, HTK_HMM_Dens **g, int num, int *last_id, int lnum);
00077 
00079   boolean (*compute_gaussset_init)(struct __hmmwork__ *);
00080 
00082   void (*compute_gaussset_free)(struct __hmmwork__ *);
00083 
00084   /* local storage of pointers to the HMM */
00085   HTK_HMM_INFO *OP_hmminfo; 
00086   HTK_HMM_INFO *OP_gshmm; 
00087 
00088   /* local storage of input parameters */
00089   HTK_Param *OP_param;  
00090   int OP_gprune_num; 
00091   int OP_time;          
00092   int OP_last_time;     
00093 
00094   /* current computing state */
00095   HTK_HMM_State *OP_state;      
00096   int OP_state_id;              
00097 
00098   /* for multi-stream input */
00099   short OP_nstream;             
00100   VECT *OP_vec_stream[MAXSTREAMNUM]; 
00101   short OP_veclen_stream[MAXSTREAMNUM]; 
00102 
00103   /* temporal buffers to hold result of mixture computation at each stream */
00104   VECT *OP_vec;         
00105   short OP_veclen;              
00106   int OP_calced_maxnum; 
00107   LOGPROB *OP_calced_score; 
00108   int *OP_calced_id; 
00109   int OP_calced_num; 
00110 
00111   /* state level cache */
00112   int statenum;         
00113   LOGPROB **outprob_cache; 
00114   int outprob_allocframenum;    
00115   BMALLOC_BASE *croot;  
00116   LOGPROB *last_cache;  
00117 
00118   /* mixture level cache for tied-mixture model */
00119   MIXCACHE ***mixture_cache; 
00120   short **mixture_cache_num; 
00121   BMALLOC_BASE *mroot;  
00122 
00123   /* work area for tied-mixture computation */
00124   int *tmix_last_id;            
00125   int tmix_allocframenum;       
00126 
00127   /* work area for gaussian pruning (common) */
00128   boolean *mixcalced;   
00129   /* for beam gaussian pruning */
00130   LOGPROB *dimthres;    
00131   int dimthres_num;     
00132   /* for heuristic gaussian pruning */
00133   LOGPROB *backmax;     
00134   int backmax_num;              
00135 
00136   /* work area for outprob_cd_nbest */
00137   LOGPROB *cd_nbest_maxprobs;   
00138   int cd_nbest_maxn;            
00139 
00140   /* work area for GMS */
00141   /* GMS variables */
00142   int my_nbest;         
00143   int gms_allocframenum;        
00144   /* GMS info */
00145   GS_SET *gsset;                
00146   int gsset_num;                
00147   int *state2gs; 
00148   /* GMS results */
00149   boolean *gms_is_selected;     
00150   LOGPROB **fallback_score; 
00151   /* GMS calculation */
00152   int *gsindex;         
00153   LOGPROB *t_fs;                
00154   /* GMS gprune local cache */
00155   int **gms_last_max_id_list;   
00156 
00157 } HMMWork;  
00158 
00159 
00160 #ifdef __cplusplus
00161 extern "C" {
00162 #endif
00163 
00164 /* addlog.c */
00165 void make_log_tbl();
00166 LOGPROB addlog(LOGPROB x, LOGPROB y);
00167 LOGPROB addlog_array(LOGPROB *x, int n);
00168 
00169 /* outprob_init.c */
00170 boolean
00171 outprob_init(HMMWork *wrk, HTK_HMM_INFO *hmminfo,
00172              HTK_HMM_INFO *gshmm, int gms_num,
00173              int gprune_method, int gprune_mixnum
00174              );
00175 boolean outprob_prepare(HMMWork *wrk, int framenum);
00176 void outprob_free(HMMWork *wrk);
00177 /* outprob.c */
00178 boolean outprob_cache_init(HMMWork *wrk);
00179 boolean outprob_cache_prepare(HMMWork *wrk);
00180 void outprob_cache_free(HMMWork *wrk);
00181 LOGPROB outprob_state(HMMWork *wrk, int t, HTK_HMM_State *stateinfo, HTK_Param *param);
00182 void outprob_cd_nbest_init(HMMWork *wrk, int num);
00183 void outprob_cd_nbest_free(HMMWork *wrk);
00184 LOGPROB outprob_cd(HMMWork *wrk, int t, CD_State_Set *lset, HTK_Param *param);
00185 /* gms.c */
00186 boolean gms_init(HMMWork *wrk);
00187 boolean gms_prepare(HMMWork *wrk, int framelen);
00188 void gms_free(HMMWork *wrk);
00189 LOGPROB gms_state(HMMWork *wrk);
00190 /* gms_gprune.c */
00191 void gms_gprune_init(HMMWork *wrk);
00192 void gms_gprune_prepare(HMMWork *wrk);
00193 void gms_gprune_free(HMMWork *wrk);
00194 void compute_gs_scores(HMMWork *wrk);
00195 
00196 /* calc_mix.c */
00197 LOGPROB calc_mix(HMMWork *wrk);
00198 /* calc_tied_mix.c */
00199 boolean calc_tied_mix_init(HMMWork *wrk);
00200 boolean calc_tied_mix_prepare(HMMWork *wrk, int framenum);
00201 void calc_tied_mix_free(HMMWork *wrk);
00202 LOGPROB calc_tied_mix(HMMWork *wrk);
00203 LOGPROB calc_compound_mix(HMMWork *wrk);
00204 
00205 /* gprune_common.c */
00206 int cache_push(HMMWork *wrk, int id, LOGPROB score, int len);
00207 /* gprune_none.c */
00208 LOGPROB compute_g_base(HMMWork *wrk, HTK_HMM_Dens *binfo);
00209 boolean gprune_none_init(HMMWork *wrk);
00210 void gprune_none_free(HMMWork *wrk);
00211 void gprune_none(HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id, int lnum);
00212 /* gprune_safe.c */
00213 LOGPROB compute_g_safe(HMMWork *wrk, HTK_HMM_Dens *binfo, LOGPROB thres);
00214 boolean gprune_safe_init(HMMWork *wrk);
00215 void gprune_safe_free(HMMWork *wrk);
00216 void gprune_safe(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum);
00217 /* gprune_heu.c */
00218 boolean gprune_heu_init(HMMWork *wrk);
00219 void gprune_heu_free(HMMWork *wrk);
00220 void gprune_heu(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum);
00221 /* gprune_beam.c */
00222 boolean gprune_beam_init(HMMWork *wrk);
00223 void gprune_beam_free(HMMWork *wrk);
00224 void gprune_beam(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum);
00225 
00226 
00227 #ifdef __cplusplus
00228 }
00229 #endif
00230 
00231 #endif /* __SENT_HMM_CALC_H__ */