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