kbcore.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  * kbcore.h -- Structures for maintain the main models.
00039  * 
00040  * **********************************************
00041  * CMU ARPA Speech Project
00042  *
00043  * Copyright (c) 1999 Carnegie Mellon University.
00044  * ALL RIGHTS RESERVED.
00045  * **********************************************
00046  * 
00047  * HISTORY
00048  * $Log$
00049  * Revision 1.2  2006/04/06  14:03:02  dhdfu
00050  * Prevent confusion among future generations by calling this s2_semi_mgau instead of sc_vq
00051  * 
00052  * Revision 1.1  2006/04/05 20:27:30  dhdfu
00053  * A Great Reorganzation of header files and executables
00054  *
00055  * Revision 1.12  2006/02/23 05:54:58  arthchan2003
00056  * Merged from the branch SPHINX3_5_2_RCI_IRII_BRANCH
00057  * 1, Added linksilences.  This allows silences to be linked correctly in mode FLAT, TREE.
00058  * 2, Added s3_am_init: an all-in-one initalization routine SCHMM and CDHMM.
00059  *
00060  * Revision 1.11.4.5  2006/01/16 18:25:16  arthchan2003
00061  * Sphinx 3.x tree decoders assume silences are unlinked (set them to BAD_S3WID) before used. Whereas the flat lexicon decode doesn't have this assumption.  The changes in versions this branch also significantly changed behavior of the decoder. Thus the function LinkSilences is introduced to change back the behavior if necessary.
00062  *
00063  * Revision 1.11.4.4  2005/09/18 01:29:37  arthchan2003
00064  * 1, .s3cont. mode is supported.  When it is specified by -senmgau, it will invoke the MS version of GMM computation even for CDHMM. Not supposed to be documented for users. 2, Remove unlinkSilences and put it inside search-specific initialization.  Apparently, remove it entirely will screw up the current test of mode 4 and 5.  add it back will screw up mode 3.  That's why I used temp solution.
00065  *
00066  * Revision 1.11.4.3  2005/08/03 18:54:32  dhdfu
00067  * Fix the support for multi-stream / semi-continuous models.  It is
00068  * still kind of a hack, but it now works.
00069  *
00070  * Revision 1.11.4.2  2005/08/02 21:33:47  arthchan2003
00071  * Factored the code of initializing one hmm into s3_am_init. That is to say initialization of mdef, mgau, var, mixw and tmat could all be found one function.
00072  *
00073  * Revision 1.11.4.1  2005/07/20 21:19:52  arthchan2003
00074  * Added options such that finite state grammar option is now accepted.
00075  *
00076  * Revision 1.11  2005/06/21 23:28:48  arthchan2003
00077  * Log. Please also see comments of kb.[ch].  Major changes you could see
00078  * is that the lmset interface is now used rather than several interfaces
00079  * for reading lm. Other than that, you could say most changes are
00080  * harmless internal interfaces changes.
00081  *
00082  * Revision 1.5  2005/06/18 03:22:29  archan
00083  * Add lmset_init. A wrapper function of various LM initialization and initialize an lmset It is now used in decode, livepretend, dag and astar.
00084  *
00085  * Revision 1.4  2005/04/20 03:38:43  archan
00086  * Do the corresponding code changes for the lm code.
00087  *
00088  * Revision 1.3  2005/03/30 01:22:47  archan
00089  * Fixed mistakes in last updates. Add
00090  *
00091  * 
00092  * 11-Feb-2000  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00093  *              Removed svqpp stuff.  It doesn't work too well anyway.
00094  * 
00095  * 06-Dec-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00096  *              Added kb_t.svqpp_t and related handling.
00097  * 
00098  * 30-Apr-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00099  *              Created.
00100  */
00101 
00102 
00103 #ifndef _S3_KBCORE_H_
00104 #define _S3_KBCORE_H_
00105 
00106 #include <s3types.h>
00107 #include <cmd_ln.h>
00108 #include <logmath.h>
00109 #include "feat.h"
00110 #include "cont_mgau.h"
00111 #include "ms_mgau.h"
00112 #include "s2_semi_mgau.h"
00113 #include "mdef.h"
00114 #include "dict.h"
00115 #include "dict2pid.h"
00116 #include "fillpen.h"
00117 #include "lm.h"
00118 #include "tmat.h"
00119 #include "subvq.h"
00120 #include "gs.h"
00121 
00122 
00123 #ifdef __cplusplus
00124 extern "C" {
00125 #endif
00126 #if 0
00127 } /* Fool Emacs into not indenting things. */
00128 #endif
00129 
00134 typedef struct {
00135     cmd_ln_t *config; 
00136     feat_t *fcb; 
00137     mdef_t *mdef; 
00138     dict_t *dict; 
00139     dict2pid_t *dict2pid; 
00141     lmset_t *lmset; 
00144     /*Specified either one of them when using kbcore.h.  It is not yet very nice now. */
00145     mgau_model_t *mgau; 
00146     ms_mgau_model_t *ms_mgau; 
00147     s2_semi_mgau_t *s2_mgau; 
00149     fillpen_t *fillpen; 
00150     subvq_t *svq; 
00151     gs_t *gs; 
00152     tmat_t *tmat; 
00154     int32 maxNewHeurScore; 
00155     int32 lastfrm; 
00157     s3lmwid32_t startwid;
00158     s3lmwid32_t finishwid;
00159     logmath_t *logmath;
00160 } kbcore_t;
00161 
00162   
00166 S3DECODER_EXPORT
00167 kbcore_t *New_kbcore(cmd_ln_t *config);
00168 
00173 S3DECODER_EXPORT
00174 void s3_am_init(kbcore_t *kbc);
00175 
00176 
00181 kbcore_t *kbcore_init(cmd_ln_t *config);
00182 
00184 S3DECODER_EXPORT
00185 void kbcore_free (kbcore_t *kbcore  
00186     );
00187 
00195 void unlinksilences(lm_t* l, kbcore_t *kbc, dict_t *d);
00196 
00197 void linksilences(lm_t* l, kbcore_t *kbc, dict_t *d);
00198 
00200 #define kbcore_config(k)        ((k)->config)
00201 #define kbcore_fcb(k)           ((k)->fcb)
00202 #define kbcore_mdef(k)          ((k)->mdef)
00203 #define kbcore_dict(k)          ((k)->dict)
00204 #define kbcore_dict2pid(k)      ((k)->dict2pid)
00205 #define kbcore_lm(k)            ((k)->lmset ? (k)->lmset->cur_lm : NULL)
00206 #define kbcore_fillpen(k)       ((k)->fillpen)
00207 #define kbcore_dict2lmwid(k,w)  ((k)->dict2lmwid[w])
00208 #define kbcore_mgau(k)          ((k)->mgau)
00209 #define kbcore_ms_mgau(k)       ((k)->ms_mgau)
00210 #define kbcore_s2_mgau(k)       ((k)->s2_mgau)
00211 #define kbcore_svq(k)           ((k)->svq)
00212 #define kbcore_gs(k)            ((k)->gs)
00213 #define kbcore_tmat(k)          ((k)->tmat)
00214 #define kbcore_lmset(k)         ((k)->lmset)
00215 /*#define kbcore_n_mgau(k)      ((k)->mgau ? mgau_n_mgau((k)->mgau) : (k)->ms_mgau->s->n_sen)
00216  */
00217 #define kbcore_n_mgau(k)        ((k)->mgau ? mgau_n_mgau((k)->mgau) \
00218                                 : ((k)->s2_mgau ? (k)->s2_mgau->CdWdPDFMod \
00219                                    : (k)->ms_mgau->s->n_sen))
00220 #define kbcore_logmath(k)       ((k)->logmath)
00221 
00222 
00223 
00224 #if 0
00225 { /* Stop indent from complaining */
00226 #endif
00227 #ifdef __cplusplus
00228 }
00229 #endif
00230 
00231 #endif

Generated on 7 Mar 2010 by  doxygen 1.6.1