libsent/include/sent/hmm_calc.h

Go to the documentation of this file.
00001 
00019 /*
00020  * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University
00021  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00022  * Copyright (c) 2005-2007 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 
00043 enum{GPRUNE_SEL_UNDEF, GPRUNE_SEL_NONE, GPRUNE_SEL_SAFE, GPRUNE_SEL_HEURISTIC, GPRUNE_SEL_BEAM};
00044 
00052 #define TMBEAMWIDTH 5.0
00053 
00055 typedef struct {
00056   LOGPROB score;                
00057   unsigned short id;            
00058 } MIXCACHE;
00059 
00064 typedef struct __hmmwork__{
00065 
00066   /* pointer to functions, selected by model configuration */
00067 
00069   LOGPROB (*calc_outprob)(struct __hmmwork__ *);
00070 
00072   LOGPROB (*calc_outprob_state)(struct __hmmwork__ *);
00073 
00075   void (*compute_gaussset)(struct __hmmwork__ *, HTK_HMM_Dens **g, int num, int *last_id);
00076 
00078   boolean (*compute_gaussset_init)(struct __hmmwork__ *);
00079 
00081   void (*compute_gaussset_free)(struct __hmmwork__ *);
00082 
00083   /* local storage of pointers to the HMM */
00084   HTK_HMM_INFO *OP_hmminfo; 
00085   HTK_HMM_INFO *OP_gshmm; 
00086 
00087   /* local storage of input parameters */
00088   HTK_Param *OP_param;  
00089   int OP_gprune_num; 
00090   int OP_time;          
00091   int OP_last_time;     
00092   VECT *OP_vec;         
00093   short OP_veclen;              
00094 
00095   /* current computing state */
00096   HTK_HMM_State *OP_state;      
00097   int OP_state_id;              
00098 
00099   /* buffers to hold result of mixture computation */
00100   int OP_calced_maxnum; 
00101   LOGPROB *OP_calced_score; 
00102   int *OP_calced_id; 
00103   int OP_calced_num; 
00104 
00105   /* state level cache */
00106   int statenum;         
00107   LOGPROB **outprob_cache; 
00108   int outprob_allocframenum;    
00109   BMALLOC_BASE *croot;  
00110   LOGPROB *last_cache;  
00111 
00112   /* mixture level cache for tied-mixture model */
00113   MIXCACHE ***mixture_cache; 
00114   BMALLOC_BASE *mroot;  
00115 
00116   /* work area for tied-mixture computation */
00117   int *tmix_last_id;            
00118   int tmix_allocframenum;       
00119 
00120   /* work area for gaussian pruning (common) */
00121   boolean *mixcalced;   
00122   /* for beam gaussian pruning */
00123   LOGPROB *dimthres;    
00124   int dimthres_num;     
00125   /* for heuristic gaussian pruning */
00126   LOGPROB *backmax;     
00127   int backmax_num;              
00128 
00129   /* work area for outprob_cd_nbest */
00130   LOGPROB *cd_nbest_maxprobs;   
00131   int cd_nbest_maxn;            
00132 
00133   /* work area for GMS */
00134   /* GMS variables */
00135   int my_nbest;         
00136   int gms_allocframenum;        
00137   /* GMS info */
00138   GS_SET *gsset;                
00139   int gsset_num;                
00140   int *state2gs; 
00141   /* GMS results */
00142   boolean *gms_is_selected;     
00143   LOGPROB **fallback_score; 
00144   /* GMS calculation */
00145   int *gsindex;         
00146   LOGPROB *t_fs;                
00147   /* GMS gprune local cache */
00148   int *gms_last_max_id; 
00149 
00150 } HMMWork;  
00151 
00152 
00153 /* addlog.c */
00154 void make_log_tbl();
00155 LOGPROB addlog(LOGPROB x, LOGPROB y);
00156 LOGPROB addlog_array(LOGPROB *x, int n);
00157 
00158 /* outprob_init.c */
00159 boolean
00160 outprob_init(HMMWork *wrk, HTK_HMM_INFO *hmminfo,
00161              HTK_HMM_INFO *gshmm, int gms_num,
00162              int gprune_method, int gprune_mixnum
00163              );
00164 boolean outprob_prepare(HMMWork *wrk, int framenum);
00165 void outprob_free(HMMWork *wrk);
00166 /* outprob.c */
00167 boolean outprob_cache_init(HMMWork *wrk);
00168 boolean outprob_cache_prepare(HMMWork *wrk);
00169 void outprob_cache_free(HMMWork *wrk);
00170 LOGPROB outprob_state(HMMWork *wrk, int t, HTK_HMM_State *stateinfo, HTK_Param *param);
00171 void outprob_cd_nbest_init(HMMWork *wrk, int num);
00172 void outprob_cd_nbest_free(HMMWork *wrk);
00173 LOGPROB outprob_cd(HMMWork *wrk, int t, CD_State_Set *lset, HTK_Param *param);
00174 /* gms.c */
00175 boolean gms_init(HMMWork *wrk);
00176 boolean gms_prepare(HMMWork *wrk, int framelen);
00177 void gms_free(HMMWork *wrk);
00178 LOGPROB gms_state(HMMWork *wrk);
00179 /* gms_gprune.c */
00180 void gms_gprune_init(HMMWork *wrk);
00181 void gms_gprune_prepare(HMMWork *wrk);
00182 void gms_gprune_free(HMMWork *wrk);
00183 void compute_gs_scores(HMMWork *wrk);
00184 
00185 /* calc_mix.c */
00186 LOGPROB calc_mix(HMMWork *wrk);
00187 /* calc_tied_mix.c */
00188 boolean calc_tied_mix_init(HMMWork *wrk);
00189 boolean calc_tied_mix_prepare(HMMWork *wrk, int framenum);
00190 void calc_tied_mix_free(HMMWork *wrk);
00191 LOGPROB calc_tied_mix(HMMWork *wrk);
00192 
00193 /* gprune_common.c */
00194 int cache_push(HMMWork *wrk, int id, LOGPROB score, int len);
00195 /* gprune_none.c */
00196 LOGPROB compute_g_base(HMMWork *wrk, HTK_HMM_Dens *binfo);
00197 boolean gprune_none_init(HMMWork *wrk);
00198 void gprune_none_free(HMMWork *wrk);
00199 void gprune_none(HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id);
00200 /* gprune_safe.c */
00201 LOGPROB compute_g_safe(HMMWork *wrk, HTK_HMM_Dens *binfo, LOGPROB thres);
00202 boolean gprune_safe_init(HMMWork *wrk);
00203 void gprune_safe_free(HMMWork *wrk);
00204 void gprune_safe(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id);
00205 /* gprune_heu.c */
00206 boolean gprune_heu_init(HMMWork *wrk);
00207 void gprune_heu_free(HMMWork *wrk);
00208 void gprune_heu(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id);
00209 /* gprune_beam.c */
00210 boolean gprune_beam_init(HMMWork *wrk);
00211 void gprune_beam_free(HMMWork *wrk);
00212 void gprune_beam(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id);
00213 
00214 #endif /* __SENT_HMM_CALC_H__ */

Generated on Tue Dec 18 15:59:53 2007 for Julius by  doxygen 1.5.4