fast_algo_struct.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2004 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 /*
38  * fast_algo_struct.h -- Various forms of pruning beam
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1999 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  *
47  * HISTORY
48  * $Log$
49  * Revision 1.1 2006/04/05 20:27:30 dhdfu
50  * A Great Reorganzation of header files and executables
51  *
52  * Revision 1.10 2006/02/22 16:39:43 arthchan2003
53  * Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Initialize beam->n_ciphone properly, 2, use ckd_free instead of free, use float64 for subvqbeam and cipbeam. 3, Add a proper free function for fast_gmm_free
54  *
55  *
56  * Revision 1.7.4.5 2005/11/17 06:07:07 arthchan2003
57  * Added fast_gmm_free in the header.
58  *
59  * Revision 1.7.4.4 2005/07/05 21:28:57 arthchan2003
60  * 1, Merged from HEAD. 2, Remove redundant keyword in cont_mgau.
61  *
62  * Revision 1.7.4.3 2005/07/05 05:47:59 arthchan2003
63  * Fixed dox-doc. struct level of documentation are included.
64  *
65  * Revision 1.7.4.2 2005/07/04 02:44:25 arthchan2003
66  * Changed float32 to float64 for ci_pbeam and svqbeam. Code now compiled.
67  *
68  * Revision 1.7.4.1 2005/06/27 05:22:19 arthchan2003
69  * Merged from the HEAD.
70  *
71  * Revision 1.9 2005/06/30 13:08:45 egouvea
72  * Beams in linear scale have to be float64, since they can be easily defined as < 1e-40
73  *
74  * Revision 1.8 2005/06/22 08:00:09 arthchan2003
75  * Completed all doxygen documentation on file description for libs3decoder/libutil/libs3audio and programs.
76  *
77  * Revision 1.7 2005/06/21 18:26:38 arthchan2003
78  * Log. fast_algo_struct.c go through major changes in the gentle
79  * refactoring process. It is the location of several wrapper structures
80  * that control fast search. That includes beam_t for storing beams and
81  * scores. pl_t for storing structure for phoneme lookahead, histprune_t
82  * for storing structures for histogram pruning. Lastly
83  * fast_algo_struct_t, for storing structures for fast GMM
84  * computation.
85  *
86  * Log. General Remark All of them now has consistent inteface, _init,
87  * _report and _free. They are respectively used for allocation,
88  * reporting and deallocation of the routine. Doxygen documentation are
89  * fixed for all structures.
90  *
91  * Log. Individual changes; beam_t start to own bestscore, bestwordscore,
92  * wordbestscores, wordbestexits. They were owned by kb_t. histprune_t
93  * now wrapped up maxwpf, maxhmmpdf, maxhistpf and
94  * hmm_hist_binsize. Currently, the beam size determination routine is
95  * controlled by search implementation modules. It is done because
96  * wrapping that operation up means we may need to introduce a bridge
97  * between beam_t and histprune_t. pl_t is now owning heuristic type,
98  * the phoneme lookahead beam size. It also wrapped up phoneme heuristic
99  * computation.
100  *
101  * Revision 1.5 2005/04/20 03:33:54 archan
102  * Remove pl_win and pl_win_strt, Now consider them as the parameters of the search abstraction in srch.c
103  *
104  * Revision 1.4 2005/03/30 01:22:46 archan
105  * Fixed mistakes in last updates. Add
106  *
107  *
108  * 19-May-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
109  * Started.
110  */
111 
118 #ifndef _S3_BEAM_H_
119 #define _S3_BEAM_H_
120 
121 #include <s3types.h>
122 #include <mdef.h>
123 #include <ascr.h>
124 #include <logmath.h>
125 
126 #ifdef __cplusplus
127 extern "C" {
128 #endif
129 #if 0
130 } /* Fool Emacs into not indenting things. */
131 #endif
132 
133 
149 typedef struct {
150  int32 hmm;
151  int32 ptrans;
152  int32 word;
153  int32 ptranskip;
154  int32 wordend;
155  int32 n_ciphone;
157  int32 bestscore;
159  int32 thres;
160  int32 phone_thres;
161  int32 word_thres;
163  int32 *wordbestscores;
164  int32 *wordbestexits;
166 } beam_t;
167 
173 typedef struct{
174  int32 pheurtype;
175  int32 pl_beam;
177  int32 n_ciphone;
178  int32 *phn_heur_list;
182 }pl_t;
183 
190 typedef struct {
191  int32 maxwpf;
192  int32 maxhistpf;
193  int32 maxhmmpf;
196  int32 *hmm_hist;
198 } histprune_t;
199 
205 typedef struct{
206  int32 ds_ratio;
207  int32 cond_ds;
212  int32 dist_ds;
217  int32 skip_count;
220 
225 typedef struct{
226  int32 ci_pbeam;
228  int32 dyn_ci_pbeam;
230  float32 tighten_factor;
234  int32 *ci_occu;
236  int32 *idx;
238  int32 max_cd;
240 } gmm_select_t;
241 
247 typedef struct{
248  int32 subvqbeam;
249  int32 rec_bstcid;
250 } gau_select_t;
251 
256 typedef struct{
260  int32 gs4gs;
262  int32 svq4svq;
264  float32 *last_feat;
266 } fast_gmm_t;
267 
277 beam_t *beam_init (
278  float64 hmm,
279  float64 ptr,
280  float64 wd,
281  float64 wdend,
282  int32 ptranskip,
283  int32 n_ciphone,
284  logmath_t *logmath
285  );
286 
287 
289 void beam_report(beam_t* b
290  );
291 
293 void beam_free(beam_t *b
294  );
295 
300 histprune_t *histprune_init (int32 maxhmm,
301  int32 maxhist,
302  int32 maxword,
303  int32 hmmhistbinsize,
304  int32 numNodes
305  );
306 
308  );
309 
311  int32 hmmhistbinsize,
312  int32 numNodes
313  );
314 
317  );
318 
321  int32 nfr,
322  char* uttid
323  );
324 
327  );
332 fast_gmm_t *fast_gmm_init (int32 down_sampling_ratio,
333  int32 mode_cond_ds,
334  int32 mode_dist_ds,
335  int32 isGS4GS,
336  int32 isSVQ4SVQ,
337  float64 subvqbeam,
338  float64 cibeam,
339  float32 tighten_factor,
340  int32 max_cd,
341  int32 n_ci_sen,
342  logmath_t *logmath
343  );
344 
347  );
348 
351 void fast_gmm_free (fast_gmm_t *fg
352  );
353 
354 
359 pl_t* pl_init(int32 pheurtype,
360  int32 pl_beam,
361  int32 n_ciphone,
362  logmath_t *logmath
363  );
364 
366 void pl_report(pl_t* pl
367  );
368 
370 void pl_free(pl_t* pl
371  );
372 
377 void pl_computePhnHeur(mdef_t* md,
378  ascr_t *a,
379  pl_t* pl,
380  int32 heutype,
381  int32 win_strt,
382  int32 win_efv
383  );
384 
385 #if 0
386 { /* Stop indent from complaining */
387 #endif
388 #ifdef __cplusplus
389 }
390 #endif
391 
392 
393 #endif
strcture for storing the model definition.
Definition: mdef.h:184
int32 hmm_hist_binsize
Definition: fast_algo_struct.h:194
void pl_computePhnHeur(mdef_t *md, ascr_t *a, pl_t *pl, int32 heutype, int32 win_strt, int32 win_efv)
int32 hmm_hist_bins
Definition: fast_algo_struct.h:195
int32 subvqbeam
Definition: fast_algo_struct.h:248
void beam_free(beam_t *b)
int32 * idx
Definition: fast_algo_struct.h:236
void pl_report(pl_t *pl)
Structure that contains all parameters for phoneme lookahead.
Definition: fast_algo_struct.h:173
histprune_t * histprune_init(int32 maxhmm, int32 maxhist, int32 maxword, int32 hmmhistbinsize, int32 numNodes)
int32 wordend
Definition: fast_algo_struct.h:154
int32 bestwordscore
Definition: fast_algo_struct.h:158
Structure that contains all beam parameters for beam pruning in Viterbi algorithm.
Definition: fast_algo_struct.h:149
int32 n_ciphone
Definition: fast_algo_struct.h:177
int32 hmm
Definition: fast_algo_struct.h:150
int32 ptranskip
Definition: fast_algo_struct.h:153
void histprune_zero_histbin(histprune_t *h)
int32 maxhmmpf
Definition: fast_algo_struct.h:193
float32 * last_feat
Definition: fast_algo_struct.h:264
int32 * ci_occu
Definition: fast_algo_struct.h:234
Definition: ascr.h:99
Structure that contains all parameter related to 4-Level Fast GMM computation.
Definition: fast_algo_struct.h:256
Structure containing various parameters for downsampling.
Definition: fast_algo_struct.h:205
pl_t * pl_init(int32 pheurtype, int32 pl_beam, int32 n_ciphone, logmath_t *logmath)
Structure that contains all parameters for CI-based GMM selection.
Definition: fast_algo_struct.h:225
int32 ci_pbeam
Definition: fast_algo_struct.h:226
int32 dist_ds
Definition: fast_algo_struct.h:212
Structure that contains all parameters related to Gaussian selection.
Definition: fast_algo_struct.h:247
Size definition of semantically units. Common for both s3 and s3.X decoder.
int32 * phn_heur_list
Definition: fast_algo_struct.h:178
Structure containing various histogram pruning parameters and internal storage All in integers...
Definition: fast_algo_struct.h:190
void beam_report(beam_t *b)
beam_t * beam_init(float64 hmm, float64 ptr, float64 wd, float64 wdend, int32 ptranskip, int32 n_ciphone, logmath_t *logmath)
int32 thres
Definition: fast_algo_struct.h:159
int32 word
Definition: fast_algo_struct.h:152
#define S3DECODER_EXPORT
Definition: sphinx3_export.h:15
int32 dyn_ci_pbeam
Definition: fast_algo_struct.h:228
gau_select_t * gaus
Definition: fast_algo_struct.h:259
S3DECODER_EXPORT void fast_gmm_free(fast_gmm_t *fg)
void pl_free(pl_t *pl)
void histprune_update_histbinsize(histprune_t *h, int32 hmmhistbinsize, int32 numNodes)
void histprune_showhistbin(histprune_t *hp, int32 nfr, char *uttid)
downsampling_t * downs
Definition: fast_algo_struct.h:257
int32 cond_ds
Definition: fast_algo_struct.h:207
void fast_gmm_report(fast_gmm_t *f)
int32 rec_bst_senscr
Definition: fast_algo_struct.h:263
S3DECODER_EXPORT fast_gmm_t * fast_gmm_init(int32 down_sampling_ratio, int32 mode_cond_ds, int32 mode_dist_ds, int32 isGS4GS, int32 isSVQ4SVQ, float64 subvqbeam, float64 cibeam, float32 tighten_factor, int32 max_cd, int32 n_ci_sen, logmath_t *logmath)
int32 n_ciphone
Definition: fast_algo_struct.h:155
Model definition.
int32 maxhistpf
Definition: fast_algo_struct.h:192
int32 word_thres
Definition: fast_algo_struct.h:161
int32 max_cd
Definition: fast_algo_struct.h:238
int32 bestscore
Definition: fast_algo_struct.h:157
int32 pl_beam
Definition: fast_algo_struct.h:175
int32 phone_thres
Definition: fast_algo_struct.h:160
int32 pheurtype
Definition: fast_algo_struct.h:174
int32 maxwpf
Definition: fast_algo_struct.h:191
void histprune_report(histprune_t *h)
Wrapper to hold senone scores.
gmm_select_t * gmms
Definition: fast_algo_struct.h:258
int32 ds_ratio
Definition: fast_algo_struct.h:206
int32 rec_bstcid
Definition: fast_algo_struct.h:249
int32 * hmm_hist
Definition: fast_algo_struct.h:196
void histprune_free(histprune_t *h)
int32 skip_count
Definition: fast_algo_struct.h:217
int32 gs4gs
Definition: fast_algo_struct.h:260
int32 * wordbestscores
Definition: fast_algo_struct.h:163
int32 ptrans
Definition: fast_algo_struct.h:151
int32 * wordbestexits
Definition: fast_algo_struct.h:164
float32 tighten_factor
Definition: fast_algo_struct.h:230
int32 svq4svq
Definition: fast_algo_struct.h:262