ctxt_table.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1995-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  * ctxt_table.h -- Phone Context Table Structure
00039  *
00040  * **********************************************
00041  * CMU ARPA Speech Project
00042  *
00043  * Copyright (c) 1995 Carnegie Mellon University.
00044  * ALL RIGHTS RESERVED.
00045  * **********************************************
00046  * 14-Jul-05    ARCHAN (archan@cs.cmu.edu) at Carnegie Mellon Unversity 
00047  *              First created it. 
00048  *
00049  * $Log$
00050  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00051  * A Great Reorganzation of header files and executables
00052  * 
00053  * Revision 1.2  2006/02/22 20:46:05  arthchan2003
00054  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: ctxt_table is a wrapper of the triphone context structure and its maniuplations which were used in flat_fwd.c .  The original flat_fwd.c was very long (3000) lines.  It was broken in 5 parts, ctxt_table is one of the 5.
00055  *
00056  * Revision 1.1.2.2  2005/09/27 07:39:17  arthchan2003
00057  * Added ctxt_table_free.
00058  *
00059  * Revision 1.1.2.1  2005/09/25 19:08:25  arthchan2003
00060  * Move context table from search to here.
00061  *
00062  * Revision 1.1.2.3  2005/09/07 23:32:03  arthchan2003
00063  * 1, Added get_lcpid in parrallel with get_rcpid. 2, Also fixed small mistakes in the macro.
00064  *
00065  * Revision 1.1.2.2  2005/07/17 05:42:27  arthchan2003
00066  * Added super-detailed comments ctxt_table.h. Also added dimension to the arrays that stores all context tables.
00067  *
00068  * Revision 1.1.2.1  2005/07/15 07:48:32  arthchan2003
00069  * split the hmm (whmm_t) and context building process (ctxt_table_t) from the the flat_fwd.c
00070  *
00071  *
00072  */
00073 
00074 /* 
00075  * \file ctxt_table.h
00076  * \brief data structure for building cross word triphones for Sphinx 3. 
00077  */
00078 
00079 #ifndef _CTX_TAB_
00080 #define _CTX_TAB_
00081 
00082 #include <s3types.h>
00083 #include <prim_type.h>
00084 #include <mdef.h>
00085 #include <dict.h>
00086 
00087 
00088 #ifdef __cplusplus
00089 extern "C" {
00090 #endif
00091 #if 0
00092 /* Fool Emacs. */
00093 }
00094 #endif
00095 
00111 typedef struct {
00112     s3ssid_t  *ssid;    
00113     s3cipid_t *cimap;   
00114     int32     n_ssid;   
00115 } xwdssid_t;
00116 
00117 
00118 #define ctxt_table_left_ctxt_ssid(ct,l,b,r)  ((ct)->lcssid[b][r].ssid[ct->lcssid[b][r].cimap[l]])
00119 #define ctxt_table_word_int_ssid(ct,wid,wpos)  ((ct)->wwssid[wid][wpos])
00120 #define ctxt_table_right_ctxt_ssid(ct,l,b,r)  ((ct)->rcssid[b][l].ssid[ct->rcssid[b][l].cimap[r]])
00121 #define ctxt_table_single_phone_ssid(ct,l,b,r)  ((ct)->lrcssid[b][l].ssid[ct->lrcssid[b][l].cimap[r]])
00122 
00353 typedef struct {
00354     xwdssid_t **lcssid; 
00359     xwdssid_t **rcssid; 
00364     xwdssid_t **lrcssid; 
00370     s3ssid_t **wwssid;  
00374     int32 n_backoff_ci; 
00375     int32 n_ci, n_word;
00376 } ctxt_table_t ;
00377 
00382 ctxt_table_t *ctxt_table_init(dict_t *dict,  
00383                               mdef_t *mdef   
00384     );
00385 
00390 void ctxt_table_free(ctxt_table_t *ct); 
00395 void get_rcssid (ctxt_table_t *ct,   
00396                  s3wid_t w,          
00397                  s3ssid_t **ssid,    
00398                  int32 *nssid,       
00399                  dict_t *dict        
00400     );
00401 
00405 void get_lcssid (ctxt_table_t *ct,  
00406                  s3wid_t w,         
00407                  s3ssid_t **ssid,    
00408                  int32 *nssid,      
00409                  dict_t *dict       
00410     );
00411 
00412 
00418 s3cipid_t *get_rc_cimap (ctxt_table_t *ct, 
00419                          s3wid_t w, 
00420                          dict_t *dict 
00421     );
00422 
00428 s3cipid_t *get_lc_cimap (ctxt_table_t *ct, 
00429                          s3wid_t w, 
00430                          dict_t *dict 
00431     );
00432 
00438 int32 ct_get_rc_nssid (ctxt_table_t *ct,  
00439                        s3wid_t w,          
00440                        dict_t *dict        
00441     );
00442 
00443 #ifdef __cplusplus
00444 }
00445 #endif
00446 
00447 
00448 #endif /*_CTX_TAB_*/

Generated on 7 Mar 2010 by  doxygen 1.6.1