This file is indexed.

/usr/include/sphinx3/approx_cont_mgau.h is in libs3decoder-dev 0.8-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
 * Copyright (c) 1999-2004 Carnegie Mellon University.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * This work was supported in part by funding from the Defense Advanced 
 * Research Projects Agency and the National Science Foundation of the 
 * United States of America, and the CMU Sphinx Speech Consortium.
 *
 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 *
 */
/*
 * approx_cont_mgau.h
 * 
 * **********************************************
 * CMU ARPA Speech Project
 *
 * Copyright (c) 1999 Carnegie Mellon University.
 * ALL RIGHTS RESERVED.
 * **********************************************
 * 
 * HISTORY
 * $Log$
 * Revision 1.1  2006/04/05  20:27:30  dhdfu
 * A Great Reorganzation of header files and executables
 * 
 * Revision 1.10  2005/06/21 18:05:12  arthchan2003
 * Log. approx_cont_mgau_frame_eval has interface's changes. ci_senscr,
 * best_score is now wrapped up ascr_t. approx_cont_mgau_ci_eval is now
 * taking care of maxing ci senone score for a frame.
 *
 * Revision 1.6  2005/06/09 20:55:29  archan
 * Add comments for approx_cont_mgau.h.
 *
 * Revision 1.5  2005/04/20 03:30:58  archan
 * Part of refactoring: move best scores inside approx_cont_mgau.h
 *
 * Revision 1.4  2005/03/30 01:22:46  archan
 * Fixed mistakes in last updates. Add
 *
 * 
 * 23-Jan-2004 Arthur Chan (archan@cs.cmu.edu)
 *             started
 */


#ifndef _S3_APPROXCONGAU_H_
#define _S3_APPROXCONGAU_H_

#include <logmath.h>
#include <profile.h>
#include "cont_mgau.h"
#include "subvq.h"
#include "gs.h"
#include "fast_algo_struct.h"
#include "ascr.h"
#include "mdef.h"
#include "s3types.h"

#ifdef __cplusplus
extern "C" {
#endif
#if 0
} /* Fool Emacs into not indenting things. */
#endif

/** \file approx_cont_mgau.h
 * \brief Master function to compute the approximate score of mixture of Gaussians 
 \warning You need to have some knowledge in fast GMM computation in order to modifed this function. 
      
 This is the current schemes included:
 1, VQ-based Gaussian Selection 
 2, Subvq-based Gaussian Selection
 3, Context Independent Phone-based GMM Selection
 4, Down Sampling 
 a, dumb approach,
 b, conditional down sampling (currently can only be used with VQ-based Gaussian Selection
 c, distance-based down sampling 
      
 The above method of categorizing GMM computation in 4 levels are
 presented in ICSLP 2004.  For the publication, please visit
 Arthur Chan's web site at www.cs.cmu.edu/~archan/ .  
*/

