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
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 #ifndef _S3_FEAT_H_
00080 #define _S3_FEAT_H_
00081
00082 #include <stdio.h>
00083
00084
00085 #include <sphinxbase_export.h>
00086 #include <prim_type.h>
00087 #include <fe.h>
00088 #include <cmn.h>
00089 #include <agc.h>
00090
00091 #ifdef __cplusplus
00092 extern "C" {
00093 #endif
00094 #if 0
00095
00096 }
00097 #endif
00098
00102 #define LIVEBUFBLOCKSIZE 256
00104 #define S3_MAX_FRAMES 15000
00105
00106 #define cepstral_to_feature_command_line_macro() \
00107 { "-feat", \
00108 ARG_STRING, \
00109 "1s_c_d_dd", \
00110 "Feature stream type, depends on the acoustic model" }, \
00111 { "-ceplen", \
00112 ARG_INT32, \
00113 "13", \
00114 "Number of components in the input feature vector" }, \
00115 { "-cmn", \
00116 ARG_STRING, \
00117 "current", \
00118 "Cepstral mean normalization scheme ('current', 'prior', or 'none')" }, \
00119 { "-cmninit", \
00120 ARG_STRING, \
00121 "8.0", \
00122 "Initial values (comma-separated) for cepstral mean when 'prior' is used" }, \
00123 { "-varnorm", \
00124 ARG_BOOLEAN, \
00125 "no", \
00126 "Variance normalize each utterance (only if CMN == current)" }, \
00127 { "-agc", \
00128 ARG_STRING, \
00129 "none", \
00130 "Automatic gain control for c0 ('max', 'emax', 'noise', or 'none')" }, \
00131 { "-agcthresh", \
00132 ARG_FLOAT32, \
00133 "2.0", \
00134 "Initial threshold for automatic gain control" }, \
00135 { "-lda", \
00136 ARG_STRING, \
00137 NULL, \
00138 "File containing transformation matrix to be applied to features (single-stream features only)" }, \
00139 { "-ldadim", \
00140 ARG_INT32, \
00141 "0", \
00142 "Dimensionality of output of feature transformation (0 to use entire matrix)" }, \
00143 {"-svspec", \
00144 ARG_STRING, \
00145 NULL, \
00146 "Subvector specification (e.g., 24,0-11/25,12-23/26-38 or 0-12/13-25/26-38)"}
00147
00155 typedef struct feat_s {
00156 int refcount;
00157 char *name;
00158 int32 cepsize;
00159 int32 n_stream;
00160 int32 *stream_len;
00161 int32 window_size;
00163 int32 n_sv;
00164 int32 *sv_len;
00165 int32 **subvecs;
00166 mfcc_t *sv_buf;
00167 int32 sv_dim;
00169 cmn_type_t cmn;
00170 int32 varnorm;
00172 agc_type_t agc;
00186 void (*compute_feat)(struct feat_s *fcb, mfcc_t **input, mfcc_t **feat);
00187 cmn_t *cmn_struct;
00189 agc_t *agc_struct;
00192 mfcc_t **cepbuf;
00193 mfcc_t **tmpcepbuf;
00194 int32 bufpos;
00195 int32 curpos;
00197 mfcc_t ***lda;
00198 uint32 n_lda;
00199 uint32 out_dim;
00200 } feat_t;
00201
00205 #define feat_name(f) ((f)->name)
00206
00209 #define feat_cepsize(f) ((f)->cepsize)
00210
00213 #define feat_window_size(f) ((f)->window_size)
00214
00219 #define feat_n_stream(f) ((f)->n_stream)
00220
00225 #define feat_stream_len(f,i) ((f)->stream_len[i])
00226
00229 #define feat_dimension1(f) ((f)->n_sv ? (f)->n_sv : f->n_stream)
00230
00233 #define feat_dimension2(f,i) ((f)->sv_len ? (f)->sv_len[i] : f->stream_len[i])
00234
00237 #define feat_dimension(f) ((f)->out_dim)
00238
00259 SPHINXBASE_EXPORT
00260 int32 **parse_subvecs(char const *str);
00261
00265 SPHINXBASE_EXPORT
00266 void subvecs_free(int32 **subvecs);
00267
00276 SPHINXBASE_EXPORT
00277 int32 feat_s2mfc_read(char *file,
00278 int32 win,
00280 int32 sf, int32 ef,
00283 mfcc_t ***out_mfc,
00286 int32 maxfr,
00289 int32 cepsize
00290 );
00291
00304 SPHINXBASE_EXPORT
00305 mfcc_t ***feat_array_alloc(feat_t *fcb,
00307 int32 nfr
00308 );
00309
00313 SPHINXBASE_EXPORT
00314 void feat_array_free(mfcc_t ***feat);
00315
00316
00332 SPHINXBASE_EXPORT
00333 feat_t *feat_init(char const *type,
00334 cmn_type_t cmn,
00337 int32 varnorm,
00340 agc_type_t agc,
00342 int32 breport,
00343 int32 cepsize
00346 );
00347
00352 SPHINXBASE_EXPORT
00353 int32 feat_read_lda(feat_t *feat,
00354 const char *ldafile,
00355 int32 dim
00356 );
00357
00361 SPHINXBASE_EXPORT
00362 void feat_lda_transform(feat_t *fcb,
00363 mfcc_t ***inout_feat,
00364 uint32 nfr
00365 );
00366
00385 SPHINXBASE_EXPORT
00386 int feat_set_subvecs(feat_t *fcb, int32 **subvecs);
00387
00391 SPHINXBASE_EXPORT
00392 void feat_print(feat_t *fcb,
00393 mfcc_t ***feat,
00394 int32 nfr,
00395 FILE *fp
00396 );
00397
00398
00415 SPHINXBASE_EXPORT
00416 int32 feat_s2mfc2feat(feat_t *fcb,
00417 const char *file,
00418 const char *dir,
00420 const char *cepext,
00423 int32 sf, int32 ef,
00424
00425
00426
00427 mfcc_t ***feat,
00429 int32 maxfr
00433 );
00434
00435
00464 SPHINXBASE_EXPORT
00465 int32 feat_s2mfc2feat_live(feat_t *fcb,
00466 mfcc_t **uttcep,
00467 int32 *inout_ncep,
00469 int32 beginutt,
00470 int32 endutt,
00471 mfcc_t ***ofeat
00474 );
00475
00476
00482 SPHINXBASE_EXPORT
00483 feat_t *feat_retain(feat_t *f);
00484
00490 SPHINXBASE_EXPORT
00491 int feat_free(feat_t *f
00492 );
00493
00497 SPHINXBASE_EXPORT
00498 void feat_report(feat_t *f
00499 );
00500 #ifdef __cplusplus
00501 }
00502 #endif
00503
00504
00505 #endif