srch_flat_fwd_internal.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 /*
39  * HISTORY
40  * $Log$
41  * Revision 1.1 2006/04/05 20:27:30 dhdfu
42  * A Great Reorganzation of header files and executables
43  *
44  * Revision 1.2 2006/02/23 05:16:14 arthchan2003
45  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: Add wrapper of flat_fwd.c
46  *
47  * Revision 1.1.2.5 2006/01/16 20:11:23 arthchan2003
48  * Interfaces for 2nd stage search, now commented.
49  *
50  * Revision 1.1.2.4 2005/11/17 06:42:15 arthchan2003
51  * Added back crossword triphone traversing timing for search. Also. for consistency with srch.c. Some dummy code of IBM lattice conversion was added. They are now bypassed because it is not fully function.
52  *
53  * Revision 1.1.2.3 2005/09/25 19:23:55 arthchan2003
54  * 1, Added arguments for turning on/off LTS rules. 2, Added arguments for turning on/off composite triphones. 3, Moved dict2pid deallocation back to dict2pid. 4, Tidying up the clean up code.
55  *
56  * Revision 1.1.2.2 2005/09/18 01:45:19 arthchan2003
57  * Filled in all implementation in srch_flat_fwd.[ch], like the FSG mode, it takes care of reporting itselft.
58  *
59  * Revision 1.1.2.1 2005/07/24 01:40:37 arthchan2003
60  * (Incomplete) The implementation of flat-lexicon decoding.
61  *
62  *
63  *
64  */
65 
66 /* \file srch_flat_fwd.h
67  *
68  * SOME ASSUMPTIONS
69  * - All phones (ciphones and triphones) have same HMM topology with n_state states.
70  * - Initial state = state 0; final state = state n_state-1.
71  * - Final state is a non-emitting state with no arcs out of it.
72  * - Some form of Bakis topology (ie, no cycles, except for self-transitions).
73  *
74  */
75 
76 #ifndef SRCH_FLT_FWD_INTERNAL
77 #define SRCH_FLT_FWD_INTERNAL
78 
79 
80 #include <stdio.h>
81 
82 #include <profile.h>
83 #include <s3types.h>
84 #include <lm.h>
85 #include <kbcore.h>
86 #include <vithist.h>
87 #include <word_ugprob.h>
88 #include <word_graph.h>
89 #include <whmm.h>
90 #include <hmm.h>
91 #include <ctxt_table.h>
92 #include <dict.h>
93 
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 #if 0
98 /* Fool Emacs. */
99 }
100 #endif
101 
107 typedef struct {
109  int32 word_dump_sf;
110  int32 word_dump_ef;
111  int32 hmm_dump_sf;
112  int32 hmm_dump_ef;
113 } fwd_dbg_t ;
114 
115 
123 typedef struct {
125  int32 score;
128 } backoff_t;
129 
130 typedef struct word_cand_s {
132  struct word_cand_s *next;
133 } word_cand_t;
134 
135 
136 /*
137  \struct srch_FLAT_FWD_graph_t;
138 
139 */
140 typedef struct srch_FLAT_FWD_graph_s {
141 
158  /*
159  FIXME! This should be used by the generic search as well.
160  */
161  char const *word_cand_dir;
165  char const *latfile_ext;
172  int32 n_word_cand;
185  uint8 *tg_trans_done;
189  int32 *rcscore;
204  /*
205  states for the search
206  */
207  int32 n_frm;
208  int32 final_state;
209  int32 renormalized;
210  int32 multiplex;
213  /* Event count statistics */
214  pctr_t* ctr_mpx_whmm;
216  pctr_t* ctr_latentry;
217 
218  ptmr_t tm_hmmeval;
219  ptmr_t tm_hmmtrans;
220  ptmr_t tm_wdtrans;
221 
224 
225 
231 void build_word_cand_cf (int32 cf,
232  dict_t *dict,
233  s3wid_t* wcand_cf,
234  int32 word_cand_win,
237  word_cand_t ** wcand
238 
239  );
240 
241 
242 
246 int32 word_cand_load (FILE *fp,
247  word_cand_t** wcand,
248  dict_t *dict,
249  char* uttid
250  );
251 
252 
256 void word_cand_free ( word_cand_t ** wcand
257  );
258 
260 int32 whmm_eval(srch_FLAT_FWD_graph_t * fwg, int32 * senscr);
261 
262 void dump_all_whmm(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm,
263  int32 n_frm, int32 * senscr);
264 
265 void dump_all_word(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm);
266 
267 void whmm_renorm(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm, int32 bestscr);
268 
269 void whmm_transition(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm, int32 w,
270  whmm_t * h);
271 
273  int32 score, s3latid_t l, s3cipid_t lc);
274 
276  whmm_t ** whmm,
277  latticehist_t * lathist,
278  int32 thresh, int32 wordthresh, int32 phone_penalty);
279 
280 
282  whmm_t ** whmm,
283  latticehist_t * lathist,
284  int32 thresh, int32 phone_penalty);
285 
287  dag_t * dagp,
288  int32 fudge,
289  int32 min_ef_range,
290  void *hist, dict_t * dict);
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 
296 
297 #endif /* SRCH_FLT_FWD_INTERNAL */