/** 
    approx_con_mgau_frame_eval encapsulates all approximations in the
    Gaussian computation.  This assumes programmers NOT to initialize
    the senone scores at every frame before using this function. This
    modularize this routine but complicated issues such as
    frame-dropping which can also be done in the front-end

    This layer of code controls the optimization performance in Frame
    Leval and GMM Level.

    Frame Level:

    ^^^^^^^^^^^^

    We select to compute the scores only if it is not similar to the
    most recently computed frames.  There are multiple ways to
    configures this.

    Naive down-sampling : Skip the computation one every other n-frames

    Conditional down-sampling : Skip the computation only if the
    current frame doesn't belong to the same neighborhood of the same
    frame.  This neighborhood corresponds to the codeword which the
    feature vector found to be the closest.
   
    No matter which down-sampling was used, the following problem will
    appear in the computation.  Active senones of frame which supposed
    to be skipped in computation could be not computed in the most
    recently computed frame.  In those cases, we chose to compute those
    senones completely.

    GMM Level:

    ^^^^^^^^^^

    In the implementation of CI-based GMM selection makes use of the
    fact that in s3.3 , CI models are always placed before all CD
    models. Hence the following logic is implemented:

    if(it is CI senone)
    compute score
    else if (it is CD senone)
    if the ci-phone beam was not set 
    compute score
    else
    if the CD senone's parent has a score within the beam
    compute_score
    else CD senone's parent has a score out of the beam
    back-off using the parent senone score. 

    During s3.5, the idea of bestidx in a GMM has been changed and 
    the above logic becomes

    if(it is CI senone)
    compute score
    else if (it is CD senone)
    if the ci-phone beam was not set 
    compute score
    else
    if the CD senone's parent has a score within the beam
    compute_score
    else CD senone's parent has a score out of the beam
    if the bestindex of the last frame exists
    compute score using the bestidx
    then
    back-off using the parent senone score. 
	  
    About renormalization

    ^^^^^^^^^^^^^^^^^^^^^

    Sphinx 3.4 generally renormalize the score using the best
    score. Notice that this introduce extra complication to the
    implementation.  I have separated the logic of computing or not
    computing the scores.  This will clarify the code a bit.
   
    Accounting of senone and gaussian computation

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    This function assumes approx_cont_mgau_ci_eval was run before it,
    hence at the end the score was added on top of the it.
   
    Design

    ^^^^^^ 

    The whole idea of this function is based on my paper on "4-level
    categorization of GMM computation " which basically describe how
    different techniques of fast GMM computation should interact with
    each others.  The current implementation was there to make the
    code to be as short as possible. I hope that no one will try to make
    the code to be longer than 500 lines. 

    Imperfection
    ^^^^^^^^^^^^

    Imperfections of the code can be easily seen by experts so I want
    to point out before they freak out.  There are synchronization
    mechanism in the bestindex and rec_sen_active. That can easily be a
    source of error.  I didn't do it because somehow when you trust
    just the best matching index of the previous frame is slightly
    different from if you trust the score of the previous frame

    The sen_active, rec_sen_active and senscr should be inside the GMM
    structure rather than just a separate array. I didn't fix it
    because this change will also touch other data structures as well. 

    @see approx_mgau_eval 
    @return the best senone score
*/
S3DECODER_EXPORT
int32 approx_cont_mgau_frame_eval (mdef_t *mdef,
				   subvq_t *svq,
				   gs_t *gs, /**< Input mdef, svq and gs*/
				   mgau_model_t *g,
				   fast_gmm_t *fastgmm,	 /**< Input/Output: wrapper for
							    parameters for Fast GMM , for
							    all beams and parameters, during
							    the computation, the */
				   ascr_t *a,           /**< Input/Output: wrapper for all acoustic scores
							   arrays */
				   float32 *feat,	/**< Input: the current feature vector */
				   int32 frame,         /**< Input: The frame number */
				   int32 *cache_ci_senscr, /**< Input: The cache CI scores for this frame */
				   ptmr_t *tm_ovrhd,        /**< Output: the timer used for computing overhead */
				   logmath_t *logmath
    );


/**
 * Evaluate the approximate gaussian score for CI senone for one
 * frame.  In Sphinx 3.X (X=4,5), this routine is used to precompute
 * CI senone score as a kind of approximate match of the CD score.
 */

S3DECODER_EXPORT
void approx_cont_mgau_ci_eval (
    subvq_t *svq,
    gs_t *gs,
    mgau_model_t *g,
    fast_gmm_t *fg, /**< Input/Output: wrapper for
                       parameters for Fast GMM , for
                       all beams and parameters, during
                       the computation, the */
    mdef_t *mdef,  /**< Input : model definition */
    float32 *feat, /**< Input : the current frame of feature */
    int32 *ci_senscr, /** Input/Output : ci senone score, a one dimension array */
    int32 *best_score, /** Input/Output: the best score, a scalar */
    int32 fr, /** In : The frame number */
    logmath_t *logmath
    );

#if 0
{ /* Stop indent from complaining */
#endif
#ifdef __cplusplus
}
#endif

#endif