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 */
void whmm_exit(srch_FLAT_FWD_graph_t *fwg, whmm_t **whmm, latticehist_t *lathist, int32 thresh, int32 wordthresh, int32 phone_penalty)
Definition: flat_fwd.c:552
int32 hmm_dump_ef
Definition: srch_flat_fwd_internal.h:112
int32 s3wid_t
Definition: s3types.h:136
int32 word_dump_ef
Definition: srch_flat_fwd_internal.h:110
Definition: srch_flat_fwd_internal.h:140
int32 multiplex
Definition: srch_flat_fwd_internal.h:210
whmm_t ** whmm
Definition: srch_flat_fwd_internal.h:180
void word_cand_free(word_cand_t **wcand)
Definition: flat_fwd.c:1277
int32 multiplex_singleph
Definition: srch_flat_fwd_internal.h:211
pctr_t * ctr_mpx_whmm
Definition: srch_flat_fwd_internal.h:214
kb core structures, the structure that stores parameters for s3.X search
void build_word_cand_cf(int32 cf, dict_t *dict, s3wid_t *wcand_cf, int32 word_cand_win, word_cand_t **wcand)
Definition: flat_fwd.c:1169
Operations on dictionary.
struct srch_FLAT_FWD_graph_s srch_FLAT_FWD_graph_t
int32 hmm_dump_sf
Definition: srch_flat_fwd_internal.h:111
int32 score
Definition: srch_flat_fwd_internal.h:125
int32 * rcscore
Definition: srch_flat_fwd_internal.h:189
latticehist_t * lathist
Definition: srch_flat_fwd_internal.h:202
struct word_cand_s * next
Definition: srch_flat_fwd_internal.h:132
int32 renormalized
Definition: srch_flat_fwd_internal.h:209
HMM data structure and operation.
s3wid_t trace_wid
Definition: srch_flat_fwd_internal.h:108
int32 final_state
Definition: srch_flat_fwd_internal.h:208
ptmr_t tm_hmmeval
Definition: srch_flat_fwd_internal.h:218
s3cipid_t lc
Definition: srch_flat_fwd_internal.h:126
s3latid_t latid
Definition: srch_flat_fwd_internal.h:124
uint8 * tg_trans_done
Definition: srch_flat_fwd_internal.h:185
int32 n_frm
Definition: srch_flat_fwd_internal.h:207
s3wid_t wid
Definition: srch_flat_fwd_internal.h:131
char const * latfile_ext
Definition: srch_flat_fwd_internal.h:165
hmm_context_t * hmmctx
Definition: srch_flat_fwd_internal.h:179
void dump_all_word(srch_FLAT_FWD_graph_t *fwg, whmm_t **whmm)
Definition: flat_fwd.c:366
int32 whmm_eval(srch_FLAT_FWD_graph_t *fwg, int32 *senscr)
Definition: flat_fwd.c:403
Definition: srch_flat_fwd_internal.h:123
void whmm_renorm(srch_FLAT_FWD_graph_t *fwg, whmm_t **whmm, int32 bestscr)
Definition: flat_fwd.c:463
s3wid_t * word_cand_cf
Definition: srch_flat_fwd_internal.h:191
kbcore_t * kbcore
Definition: srch_flat_fwd_internal.h:222
backoff_t * filler_backoff
Definition: srch_flat_fwd_internal.h:184
int16 s3cipid_t
Definition: s3types.h:110
pctr_t * ctr_nonmpx_whmm
Definition: srch_flat_fwd_internal.h:215
Viterbi history structures. Mainly vithist_t, also its slightly older brother latticehist_t. They are respectively used by decode (mode 4 and 5) and decode_anytopo (mode 3). The curent arrangement is temporary.
ctxt_table_t * ctxt
Definition: srch_flat_fwd_internal.h:195
Size definition of semantically units. Common for both s3 and s3.X decoder.
Shared information between a set of HMMs.
ptmr_t tm_wdtrans
Definition: srch_flat_fwd_internal.h:220
struct word_cand_s word_cand_t
Word HMM instance: the basic structure searched during recognition.
a structure for a dictionary.
Definition: dict.h:146
word_ugprob_t ** word_ugprob
Definition: srch_flat_fwd_internal.h:182
int32 word_cand_load(FILE *fp, word_cand_t **wcand, dict_t *dict, char *uttid)
Definition: flat_fwd.c:1205
void whmm_transition(srch_FLAT_FWD_graph_t *fwg, whmm_t **whmm, int32 w, whmm_t *h)
Definition: flat_fwd.c:486
pctr_t * ctr_latentry
Definition: srch_flat_fwd_internal.h:216
Definition: vithist.h:493
void flat_fwd_dag_add_fudge_edges(srch_FLAT_FWD_graph_t *fwg, dag_t *dagp, int32 fudge, int32 min_ef_range, void *hist, dict_t *dict)
Definition: flat_fwd.c:1097
ptmr_t tm_hmmtrans
Definition: srch_flat_fwd_internal.h:219
void dump_all_whmm(srch_FLAT_FWD_graph_t *fwg, whmm_t **whmm, int32 n_frm, int32 *senscr)
Definition: flat_fwd.c:342
void word_trans(srch_FLAT_FWD_graph_t *fwg, whmm_t **whmm, latticehist_t *lathist, int32 thresh, int32 phone_penalty)
Definition: flat_fwd.c:961
int32 word_cand_win
Definition: srch_flat_fwd_internal.h:167
backoff_t * ug_backoff
Definition: srch_flat_fwd_internal.h:183
int32 s3latid_t
Definition: s3types.h:166
Definition: dag.h:204
void word_enter(srch_FLAT_FWD_graph_t *fwg, s3wid_t w, int32 score, s3latid_t l, s3cipid_t lc)
Definition: flat_fwd.c:618
Definition: kbcore.h:134
Definition: srch_flat_fwd_internal.h:130
int32 word_dump_sf
Definition: srch_flat_fwd_internal.h:109
Language model.
Definition: ctxt_table.h:353
Definition: srch_flat_fwd_internal.h:107
int32 n_word_cand
Definition: srch_flat_fwd_internal.h:172
Word hmm instance that is used by sphinx 3.0 decode_anytopo search.
fwd_dbg_t * fwdDBG
Definition: srch_flat_fwd_internal.h:200
word_cand_t ** word_cand
Definition: srch_flat_fwd_internal.h:170
char const * word_cand_dir
Definition: srch_flat_fwd_internal.h:161