mdef.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  * mdef.h -- HMM model definition: base (CI) phones and triphones
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.1  2006/04/05  20:27:30  dhdfu
00050  * A Great Reorganzation of header files and executables
00051  * 
00052  * Revision 1.13  2006/02/22 16:52:51  arthchan2003
00053  * Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Fixed memory leaks in mdef. 2,  Fixed $, 3, Fixed dox-doc.
00054  *
00055  * Revision 1.12.4.2  2005/07/05 05:47:59  arthchan2003
00056  * Fixed dox-doc. struct level of documentation are included.
00057  *
00058  * Revision 1.12.4.1  2005/07/03 22:54:09  arthchan2003
00059  * move st2senmap into mdef_t, it was not properly freed before. \n
00060  *
00061  * Revision 1.12  2005/06/21 18:47:39  arthchan2003
00062  * Log. 1, Added breport flag to mdef_init, 2, implemented reporting functions to
00063  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added $Log$
00064  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00065  * A Great Reorganzation of header files and executables
00066  * 
00067  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added Revision 1.13  2006/02/22 16:52:51  arthchan2003
00068  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Fixed memory leaks in mdef. 2,  Fixed $, 3, Fixed dox-doc.
00069  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added
00070  *
00071  * Revision 1.5  2005/06/13 04:02:55  archan
00072  * Fixed most doxygen-style documentation under libs3decoder.
00073  *
00074  * Revision 1.4  2005/04/21 23:50:26  archan
00075  * Some more refactoring on the how reporting of structures inside kbcore_t is done, it is now 50% nice. Also added class-based LM test case into test-decode.sh.in.  At this moment, everything in search mode 5 is already done.  It is time to test the idea whether the search can really be used.
00076  *
00077  * Revision 1.3  2005/03/30 01:22:47  archan
00078  * Fixed mistakes in last updates. Add
00079  *
00080  * 19.Apr-2001  Ricky Houghton, added code for free allocated memory
00081  * 
00082  * 14-Oct-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
00083  *              Added mdef_sseq2sen_active().
00084  * 
00085  * 30-Apr-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
00086  *              Added senone-sequence id (ssid) to phone_t and appropriate functions to
00087  *              maintain it.  Instead, moved state sequence info to mdef_t.
00088  * 
00089  * 13-Jul-96    M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
00090  *              Added mdef_phone_str().
00091  * 
00092  * 01-Jan-96    M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
00093  *              Created.
00094  */
00095 
00096 
00097 #ifndef _S3_MDEF_H_
00098 #define _S3_MDEF_H_
00099 
00100 #include <stdio.h>
00101 
00102 #include <hash_table.h>
00103 #include "s3types.h"
00104 
00105 #ifdef __cplusplus
00106 extern "C" {
00107 #endif
00108 #if 0
00109 } /* Fool Emacs into not indenting things. */
00110 #endif
00111 
00120 typedef enum {
00121     WORD_POSN_INTERNAL = 0,     
00122     WORD_POSN_BEGIN = 1,        
00123     WORD_POSN_END = 2,          
00124     WORD_POSN_SINGLE = 3,       
00125     WORD_POSN_UNDEFINED = 4     
00126 } word_posn_t;
00127 #define N_WORD_POSN     4       
00128 #define WPOS_NAME       "ibesu" 
00129 #define S3_SILENCE_CIPHONE "SIL" 
00135 typedef struct {
00136     char *name;                 
00137     int32 filler;               
00139 } ciphone_t;
00140 
00145 typedef struct {
00146     s3ssid_t ssid;              
00149     s3tmatid_t tmat;            
00150     s3cipid_t ci, lc, rc;       
00151     word_posn_t wpos;           
00152     s3senid_t *state;           
00154 } phone_t;
00155 
00161 typedef struct ph_rc_s {
00162     s3cipid_t rc;               
00163     s3pid_t pid;                
00164     struct ph_rc_s *next;       
00165 } ph_rc_t;
00166 
00172 typedef struct ph_lc_s {
00173     s3cipid_t lc;               
00174     ph_rc_t *rclist;            
00175     struct ph_lc_s *next;       
00176 } ph_lc_t;
00177 
00178 
00184 typedef struct {
00185     int32 n_ciphone;            
00186     int32 n_phone;              
00187     int32 n_emit_state;         
00188     int32 n_ci_sen;             
00189     int32 n_sen;                
00190     int32 n_tmat;               
00192     hash_table_t *ciphone_ht;   
00193     ciphone_t *ciphone;         
00194     phone_t *phone;             
00195     s3senid_t **sseq;           
00197     int32 n_sseq;               
00199     s3senid_t *cd2cisen;        
00202     s3cipid_t *sen2cimap;       
00204     s3cipid_t sil;              
00206     ph_lc_t ***wpos_ci_lclist;  
00212     s3senid_t *st2senmap; 
00217 } mdef_t;
00218 
00220 #define mdef_is_fillerphone(m,p)        ((m)->ciphone[p].filler)
00221 #define mdef_n_ciphone(m)               ((m)->n_ciphone)
00222 #define mdef_n_phone(m)                 ((m)->n_phone)
00223 #define mdef_n_sseq(m)                  ((m)->n_sseq)
00224 #define mdef_n_emit_state(m)            ((m)->n_emit_state)
00225 #define mdef_n_sen(m)                   ((m)->n_sen)
00226 #define mdef_n_tmat(m)                  ((m)->n_tmat)
00227 #define mdef_pid2ssid(m,p)              ((m)->phone[p].ssid)
00228 #define mdef_pid2tmatid(m,p)            ((m)->phone[p].tmat)
00229 #define mdef_silphone(m)                ((m)->sil)
00230 #define mdef_sen2cimap(m)               ((m)->sen2cimap)
00231 #define mdef_sseq2sen(m,ss,pos)         ((m)->sseq[ss][pos])
00232 #define mdef_pid2ci(m,p)                ((m)->phone[p].ci)
00233 #define mdef_cd2cisen(m)                ((m)->cd2cisen)
00234 
00240 S3DECODER_EXPORT
00241 mdef_t *mdef_init (const char *mdeffile, 
00242                    int32 breport         
00243     );
00244 
00245 
00250 s3cipid_t mdef_ciphone_id (mdef_t *m,           
00251                            const char *ciphone  
00252     );
00253 
00258 S3DECODER_EXPORT
00259 const char *mdef_ciphone_str (mdef_t *m,        
00260                               s3cipid_t ci      
00261     );
00262 
00267 int32 mdef_is_ciphone (mdef_t *m,               
00268                        s3pid_t p                
00269     );
00270 
00275 int32 mdef_is_cisenone(mdef_t *m,               
00276                        s3senid_t s            
00277     );
00278 
00283 S3DECODER_EXPORT
00284 s3pid_t mdef_phone_id (mdef_t *m,               
00285                        s3cipid_t b,             
00286                        s3cipid_t l,             
00287                        s3cipid_t r,             
00288                        word_posn_t pos  
00289     );
00290 
00296 S3DECODER_EXPORT
00297 s3pid_t mdef_phone_id_nearest (mdef_t *m,       
00298                                s3cipid_t b,     
00299                                s3cipid_t l,     
00300                                s3cipid_t r,     
00301                                word_posn_t pos  
00302     );
00303 
00308 S3DECODER_EXPORT
00309 int32 mdef_phone_str (mdef_t *m,                
00310                       s3pid_t pid,              
00311                       char *buf         
00312     );
00313 
00318 S3DECODER_EXPORT
00319 int32 mdef_phone_components (mdef_t *m,         
00320                              s3pid_t p,         
00321                              s3cipid_t *b,      
00322                              s3cipid_t *l,      
00323                              s3cipid_t *r,      
00324                              word_posn_t *pos   
00325     );
00326 
00332 int32 mdef_hmm_cmp (mdef_t *m,                  
00333                     s3pid_t p1, 
00334                     s3pid_t p2  
00335     );
00336 
00341 void mdef_sseq2sen_active (mdef_t *mdef,        
00342                            uint8 *sseq,         
00344                            uint8 *sen           
00346     );
00347 
00349 void mdef_dump (FILE *fp,  
00350                 mdef_t *m  
00351     );
00352 
00354 void mdef_report(mdef_t *m 
00355     );
00356 
00358 void mdef_free_recursive_lc (ph_lc_t *lc 
00359     );
00360 void mdef_free_recursive_rc (ph_rc_t *rc 
00361     );
00362 
00364 S3DECODER_EXPORT
00365 void mdef_free (mdef_t *mdef 
00366     );
00367 
00368 
00369 #if 0
00370 { /* Stop indent from complaining */
00371 #endif
00372 #ifdef __cplusplus
00373 }
00374 #endif
00375 
00376 #endif

Generated on 7 Mar 2010 by  doxygen 1.6.1