subvq.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2004 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  * subvq.h
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1999 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  *
47  * HISTORY
48  * $Log$
49  * Revision 1.1 2006/04/05 20:27:30 dhdfu
50  * A Great Reorganzation of header files and executables
51  *
52  * Revision 1.14 2006/02/22 17:43:32 arthchan2003
53  * Merged from SPHINX3_5_2_RCI_IRII_BRANCH:
54  * 1, vector_gautbl_free is not appropiate to be used in this case because it will free a certain piece of memory twice.
55  * 2, Fixed dox-doc.
56  *
57  * Revision 1.13.4.1 2005/07/05 05:47:59 arthchan2003
58  * Fixed dox-doc. struct level of documentation are included.
59  *
60  * Revision 1.13 2005/06/21 19:01:33 arthchan2003
61  * Added $ keyword.
62  *
63  * Revision 1.3 2005/03/30 01:22:47 archan
64  * Fixed mistakes in last updates. Add
65  *
66  *
67  * 20.Apr.2001 RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu)
68  * Updated subvq_free () to free more allocated memory
69  *
70  * 15-Dec-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
71  * Moved subvq_t.{frm_sen_eval,frm_gau_eval} to cont_mgau.h.
72  *
73  * 14-Dec-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
74  * Added subvq_t.{frm_sen_eval,frm_gau_eval}. Changed subvq_frame_eval to
75  * return the normalization factor.
76  *
77  * 06-Dec-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
78  * Added subvq_subvec_eval_logs3().
79  *
80  * 14-Oct-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
81  * Changed ci_active flags input to sen_active in subvq_frame_eval().
82  *
83  * 20-Jul-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
84  * Added subvq_gautbl_eval_logs3().
85  *
86  * 12-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
87  * Started.
88  */
89 
90 
91 #ifndef _S3_SUBVQ_H_
92 #define _S3_SUBVQ_H_
93 
94 #include <cmd_ln.h>
95 #include <logmath.h>
96 
97 #include "s3types.h"
98 #include "cont_mgau.h"
99 #include "vector.h"
100 
104 #ifdef __cplusplus
105 extern "C" {
106 #endif
107 #if 0
108 } /* Fool Emacs into not indenting things. */
109 #endif
110 
114 typedef struct {
115  arraysize_t origsize;
117  int32 n_sv;
118  int32 vqsize;
119  int32 **featdim;
121  int32 ***map;
126  /* Working space used during evaluation. */
127  float32 *subvec;
128  int32 **vqdist;
130  int32 *gauscore;
131  int32 *mgau_sl;
133  /* ARCHAN, 1111, 04, move the static global variables to the structure again. */
134  /* RAH, 5.8.01, VQ_EVAL determines how many vectors are used to
135  * compute the shortlist, for now this value is only relevant when n_sv =3.
136  * Setting it to 1 means that only the CEP values are estimated, 2 means that
137  * CEP and delta values are estimated, 3 means all three are estimated.
138  * Note, we must adjust the beam widths as we muck around with these.
139  */
140 
141  int32 VQ_EVAL;
142 } subvq_t;
143 
144 
167 subvq_t *subvq_init (const char *file,
168  float64 varfloor,
169  int32 max_sv,
171  mgau_model_t *g,
175  cmd_ln_t *config,
176  logmath_t *logmath
177  );
178 
179 
180 
182 void subvq_free (subvq_t *vq
183  );
184 
185 
193 int32 subvq_frame_eval (subvq_t *vq,
194  mgau_model_t *g,
195  int32 beam,
197  float32 *feat,
198  int32 *sen_active,
200  int32 *senscr
201  );
202 
208  float32 *feat,
211  logmath_t *logmath
212  );
213 
220  float32 *feat,
227  int32 sv,
230  logmath_t *logmath
231  );
232 
233 /*
234  * Based on previously computed subvq scores (Mahalanobis distances), determine the active
235  * components in the given mixture (using the vq->map).
236  * @return Number of candidates in the returned shortlist.
237  */
238 int32 subvq_mgau_shortlist (subvq_t *vq,
239  int32 m,
240  int32 n,
241  int32 beam
242  );
243 
244 
250 int32 subvq_mgau_eval (mgau_model_t *g,
251  subvq_t *vq,
252  int32 m,
253  int32 n,
254  int32 *active
255  );
256 
257 #if 0
258 { /* Stop indent from complaining */
259 #endif
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif