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 * 00019 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 00020 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00022 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00023 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00024 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00025 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00026 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00027 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00029 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 * ==================================================================== 00032 * 00033 */ 00034 /* 00035 * fsg_lextree.h -- The collection of all the lextrees for the entire FSM. 00036 * 00037 * ********************************************** 00038 * CMU ARPA Speech Project 00039 * 00040 * Copyright (c) 2004 Carnegie Mellon University. 00041 * ALL RIGHTS RESERVED. 00042 * ********************************************** 00043 * 00044 * HISTORY 00045 * 00046 * $Log$ 00047 * Revision 1.1 2006/04/05 20:27:30 dhdfu 00048 * A Great Reorganzation of header files and executables 00049 * 00050 * Revision 1.2 2006/02/23 05:10:18 arthchan2003 00051 * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: Adaptation of Sphinx 2's FSG search into Sphinx 3 00052 * 00053 * Revision 1.1.2.4 2005/07/24 01:34:54 arthchan2003 00054 * Mode 2 is basically running. Still need to fix function such as resulting and build the correct utterance ID 00055 * 00056 * Revision 1.1.2.3 2005/07/17 05:44:32 arthchan2003 00057 * Added dag_write_header so that DAG header writer could be shared between 3.x and 3.0. However, because the backtrack pointer structure is different in 3.x and 3.0. The DAG writer still can't be shared yet. 00058 * 00059 * Revision 1.1.2.2 2005/07/13 18:39:47 arthchan2003 00060 * (For Fun) Remove the hmm_t hack. Consider each s2 global functions one-by-one and replace them by sphinx 3's macro. There are 8 minor HACKs where functions need to be removed temporarily. Also, there are three major hacks. 1, there are no concept of "phone" in sphinx3 dict_t, there is only ciphone. That is to say we need to build it ourselves. 2, sphinx2 dict_t will be a bunch of left and right context tables. This is currently bypass. 3, the fsg routine is using fsg_hmm_t which is just a duplication of CHAN_T in sphinx2, I will guess using hmm_evaluate should be a good replacement. But I haven't figure it out yet. 00061 * 00062 * Revision 1.1.2.1 2005/06/27 05:26:29 arthchan2003 00063 * Sphinx 2 fsg mainpulation routines. Compiled with faked functions. Currently fended off from users. 00064 * 00065 * Revision 1.1 2004/07/16 00:57:12 egouvea 00066 * Added Ravi's implementation of FSG support. 00067 * 00068 * Revision 1.3 2004/06/23 20:32:16 rkm 00069 * *** empty log message *** 00070 * 00071 * Revision 1.2 2004/05/27 14:22:57 rkm 00072 * FSG cross-word triphones completed (but for single-phone words) 00073 * 00074 * Revision 1.1.1.1 2004/03/01 14:30:31 rkm 00075 * 00076 * 00077 * Revision 1.1 2004/02/23 15:53:45 rkm 00078 * Renamed from fst to fsg 00079 * 00080 * Revision 1.2 2004/02/19 21:16:54 rkm 00081 * Added fsg_search.{c,h} 00082 * 00083 * Revision 1.1 2004/02/18 15:02:34 rkm 00084 * Added fsg_lextree.{c,h} 00085 * 00086 * 00087 * 18-Feb-2004 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon 00088 * Started. 00089 */ 00090 00091 00092 #ifndef __S2_FSG_LEXTREE_H__ 00093 #define __S2_FSG_LEXTREE_H__ 00094 00095 00096 #include <stdio.h> 00097 00098 #include <logmath.h> 00099 #include <cmd_ln.h> 00100 00101 #include "word_fsg.h" 00102 #include "fsg_psubtree.h" 00103 #include "hmm.h" 00104 #include "dict.h" 00105 #include "mdef.h" 00106 #include "ctxt_table.h" 00107 00108 00109 #ifdef __cplusplus 00110 extern "C" { 00111 #endif 00112 #if 0 00113 /* Fool Emacs. */ 00114 } 00115 #endif 00116 00117 typedef struct fsg_lextree_s { 00118 word_fsg_t *fsg; /* The fsg for which this lextree is built */ 00119 fsg_pnode_t **root; /* root[s] = lextree representing all transitions 00120 out of state s. Note that the "tree" for each 00121 state is actually a collection of trees, linked 00122 via fsg_pnode_t.sibling (root[s]->sibling) */ 00123 fsg_pnode_t **alloc_head; /* alloc_head[s] = head of linear list of all 00124 pnodes allocated for state s */ 00125 int32 n_pnode; /* #HMM nodes in search structure */ 00126 00127 dict_t *dict; 00128 mdef_t *mdef; 00129 ctxt_table_t *ctxt; 00130 } fsg_lextree_t; 00131 00132 /* Access macros */ 00133 #define fsg_lextree_root(lt,s) ((lt)->root[s]) 00134 #define fsg_lextree_n_pnode(lt) ((lt)->n_pnode) 00135 00136 00137 /* 00138 * Create, initialize, and return a new phonetic lextree for the given FSM. 00139 */ 00140 fsg_lextree_t *fsg_lextree_init (word_fsg_t *fsg, 00141 hmm_context_t *ctx, 00142 cmd_ln_t *config, 00143 logmath_t *logmath); 00144 00145 void fsg_lextree_free (fsg_lextree_t *); 00146 00147 00148 void fsg_lextree_dump (fsg_lextree_t *, FILE *); 00149 00150 00151 void fsg_lextree_utt_start (fsg_lextree_t *); 00152 void fsg_lextree_utt_end (fsg_lextree_t *); 00153 00154 #ifdef __cplusplus 00155 } 00156 #endif 00157 00158 00159 #endif