00001
00019
00020
00021
00022
00023
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
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
00085 HTK_HMM_INFO *OP_hmminfo;
00086 HTK_HMM_INFO *OP_gshmm;
00087
00088
00089 HTK_Param *OP_param;
00090 int OP_gprune_num;
00091 int OP_time;
00092 int OP_last_time;
00093
00094
00095 HTK_HMM_State *OP_state;
00096 int OP_state_id;
00097
00098
00099 short OP_nstream;
00100 VECT *OP_vec_stream[MAXSTREAMNUM];
00101 short OP_veclen_stream[MAXSTREAMNUM];
00102
00103
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
00112 int statenum;
00113 LOGPROB **outprob_cache;
00114 int outprob_allocframenum;
00115 BMALLOC_BASE *croot;
00116 LOGPROB *last_cache;
00117
00118
00119 MIXCACHE ***mixture_cache;
00120 short **mixture_cache_num;
00121 BMALLOC_BASE *mroot;
00122
00123
00124 int *tmix_last_id;
00125 int tmix_allocframenum;
00126
00127
00128 boolean *mixcalced;
00129
00130 LOGPROB *dimthres;
00131 int dimthres_num;
00132
00133 LOGPROB *backmax;
00134 int backmax_num;
00135
00136
00137 LOGPROB *cd_nbest_maxprobs;
00138 int cd_nbest_maxn;
00139
00140
00141
00142 int my_nbest;
00143 int gms_allocframenum;
00144
00145 GS_SET *gsset;
00146 int gsset_num;
00147 int *state2gs;
00148
00149 boolean *gms_is_selected;
00150 LOGPROB **fallback_score;
00151
00152 int *gsindex;
00153 LOGPROB *t_fs;
00154
00155 int **gms_last_max_id_list;
00156
00157 } HMMWork;
00158
00159
00160
00161 void make_log_tbl();
00162 LOGPROB addlog(LOGPROB x, LOGPROB y);
00163 LOGPROB addlog_array(LOGPROB *x, int n);
00164
00165
00166 boolean
00167 outprob_init(HMMWork *wrk, HTK_HMM_INFO *hmminfo,
00168 HTK_HMM_INFO *gshmm, int gms_num,
00169 int gprune_method, int gprune_mixnum
00170 );
00171 boolean outprob_prepare(HMMWork *wrk, int framenum);
00172 void outprob_free(HMMWork *wrk);
00173
00174 boolean outprob_cache_init(HMMWork *wrk);
00175 boolean outprob_cache_prepare(HMMWork *wrk);
00176 void outprob_cache_free(HMMWork *wrk);
00177 LOGPROB outprob_state(HMMWork *wrk, int t, HTK_HMM_State *stateinfo, HTK_Param *param);
00178 void outprob_cd_nbest_init(HMMWork *wrk, int num);
00179 void outprob_cd_nbest_free(HMMWork *wrk);
00180 LOGPROB outprob_cd(HMMWork *wrk, int t, CD_State_Set *lset, HTK_Param *param);
00181
00182 boolean gms_init(HMMWork *wrk);
00183 boolean gms_prepare(HMMWork *wrk, int framelen);
00184 void gms_free(HMMWork *wrk);
00185 LOGPROB gms_state(HMMWork *wrk);
00186
00187 void gms_gprune_init(HMMWork *wrk);
00188 void gms_gprune_prepare(HMMWork *wrk);
00189 void gms_gprune_free(HMMWork *wrk);
00190 void compute_gs_scores(HMMWork *wrk);
00191
00192
00193 LOGPROB calc_mix(HMMWork *wrk);
00194
00195 boolean calc_tied_mix_init(HMMWork *wrk);
00196 boolean calc_tied_mix_prepare(HMMWork *wrk, int framenum);
00197 void calc_tied_mix_free(HMMWork *wrk);
00198 LOGPROB calc_tied_mix(HMMWork *wrk);
00199 LOGPROB calc_compound_mix(HMMWork *wrk);
00200
00201
00202 int cache_push(HMMWork *wrk, int id, LOGPROB score, int len);
00203
00204 LOGPROB compute_g_base(HMMWork *wrk, HTK_HMM_Dens *binfo);
00205 boolean gprune_none_init(HMMWork *wrk);
00206 void gprune_none_free(HMMWork *wrk);
00207 void gprune_none(HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id, int lnum);
00208
00209 LOGPROB compute_g_safe(HMMWork *wrk, HTK_HMM_Dens *binfo, LOGPROB thres);
00210 boolean gprune_safe_init(HMMWork *wrk);
00211 void gprune_safe_free(HMMWork *wrk);
00212 void gprune_safe(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum);
00213
00214 boolean gprune_heu_init(HMMWork *wrk);
00215 void gprune_heu_free(HMMWork *wrk);
00216 void gprune_heu(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum);
00217
00218 boolean gprune_beam_init(HMMWork *wrk);
00219 void gprune_beam_free(HMMWork *wrk);
00220 void gprune_beam(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum);
00221
00222 #endif