Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00043 #ifndef __ACMOD_H__
00044 #define __ACMOD_H__
00045
00046
00047 #include <stdio.h>
00048
00049
00050 #include <cmd_ln.h>
00051 #include <logmath.h>
00052 #include <fe.h>
00053 #include <feat.h>
00054 #include <bitvec.h>
00055 #include <err.h>
00056
00057
00058 #include "ps_mllr.h"
00059 #include "bin_mdef.h"
00060 #include "tmat.h"
00061 #include "hmm.h"
00062
00066 typedef enum acmod_state_e {
00067 ACMOD_IDLE,
00068 ACMOD_STARTED,
00069 ACMOD_PROCESSING,
00070 ACMOD_ENDED
00071 } acmod_state_t;
00072
00076 struct ps_mllr_s {
00077 int refcnt;
00078 int n_class;
00079 int n_feat;
00080 int *veclen;
00081 float32 ****A;
00082 float32 ***b;
00083 float32 ***h;
00084 int32 *cb2mllr;
00085 };
00086
00090 typedef struct ps_mgau_s ps_mgau_t;
00091
00092 typedef struct ps_mgaufuncs_s {
00093 char const *name;
00094
00095 int (*frame_eval)(ps_mgau_t *mgau,
00096 int16 *senscr,
00097 uint8 *senone_active,
00098 int32 n_senone_active,
00099 mfcc_t ** feat,
00100 int32 frame,
00101 int32 compallsen);
00102 int (*transform)(ps_mgau_t *mgau,
00103 ps_mllr_t *mllr);
00104 void (*free)(ps_mgau_t *mgau);
00105 } ps_mgaufuncs_t;
00106
00107 struct ps_mgau_s {
00108 ps_mgaufuncs_t *vt;
00109 int frame_idx;
00110 };
00111
00112 #define ps_mgau_base(mg) ((ps_mgau_t *)(mg))
00113 #define ps_mgau_frame_eval(mg,senscr,senone_active,n_senone_active,feat,frame,compallsen) \
00114 (*ps_mgau_base(mg)->vt->frame_eval) \
00115 (mg, senscr, senone_active, n_senone_active, feat, frame, compallsen)
00116 #define ps_mgau_transform(mg, mllr) \
00117 (*ps_mgau_base(mg)->vt->transform)(mg, mllr)
00118 #define ps_mgau_free(mg) \
00119 (*ps_mgau_base(mg)->vt->free)(mg)
00120
00142 struct acmod_s {
00143
00144 cmd_ln_t *config;
00145 logmath_t *lmath;
00146 glist_t strings;
00148
00149 fe_t *fe;
00150 feat_t *fcb;
00152
00153 bin_mdef_t *mdef;
00154 tmat_t *tmat;
00155 ps_mgau_t *mgau;
00156 ps_mllr_t *mllr;
00158
00159 int16 *senone_scores;
00160 bitvec_t *senone_active_vec;
00161 uint8 *senone_active;
00162 int senscr_frame;
00163 int n_senone_active;
00164 int log_zero;
00166
00167 mfcc_t **mfc_buf;
00168 mfcc_t ***feat_buf;
00169 FILE *rawfh;
00170 FILE *mfcfh;
00172
00173 uint8 state;
00174 uint8 compallsen;
00175 uint8 grow_feat;
00176 uint8 reserved;
00177 int16 output_frame;
00178 int16 n_mfc_alloc;
00179 int16 n_mfc_frame;
00180 int16 mfc_outidx;
00181 int16 n_feat_alloc;
00182 int16 n_feat_frame;
00183 int16 feat_outidx;
00184 };
00185 typedef struct acmod_s acmod_t;
00186
00203 acmod_t *acmod_init(cmd_ln_t *config, logmath_t *lmath, fe_t *fe, feat_t *fcb);
00204
00216 ps_mllr_t *acmod_update_mllr(acmod_t *acmod, ps_mllr_t *mllr);
00217
00225 int acmod_set_mfcfh(acmod_t *acmod, FILE *logfh);
00226
00234 int acmod_set_rawfh(acmod_t *acmod, FILE *logfh);
00235
00239 void acmod_free(acmod_t *acmod);
00240
00244 int acmod_start_utt(acmod_t *acmod);
00245
00249 int acmod_end_utt(acmod_t *acmod);
00250
00263 int acmod_rewind(acmod_t *acmod);
00264
00274 int acmod_advance(acmod_t *acmod);
00275
00284 int acmod_set_grow(acmod_t *acmod, int grow_feat);
00285
00304 int acmod_process_raw(acmod_t *acmod,
00305 int16 const **inout_raw,
00306 size_t *inout_n_samps,
00307 int full_utt);
00308
00320 int acmod_process_cep(acmod_t *acmod,
00321 mfcc_t ***inout_cep,
00322 int *inout_n_frames,
00323 int full_utt);
00324
00338 int acmod_process_feat(acmod_t *acmod,
00339 mfcc_t **feat);
00340
00354 int16 const *acmod_score(acmod_t *acmod,
00355 int *inout_frame_idx);
00356
00360 int acmod_best_score(acmod_t *acmod, int *out_best_senid);
00361
00365 void acmod_clear_active(acmod_t *acmod);
00366
00370 void acmod_activate_hmm(acmod_t *acmod, hmm_t *hmm);
00371
00372 #endif