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
00056
00057 #include "bin_mdef.h"
00058 #include "s2_semi_mgau.h"
00059 #include "ms_mgau.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 typedef int (*frame_eval_t)(void *eval_obj,
00077 int16 *senscr,
00078 int32 *senone_active,
00079 int32 n_senone_active,
00080 mfcc_t ** feat,
00081 int32 frame,
00082 int32 compallsen,
00083 int32 *out_bestidx);
00084
00102 struct acmod_s {
00103
00104 cmd_ln_t *config;
00105 logmath_t *lmath;
00106 glist_t strings;
00108
00109 fe_t *fe;
00110 feat_t *fcb;
00112
00113 bin_mdef_t *mdef;
00114 tmat_t *tmat;
00115 void *mgau;
00118 void (*mgau_free)(void *);
00120
00121 frame_eval_t frame_eval;
00122 int16 *senone_scores;
00123 bitvec_t *senone_active_vec;
00124 int *senone_active;
00125 int n_senone_active;
00126 int log_zero;
00128
00129 mfcc_t **mfc_buf;
00130 mfcc_t ***feat_buf;
00131 FILE *rawfh;
00132 FILE *mfcfh;
00134
00135 uint8 state;
00136 uint8 compallsen;
00137 uint8 grow_feat;
00138 uint8 reserved;
00139 int16 output_frame;
00140 int16 n_mfc_alloc;
00141 int16 n_mfc_frame;
00142 int16 mfc_outidx;
00143 int16 n_feat_alloc;
00144 int16 n_feat_frame;
00145 int16 feat_outidx;
00146 };
00147 typedef struct acmod_s acmod_t;
00148
00165 acmod_t *acmod_init(cmd_ln_t *config, logmath_t *lmath, fe_t *fe, feat_t *fcb);
00166
00174 int acmod_set_mfcfh(acmod_t *acmod, FILE *logfh);
00175
00183 int acmod_set_rawfh(acmod_t *acmod, FILE *logfh);
00184
00188 void acmod_free(acmod_t *acmod);
00189
00193 int acmod_start_utt(acmod_t *acmod);
00194
00198 int acmod_end_utt(acmod_t *acmod);
00199
00212 int acmod_rewind(acmod_t *acmod);
00213
00222 int acmod_set_grow(acmod_t *acmod, int grow_feat);
00223
00235 int acmod_process_raw(acmod_t *acmod,
00236 int16 const **inout_raw,
00237 size_t *inout_n_samps,
00238 int full_utt);
00239
00251 int acmod_process_cep(acmod_t *acmod,
00252 mfcc_t ***inout_cep,
00253 int *inout_n_frames,
00254 int full_utt);
00255
00269 int acmod_process_feat(acmod_t *acmod,
00270 mfcc_t **feat);
00271
00275 int acmod_frame_idx(acmod_t *acmod);
00276
00288 int16 const *acmod_score(acmod_t *acmod,
00289 int *out_frame_idx,
00290 int16 *out_best_score,
00291 int32 *out_best_senid);
00292
00296 void acmod_clear_active(acmod_t *acmod);
00297
00301 void acmod_activate_hmm(acmod_t *acmod, hmm_t *hmm);
00302
00309 int const *acmod_active_list(acmod_t *acmod, int *out_n_active);
00310
00311 #endif