1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* ==================================================================== 3 * Copyright (c) 1995-2002 Carnegie Mellon University. All rights 4 * reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * This work was supported in part by funding from the Defense Advanced 19 * Research Projects Agency and the National Science Foundation of the 20 * United States of America, and the CMU Sphinx Speech Consortium. 21 * 22 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 23 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 26 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * ==================================================================== 35 * 36 */ 37 /* 38 * search.h -- All exported search-related functions and data structures. 39 * 40 * ********************************************** 41 * CMU ARPA Speech Project 42 * 43 * Copyright (c) 1996 Carnegie Mellon University. 44 * ALL RIGHTS RESERVED. 45 * ********************************************** 46 * 47 * HISTORY 48 * 49 * $Log$ 50 * Revision 1.1 2006/04/05 20:27:30 dhdfu 51 * A Great Reorganzation of header files and executables 52 * 53 * Revision 1.7 2006/02/28 22:29:39 egouvea 54 * Redefined hyp_t as "search_hyp_t" rather than "struct search_hyp_t". 55 * 56 * Revision 1.6 2006/02/24 12:43:18 arthchan2003 57 * Fixed typedef issue of hyp_t and srch_hyp_t. 58 * 59 * Revision 1.5 2006/02/23 15:12:09 arthchan2003 60 * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: Introduced srch_hyp_t and conf_srch_hyp_t. The former unifies the usage of multiple hyp_t in the past. The latter is only used in confidence estimation. 61 * 62 * Revision 1.4.4.5 2006/01/16 18:28:19 arthchan2003 63 * 1, Fixed dox-doc, 2, Added confidence scores parameter in search.h. Also change names of parameters. 64 * 65 * Revision 1.4.4.4 2005/11/17 06:30:37 arthchan2003 66 * Remove senscale from srch_hyp_t (Also see changes in vithist.[ch]). Added some preliminary structure for confidence score estimation. 67 * 68 * Revision 1.4.4.3 2005/07/26 02:19:20 arthchan2003 69 * Comment out hyp_t, change name of wid in srch_hyp_t to id. 70 * 71 * Revision 1.4.4.2 2005/07/24 19:34:46 arthchan2003 72 * Removed search_hyp_t, used srch_hyp_t instead 73 * 74 * Revision 1.4.4.1 2005/06/27 05:37:58 arthchan2003 75 * Fixes to make the search of fsg in place (NOT WORKING NOW) in Makefile.am. 76 * 77 * Revision 1.4 2005/06/21 23:34:39 arthchan2003 78 * Remove all dag functions. Eventually I may just want to delete the whole file as well. 79 * 80 * Revision 1.2 2005/06/03 05:46:19 archan 81 * Refactoring across dag/astar/decode_anytopo. Code is not fully tested. 82 * There are several changes I have done to refactor the code across 83 * dag/astar/decode_anyptop. A new library called dag.c is now created 84 * to include all routines that are shared by the three applications that 85 * required graph operations. 86 * 1, dag_link is now shared between dag and decode_anytopo. Unfortunately, astar was using a slightly different version of dag_link. At this point, I could only rename astar'dag_link to be astar_dag_link. 87 * 2, dag_update_link is shared by both dag and decode_anytopo. 88 * 3, hyp_free is now shared by misc.c, dag and decode_anytopo 89 * 4, filler_word will not exist anymore, dict_filler_word was used instead. 90 * 5, dag_param_read were shared by both dag and astar. 91 * 6, dag_destroy are now shared by dag/astar/decode_anytopo. Though for some reasons, even the function was not called properly, it is still compiled in linux. There must be something wrong at this point. 92 * 7, dag_bestpath and dag_backtrack are now shared by dag and decode_anytopo. One important thing to notice here is that decode_anytopo's version of the two functions actually multiply the LM score or filler penalty by the language weight. At this point, s3_dag is always using lwf=1. 93 * 8, dag_chk_linkscr is shared by dag and decode_anytopo. 94 * 9, decode_anytopo nows supports another three options -maxedge, -maxlmop and -maxlpf. Their usage is similar to what one could find dag. 95 * 96 * Notice that the code of the best path search in dag and that of 2-nd 97 * stage of decode_anytopo could still have some differences. It could 98 * be the subtle difference of handling of the option -fudge. I am yet 99 * to know what the true cause is. 100 * 101 * Some other small changes include 102 * -removal of startwid and finishwid asstatic variables in s3_dag.c. dict.c now hide these two variables. 103 * 104 * There are functions I want to merge but I couldn't and it will be 105 * important to say the reasons. 106 * i, dag_remove_filler_nodes. The version in dag and decode_anytopo 107 * work slightly differently. The decode_anytopo's one attached a dummy 108 * predecessor after removal of the filler nodes. 109 * ii, dag_search.(s3dag_dag_search and s3flat_fwd_dag_search) The handling of fudge is differetn. Also, decode_anytopo's one now depend on variable lattice. 110 * iii, dag_load, (s3dag_dag_load and s3astar_dag_load) astar and dag seems to work in a slightly different, one required removal of arcs, one required bypass the arcs. Don't understand them yet. 111 * iv, dag_dump, it depends on the variable lattice. 112 * 113 * Revision 1.1.1.1 2005/03/24 15:24:00 archan 114 * I found Evandro's suggestion is quite right after yelling at him 2 days later. So I decide to check this in again without any binaries. (I have done make distcheck. ) . Again, this is a candidate for s3.6 and I believe I need to work out 4-5 intermediate steps before I can complete the first prototype. That's why I keep local copies. 115 * 116 * Revision 1.3 2004/12/06 10:52:01 arthchan2003 117 * Enable doxygen documentation in libs3decoder 118 * 119 * Revision 1.2 2004/08/31 08:43:47 arthchan2003 120 * Fixing _cpluscplus directive 121 * 122 * Revision 1.1 2004/08/09 00:17:12 arthchan2003 123 * Incorporating s3.0 align, at this point, there are still some small problems in align but they don't hurt. For example, the score doesn't match with s3.0 and the output will have problem if files are piped to /dev/null/. I think we can go for it. 124 * 125 * Revision 1.2 2002/12/03 23:02:44 egouvea 126 * Updated slow decoder with current working version. 127 * Added copyright notice to Makefiles, *.c and *.h files. 128 * Updated some of the documentation. 129 * 130 * Revision 1.1.1.1 2002/12/03 20:20:46 robust 131 * Import of s3decode. 132 * 133 * 134 * 07-Nov-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 135 * Added onlynodes argument to dag_dump(). 136 * 137 * 12-Sep-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 138 * Changed fwd_sen_active to flag active senones instead of building a list 139 * of them. 140 * 141 * 24-Jun-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 142 * Added dag_search(). 143 * 144 * 20-Jan-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 145 * Added function fwd_sen_active() to obtain list of active senones in 146 * current frame. 147 * 148 * 04-Dec-95 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 149 * Started. 150 */ 151 152 153 #ifndef _LIBFBS_SEARCH_H_ 154 #define _LIBFBS_SEARCH_H_ 155 156 /** \file search.h 157 \brief The temporary header file for sphinx 3 functions. 158 */ 159 160 #include "s3types.h" 161 162 #ifdef __cplusplus 163 extern "C" { 164 #endif 165 #if 0 166 } /* Fool Emacs into not indenting things. */ 167 #endif 168 169 /** \struct srch_hyp_t 170 \brief a hypothesis structure 171 */ 172 typedef struct srch_hyp_s { 173 char *word; /**< A pointer to the word string*/ 174 175 int32 id; /**< Token ID; could be s3wid_t, s3cipid_t... 176 Interpreted by client. */ 177 178 179 int32 vhid; /**< Viterbi history (lattice) ID from which 180 this entry created Specific to Sphinx 3.x 181 mode 4 and mode 5*/ 182 183 int32 type; /**< Uninterpreted data; see vithist_entry_t in vithist.h */ 184 185 s3frmid_t sf; /**< Starting frame */ 186 s3frmid_t ef; /**< Ending frame */ 187 int32 ascr; /**< AM score */ 188 int32 lscr; /**< LM score */ 189 int32 pscr; /**< score for heuristic search (Only used in dag and astar)*/ 190 int32 cscr; /**< Use when the recognizer is generating word-based confidence scores */ 191 192 int32 fsg_state; /**< At which this entry terminates (FSG mode only) */ 193 194 struct srch_hyp_s *next; /**< a pointer to next structure, a convenient device such 195 that a programmer could choose to use it instead of using 196 a link list. Of course one could also use glist 197 */ 198 } srch_hyp_t; 199 200 /** \struct hyp_t 201 \brief an alias of srch_hyp_t; 202 */ 203 204 typedef srch_hyp_t hyp_t; 205 206 /** \struct conf_srch_hyp_t 207 \brief a hypothesis structure that stores the confidence scores. Mainly used in confidence.c 208 */ 209 210 typedef struct conf_srch_hyp { 211 srch_hyp_t sh; /**< a srch_hyp_t */ 212 float32 lmtype; /**< Language model type */ 213 float32 l1, l2, l3; 214 int32 matchtype; /**< (Currently not used) Match type: INSERTION, SUBSTITUTION, CORRECT */ 215 int compound; /**< (Currently not used) The compound type */ 216 struct conf_srch_hyp *next; /**< a pointer to the next structure */ 217 } conf_srch_hyp_t; 218 219 220 /** \struct seg_hyp_line_t 221 \brief a strurcture that stores one line of hypothesis. Mainly used in confidence.c 222 */ 223 224 typedef struct seg_hyp_line { 225 char seq[1024]; /**< The file name */ 226 int32 sent_end_cscore; /**< The confidenece score at the end of the utterance */ 227 int32 cscore ; /**< Confidence score */ 228 float32 lmtype; /**< LM type, depends on the backoff_modes */ 229 int32 wordno; /**< The number of word in a sentence */ 230 int32 nfr; /**< The number of frame in a sentence */ 231 int32 ascr; /**< The sentence acoustic model score */ 232 int32 lscr; /**< The sentence language model score */ 233 conf_srch_hyp_t *wordlist; /**< The list of words */ 234 } seg_hyp_line_t; 235 236 #if 0 237 { /* Stop indent from complaining */ 238 #endif 239 #ifdef __cplusplus 240 } 241 #endif 242 243 #endif 244