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 _CONT_AD_H_
00080 #define _CONT_AD_H_
00081
00082
00083 #include <sphinxbase_export.h>
00084 #include <prim_type.h>
00085
00113 #include <stdio.h>
00114
00115
00116 #ifdef __cplusplus
00117 extern "C" {
00118 #endif
00119 #if 0
00120
00121 }
00122 #endif
00123
00124
00125 #define CONT_AD_STATE_SIL 0
00126 #define CONT_AD_STATE_SPEECH 1
00127
00128
00134 typedef struct spseg_s {
00135 int32 startfrm;
00136 int32 nfrm;
00137 struct spseg_s *next;
00138 } spseg_t;
00139
00140
00150 typedef struct {
00151
00152 int32 (*adfunc)(ad_rec_t *ad, int16 *buf, int32 max);
00153 ad_rec_t *ad;
00155 int32 rawmode;
00157 int16 *adbuf;
00159
00160
00161
00162
00163
00164 int32 state;
00166 int32 read_ts;
00170 int32 seglen;
00174 int32 siglvl;
00177
00178
00179 int32 sps;
00182 int32 eof;
00184 int32 spf;
00185 int32 adbufsize;
00186 int32 prev_sample;
00187 int32 headfrm;
00188 int32 n_frm;
00189 int32 n_sample;
00190 int32 tot_frm;
00191 int32 noise_level;
00193 int32 *pow_hist;
00194 char *frm_pow;
00196 int32 auto_thresh;
00197 int32 delta_sil;
00198 int32 delta_speech;
00199 int32 min_noise;
00200 int32 max_noise;
00201 int32 winsize;
00202 int32 speech_onset;
00203 int32 sil_onset;
00204 int32 leader;
00205 int32 trailer;
00207 int32 thresh_speech;
00209 int32 thresh_sil;
00211 int32 thresh_update;
00212 float32 adapt_rate;
00216 int32 tail_state;
00219 int32 win_startfrm;
00220 int32 win_validfrm;
00221 int32 n_other;
00223 spseg_t *spseg_head;
00224 spseg_t *spseg_tail;
00226 FILE *rawfp;
00230 FILE *logfp;
00235 int32 n_calib_frame;
00236 } cont_ad_t;
00237
00238
00254 SPHINXBASE_EXPORT
00255 cont_ad_t *cont_ad_init (ad_rec_t *ad,
00256 int32 (*adfunc)(ad_rec_t *ad, int16 *buf, int32 max)
00260 );
00261
00268 SPHINXBASE_EXPORT
00269 cont_ad_t *cont_ad_init_rawmode (ad_rec_t *ad,
00270 int32 (*adfunc)(ad_rec_t *ad, int16 *buf, int32 max));
00271
00272
00301 SPHINXBASE_EXPORT
00302 int32 cont_ad_read (cont_ad_t *r,
00303 int16 *buf,
00306 int32 max
00309 );
00310
00314 SPHINXBASE_EXPORT
00315 int32 cont_ad_buffer_space(cont_ad_t *r);
00316
00329 SPHINXBASE_EXPORT
00330 int32 cont_ad_calib (cont_ad_t *cont
00331 );
00332
00344 SPHINXBASE_EXPORT
00345 int32 cont_ad_calib_loop (cont_ad_t *r, int16 *buf, int32 max);
00346
00358 SPHINXBASE_EXPORT
00359 int32 cont_ad_calib_size(cont_ad_t *r);
00360
00373 SPHINXBASE_EXPORT
00374 int32 cont_ad_set_thresh (cont_ad_t *cont,
00375 int32 sil,
00376 int32 sp
00377 );
00378
00379
00387 SPHINXBASE_EXPORT
00388 int32 cont_ad_set_params (cont_ad_t *r, int32 delta_sil, int32 delta_speech,
00389 int32 min_noise, int32 max_noise,
00390 int32 winsize, int32 speech_onset, int32 sil_onset,
00391 int32 leader, int32 trailer,
00392 float32 adapt_rate);
00393
00401 SPHINXBASE_EXPORT
00402 int32 cont_ad_get_params (cont_ad_t *r, int32 *delta_sil, int32 *delta_speech,
00403 int32 *min_noise, int32 *max_noise,
00404 int32 *winsize, int32 *speech_onset, int32 *sil_onset,
00405 int32 *leader, int32 *trailer,
00406 float32 *adapt_rate);
00407
00412 SPHINXBASE_EXPORT
00413 int32 cont_ad_reset (cont_ad_t *cont);
00414
00415
00419 SPHINXBASE_EXPORT
00420 int32 cont_ad_close (cont_ad_t *cont);
00421
00422
00426 SPHINXBASE_EXPORT
00427 void cont_ad_powhist_dump (FILE *fp, cont_ad_t *cont);
00428
00429
00434 SPHINXBASE_EXPORT
00435 int32 cont_ad_detach (cont_ad_t *c);
00436
00437
00443 SPHINXBASE_EXPORT
00444 int32 cont_ad_attach (cont_ad_t *c, ad_rec_t *a, int32 (*func)(ad_rec_t *, int16 *, int32));
00445
00446
00458 SPHINXBASE_EXPORT
00459 int32 cont_ad_set_rawfp (cont_ad_t *c,
00460 FILE *fp);
00461
00462
00470 SPHINXBASE_EXPORT
00471 int32 cont_ad_set_logfp (cont_ad_t *c,
00472 FILE *fp);
00473
00474
00483 SPHINXBASE_EXPORT
00484 int32 cont_set_thresh(cont_ad_t *r, int32 silence, int32 speech);
00485
00486 #ifdef __cplusplus
00487 }
00488 #endif
00489
00490
00491 #endif