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 /* srch_word_switch_tree.c 00039 * HISTORY 00040 * 00041 * $Log$ 00042 * Revision 1.1 2006/04/05 20:27:30 dhdfu 00043 * A Great Reorganzation of header files and executables 00044 * 00045 * Revision 1.3 2006/02/23 16:52:56 arthchan2003 00046 * Merged from branch: SPHINX3_5_2_RCI_IRII_BRANCH: this fills in the code for doing tree propagation. However, rescoring is still being used. The code is working. However, it takes up huge amount of memory and I consider this as not elegant. It also shows that straight forward implementation of tree copies search doesn't work even in these days. 00047 * 00048 * 00049 * Revision 1.1.4.5 2006/01/16 20:15:37 arthchan2003 00050 * 1, removed the unlinksilences part, 2, added 2nd-stage interface, but now commented. 00051 * 00052 * Revision 1.1.4.4 2005/07/07 02:41:55 arthchan2003 00053 * 1, Added an experimental version of tree expansion interface it the code, it does tree expansion without history pruning. Currently disabled because it used to much memory space srch_word_switch_tree.[ch]. 2, Remove -lminsearch segments of code, it proves to be unnecessary. 3, Remove the rescoring interface. In this search, WST_rescoring is actually not doing rescoring, it is rather a segment of code which collect all active word end together and input it into the viterbi history. 00054 * 00055 * Revision 1.1.4.3 2005/07/04 07:24:15 arthchan2003 00056 * Added some comments 00057 * 00058 * Revision 1.1.4.2 2005/06/27 05:37:05 arthchan2003 00059 * Incorporated several fixes to the search. 1, If a tree is empty, it will be removed and put back to the pool of tree, so number of trees will not be always increasing. 2, In the previous search, the answer is always "STOP P I T G S B U R G H </s>"and filler words never occurred in the search. The reason is very simple, fillers was not properly propagated in the search at all <**exculamation**> This version fixed this problem. The current search will give <sil> P I T T S B U R G H </sil> </s> to me. This I think it looks much better now. 00060 * 00061 * Revision 1.1.4.1 2005/06/24 21:13:52 arthchan2003 00062 * 1, Turn on mode 5 again, 2, fixed srch_WST_end, 3, Add empty function implementations of add_lm and delete_lm in mode 5. This will make srch.c checking happy. 00063 * 00064 * Revision 1.2 2005/06/22 08:00:09 arthchan2003 00065 * Completed all doxygen documentation on file description for libs3decoder/libutil/libs3audio and programs. 00066 * 00067 * Revision 1.1 2005/06/22 02:45:52 arthchan2003 00068 * Log. Implementation of word-switching tree. Currently only work for a 00069 * very small test case and it's deliberately fend-off from users. Detail 00070 * omitted. 00071 * 00072 * Revision 1.9 2005/05/11 06:10:39 archan 00073 * Code for lattice and back track pointer table dumping is now wrapped in reg_result_dump. The function is shared across mode 4 and mode 5. Possibly later for mode 3 and mode 6 as well. 00074 * 00075 * Revision 1.8 2005/05/03 04:09:10 archan 00076 * Implemented the heart of word copy search. For every ci-phone, every word end, a tree will be allocated to preserve its pathscore. This is different from 3.5 or below, only the best score for a particular ci-phone, regardless of the word-ends will be preserved at every frame. The graph propagation will not collect unused word tree at this point. srch_WST_propagate_wd_lv2 is also as the most stupid in the century. But well, after all, everything needs a start. I will then really get the results from the search and see how it looks. 00077 * 00078 * 17-Mar-2005 A. Chan (archan@cs.cmu.edu) at Carnegie Mellon University 00079 * Started. Word condition tree search. Aka lexical tree copies. 00080 */ 00081 00082 #ifndef _SRCH_WST_H_ 00083 #define _SRCH_WST_H_ 00084 00089 #include "hash_table.h" 00090 #include "glist.h" 00091 #include "s3types.h" 00092 #include "kb.h" 00093 #include "lm.h" 00094 #include "lextree.h" 00095 #include "fast_algo_struct.h" 00096 00110 #ifdef __cplusplus 00111 extern "C" { 00112 #endif 00113 #if 0 00114 /* Fool Emacs. */ 00115 } 00116 #endif 00117 00118 typedef struct { 00119 int32 n_static_lextree; 00121 lextree_t *curroottree; 00123 lextree_t **expandtree; 00126 lextree_t *curfillertree; 00127 lextree_t **expandfillertree; 00132 lextree_t **roottree; 00135 hash_table_t *active_word; 00137 glist_t empty_tree_idx_stack; 00143 int32 no_active_word; 00145 lmset_t* lmset; 00146 int32 isLMLA; 00148 histprune_t *histprune; 00151 } srch_WST_graph_t ; 00152 00153 00154 extern struct srch_funcs_s srch_WST_funcs; 00155 00156 00157 int srch_WST_init(kb_t *kb, 00158 void* srch_struct 00159 ); 00160 00161 int srch_WST_uninit(void* srch_struct); 00162 int srch_WST_begin(void* srch_struct); 00163 int srch_WST_end(void* srch_struct); 00164 int srch_WST_decode(void* srch_struct); 00165 00166 int srch_WST_set_lm(void* srch_struct, const char* lmname); 00167 int srch_WST_add_lm(void* srch, lm_t *lm, const char *lmname); 00168 int srch_WST_delete_lm(void* srch, const char *lmname); 00169 00170 int srch_WST_gmm_compute_lv2(void* srch_struct, float32 *feat, int32 time); 00171 int srch_WST_hmm_compute_lv1(void* srch_struct); 00172 int srch_WST_hmm_compute_lv2(void* srch_struct, int32 frmno); 00173 int srch_WST_eval_beams_lv1 (void* srch_struct); 00174 int srch_WST_eval_beams_lv2 (void* srch_struct); 00175 int srch_WST_propagate_graph_ph_lv1(void* srch_struct); 00176 int srch_WST_propagate_graph_wd_lv1(void* srch_struct); 00177 00178 int srch_WST_propagate_graph_ph_lv2(void* srch_struct, int32 frmno); 00179 00183 int srch_WST_propagate_graph_wd_lv2(void* srch_struct, int32 frmno); 00184 00185 00186 int srch_WST_compute_heuristic(void *srch, int32 win_efv); 00187 int srch_WST_frame_windup(void *srch_struct,int32 frmno); 00188 int srch_WST_shift_one_cache_frame(void *srch,int32 win_efv); 00189 int srch_WST_select_active_gmm(void *srch); 00190 00191 glist_t srch_WST_gen_hyp(void* srch_struct 00192 ); 00193 00194 int srch_WST_dump_vithist(void* srch_struct 00195 ); 00196 00197 int srch_WST_bestpath_impl(void * srch_struct 00198 ); 00199 00200 #ifdef __cplusplus 00201 } 00202 #endif 00203 00204 #endif /* _SRCH_WST_H_ */