srch_flat_fwd_internal.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1999-2004 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * This work was supported in part by funding from the Defense Advanced 
00019  * Research Projects Agency and the National Science Foundation of the 
00020  * United States of America, and the CMU Sphinx Speech Consortium.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00023  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00024  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00025  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00026  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * ====================================================================
00035  *
00036  */
00037 
00038 /*
00039  * HISTORY
00040  * $Log$
00041  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00042  * A Great Reorganzation of header files and executables
00043  * 
00044  * Revision 1.2  2006/02/23 05:16:14  arthchan2003
00045  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: Add wrapper of flat_fwd.c
00046  *
00047  * Revision 1.1.2.5  2006/01/16 20:11:23  arthchan2003
00048  * Interfaces for 2nd stage search, now commented.
00049  *
00050  * Revision 1.1.2.4  2005/11/17 06:42:15  arthchan2003
00051  * 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.
00052  *
00053  * Revision 1.1.2.3  2005/09/25 19:23:55  arthchan2003
00054  * 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.
00055  *
00056  * Revision 1.1.2.2  2005/09/18 01:45:19  arthchan2003
00057  * Filled in all implementation in srch_flat_fwd.[ch], like the FSG mode, it takes care of reporting itselft.
00058  *
00059  * Revision 1.1.2.1  2005/07/24 01:40:37  arthchan2003
00060  * (Incomplete) The implementation of flat-lexicon decoding.
00061  *
00062  *
00063  *
00064  */
00065 
00066 /* \file srch_flat_fwd.h
00067  * 
00068  * SOME ASSUMPTIONS
00069  *   - All phones (ciphones and triphones) have same HMM topology with n_state states.
00070  *   - Initial state = state 0; final state = state n_state-1.
00071  *   - Final state is a non-emitting state with no arcs out of it.
00072  *   - Some form of Bakis topology (ie, no cycles, except for self-transitions).
00073  *
00074  */
00075 
00076 #ifndef SRCH_FLT_FWD_INTERNAL
00077 #define SRCH_FLT_FWD_INTERNAL
00078 
00079 
00080 #include <stdio.h>
00081 
00082 #include <profile.h>
00083 #include <s3types.h>
00084 #include <lm.h>
00085 #include <kbcore.h>
00086 #include <vithist.h>
00087 #include <word_ugprob.h>
00088 #include <word_graph.h>
00089 #include <whmm.h>
00090 #include <hmm.h>
00091 #include <ctxt_table.h>
00092 #include <dict.h>
00093 
00094 #ifdef __cplusplus
00095 extern "C" {
00096 #endif
00097 #if 0
00098 /* Fool Emacs. */
00099 }
00100 #endif
00101 
00107 typedef struct {
00108     s3wid_t trace_wid;  
00109     int32 word_dump_sf; 
00110     int32 word_dump_ef; 
00111     int32 hmm_dump_sf;  
00112     int32 hmm_dump_ef;  
00113 } fwd_dbg_t ;
00114 
00115 
00123 typedef struct {
00124     s3latid_t latid;    
00125     int32 score;        
00126     s3cipid_t lc;       
00128 } backoff_t;
00129 
00130 typedef struct word_cand_s {
00131     s3wid_t wid;                
00132     struct word_cand_s *next;   
00133 } word_cand_t;
00134 
00135 
00136 /*
00137   \struct srch_FLAT_FWD_graph_t;
00138   
00139 */
00140 typedef struct srch_FLAT_FWD_graph_s {
00141 
00158     /*
00159       FIXME! This should be used by the generic search as well. 
00160     */
00161     char const *word_cand_dir;  
00165     char const *latfile_ext;    
00167     int32 word_cand_win;        
00170     word_cand_t **word_cand;    
00172     int32 n_word_cand;  
00179     hmm_context_t *hmmctx; 
00180     whmm_t **whmm;         
00182     word_ugprob_t **word_ugprob; 
00183     backoff_t *ug_backoff;       
00184     backoff_t *filler_backoff;   
00185     uint8 *tg_trans_done;       
00189     int32 *rcscore;     
00191     s3wid_t *word_cand_cf;      
00195     ctxt_table_t *ctxt;           
00200     fwd_dbg_t *fwdDBG;            
00202     latticehist_t *lathist;       
00204     /*
00205       states for the search 
00206     */ 
00207     int32 n_frm;        
00208     int32 final_state;      
00209     int32 renormalized; 
00210     int32 multiplex;       
00211     int32 multiplex_singleph;       
00213     /* Event count statistics */
00214     pctr_t* ctr_mpx_whmm;
00215     pctr_t* ctr_nonmpx_whmm;
00216     pctr_t* ctr_latentry;
00217 
00218     ptmr_t tm_hmmeval;
00219     ptmr_t tm_hmmtrans;
00220     ptmr_t tm_wdtrans;
00221 
00222     kbcore_t* kbcore;     
00223 } srch_FLAT_FWD_graph_t ;
00224 
00225 
00231 void build_word_cand_cf (int32 cf, 
00232                          dict_t *dict, 
00233                          s3wid_t* wcand_cf, 
00234                          int32 word_cand_win, 
00237                          word_cand_t ** wcand
00238 
00239     );
00240 
00241 
00242 
00246 int32 word_cand_load (FILE *fp,  
00247                       word_cand_t** wcand, 
00248                       dict_t *dict, 
00249                       char* uttid   
00250     );
00251 
00252 
00256 void word_cand_free ( word_cand_t ** wcand  
00257     );
00258 
00260 int32 whmm_eval(srch_FLAT_FWD_graph_t * fwg, int32 * senscr);
00261 
00262 void dump_all_whmm(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm,
00263                    int32 n_frm, int32 * senscr);
00264 
00265 void dump_all_word(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm);
00266 
00267 void whmm_renorm(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm, int32 bestscr);
00268 
00269 void whmm_transition(srch_FLAT_FWD_graph_t * fwg, whmm_t ** whmm, int32 w,
00270                      whmm_t * h);
00271 
00272 void word_enter(srch_FLAT_FWD_graph_t * fwg, s3wid_t w,
00273                 int32 score, s3latid_t l, s3cipid_t lc);
00274 
00275 void whmm_exit(srch_FLAT_FWD_graph_t * fwg,
00276                whmm_t ** whmm,
00277                latticehist_t * lathist,
00278                int32 thresh, int32 wordthresh, int32 phone_penalty);
00279 
00280 
00281 void word_trans(srch_FLAT_FWD_graph_t * fwg,
00282                 whmm_t ** whmm,
00283                 latticehist_t * lathist,
00284                 int32 thresh, int32 phone_penalty);
00285 
00286 void flat_fwd_dag_add_fudge_edges(srch_FLAT_FWD_graph_t * fwg,
00287                                   dag_t * dagp,
00288                                   int32 fudge,
00289                                   int32 min_ef_range,
00290                                   void *hist, dict_t * dict);
00291 
00292 #ifdef __cplusplus
00293 }
00294 #endif
00295 
00296 
00297 #endif /* SRCH_FLT_FWD_INTERNAL */

Generated on 7 Mar 2010 by  doxygen 1.6.1