This file is indexed.

/usr/include/sphinx3/s3_decode.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
/* -*- 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.
 *
 * ====================================================================
 *
 */
/*************************************************
 * CMU ARPA Speech Project
 *
 * Copyright (c) 2000 Carnegie Mellon University.
 * ALL RIGHTS RESERVED.
 *************************************************
 *
 *  May 14, 2004
 *    Created by Yitao Sun (yitao@cs.cmu.edu) based on the live.h created by
 *    Rita Singh.  The Live Decode API is the new top level API for Sphinx3.
 *    The goal of the Live Decode API is to provide a well documented and
 *    comprehensive API to control all aspects of the Sphinx3 speech decoder
 *    engine.
 *
 *    The return values, for example, hypothesis segments and string, unlike
 *    the rest of Sphinx3, are read-only, maintained internally, and clobbered
 *    by subsequent calls.
 */

/*
  revision 1.9
  date: 2004/09/03 21:45:26;  author: yitao;  state: Exp;  lines: +2 -2

  cleaning up remote_decode API by moving list operations into a list API
  ----------------------------
  revision 1.8
  date: 2004/09/03 16:50:56;  author: yitao;  state: Exp;  lines: +108 -37


  modified comments to suit the use of doc++-
  ----------------------------
  revision 1.7
  date: 2004/08/27 05:22:43;  author: yitao;  state: Exp;  lines: +75 -105


  removed remote-decode API from the linux compile.  added doc++ comments for live_decod
  e.h-
  ----------------------------
  revision 1.6
  date: 2004/08/25 20:44:31;  author: yitao;  state: Exp;  lines: +13 -15


  1.  added code to record uttid in live-decode
  2.  added more code to flesh out remote-decode.  not compiling yet.
  ----------------------------
  revision 1.5
  date: 2004/08/23 20:41:38;  author: yitao;  state: Exp;  lines: +1 -11

  basic implementation for remote-decode API.  not compiling yet.
  ----------------------------
  revision 1.4
  date: 2004/08/19 19:12:50;  author: yitao;  state: Exp;  lines: +1 -1

  incompleted files remote-decode API.
  ----------------------------
  revision 1.3
  date: 2004/08/09 21:40:36;  author: yitao;  state: Exp;  lines: +11 -20

  1.  fixed some bugs in Live-Decode API.  changed kb.c, kb.h, utt.c, live_decode.c, liv
  e_decode.h.
  2.  changed some filenames in src/programs/.  now there are 2 sets of livedecode and l
  ivepretend: one that uses the old API (livedecode and livepretend), and one that uses 
  the new API (livedecode2 and livepretend2).
  3.  modified Makefile.am to reflect the filename changes above.
  ----------------------------
  revision 1.2
  date: 2004/08/08 23:34:50;  author: arthchan2003;  state: Exp;  lines: +1 -1
  temporary fixes of live_decode.c and live_decode.h
  ----------------------------
  revision 1.1
  date: 2004/08/06 15:07:38;  author: yitao;  state: Exp;
  *** empty log message ***
  =============================================================================

*/

#include <cmd_ln.h>
#include <fe.h>
#include "s3types.h"
#include "sphinx3_export.h"
#include "kb.h"
#include "kbcore.h"
#include "dag.h"
#include "search.h"

#ifndef __S3_DECODE_H
#define __S3_DECODE_H

/** \file live_decode_API.h
 * \brief header for live mode decoding API 
 */
#ifdef __cplusplus
extern "C" {
#endif
#if 0
} /* Fool Emacs into not indenting things. */
#endif

S3DECODER_EXPORT
extern arg_t S3_DECODE_ARG_DEFS[];

#define S3_DECODE_SUCCESS			0
#define S3_DECODE_ERROR_OUT_OF_MEMORY		-0x01
#define S3_DECODE_ERROR_NULL_POINTER		-0x02
#define S3_DECODE_ERROR_INVALID_STATE		-0x04
#define S3_DECODE_ERROR_INTERNAL		-0x08

#define S3_DECODE_STATE_IDLE			0
#define S3_DECODE_STATE_DECODING		1
#define S3_DECODE_STATE_FINISHED		2

/** Wrapper structure for live-mode recognition
 */
S3DECODER_EXPORT
typedef struct
{
    /**
     * Knowledge base.
     */
    kb_t kb;

    /**
     * Pointer to the knowledge base core.
     */
    kbcore_t *kbcore;

    /**
     * Parameter: intervals at which wbeam is used for phone transitions.
     */
    int32 phones_skip;

    /**
     * Number of frames decoded.
     */
    int32 num_frames_decoded;

    /**
     * Number of frames entered.
     */
    int32 num_frames_entered;

    /**
     * Current state of the live decoder.
     */
    int32 state;

    /**
     * UTTID (obviously NOT) filled in by knowledge-base.
     */
    char *uttid;

    /**
     * The frame number at which the hypothesis is recorded.
     */
    int32 hyp_frame_num;

    /**
     * Hypothesis string.  Result (or partial result) of the recognition is
     * stored as a complete string.
     */
    char *hyp_str;

    /**
     * Hypothesis word segments.  Result (or partial result) of the recognition
     * is stored as word segments.  Null-terminated array.
     */
    hyp_t **hyp_segs;

    /**
     * Boolean indicates whether we will internally swap the samples. 
     */
    int32 swap;

    /**
     * Boolean indicates whether a partial hypothesis will be dumped. 
     */
    int32 phypdump;

    /**
     * Extension for the raw director 
     */
    const char* rawext;

} s3_decode_t;


/** Initializes a Sphinx3 decoder object (re-entrant).  Internal
    modules, eg. search algorithms, language model, accoustic model,
    etc, are read from file and initialized.  The decoder internal
    variables are set to a starting state.

    This version of the Sphinx3 decoder assumes the user has
    externally parsed arguments using <I>cmd_ln_parse_r()</I> or
    <I>cmd_ln_parse_file_r()</I>.  The user is responsible for calling
    <I>cmd_ln_free_r()</I> when he/she is done with the decoder.

    @param decoder Pointer to the decoder.
    @param config Pointer to the command-line object
                  returned by <i>cmd_ln_parse_r()</i>.
    @return 0 for success.  -1 for failure.
*/
S3DECODER_EXPORT
int s3_decode_init(s3_decode_t *_decode, cmd_ln_t *_config);

/** Wraps up the Sphinx3 decoder.  All internal modules are closed or unloaded.
    Internal variables are freed and/or set to a finishing state.  This
    function should be called once the user is finished with the Sphinx3
    decoder.

    @param decoder Pointer to the decoder.
    @see s3_decode_init
*/
S3DECODER_EXPORT
void s3_decode_close(s3_decode_t *_decode);

/** Marks the start of the current utterance.  An utterance is a session of
    speech decoding that starts with a call to <I>s3_decode_begin_utt()</I> and
    ends with a call to <I>{@link s3_decode_end_utt s3_decode_end_utt()}</I>.
    In the duration of an utterance, speech data is processed with either
    <I>{@link s3_decode_process_raw s3_decode_process_raw()}</I> or
    <I>{@link s3_decode_process_ceps s3_decode_process_ceps()}</I>.  Decoding
    results (hypothesis) can be retrieved any time after the start of an
    utterance using <I>{@link s3_decode_hypothesis s3_decode_hypothesis()}</I>.
    All previous results will be clobbered at the start of a new utterance.

    At the moment, there is an undocumented time limit to the length of an
    utterance.  (Yitao: there is?)

    @param decoder Pointer to the decoder.
    @param uttid Utterance ID string.  If <I>null</I>, a somewhat unique 
    utterance id will be generated instead.
    @return 0 for success.  -1 for failure.
    @see s3_decode_end_utt
    @see s3_decode_process
    @see s3_decode_hypothesis
*/
S3DECODER_EXPORT
int s3_decode_begin_utt(s3_decode_t *_decode, char *_uttid);

/** Marks the end of the current utterance.  The Sphinx3 decoder  can no longer
    process speech data until the start of the next utterance.  Any hypothesis
    retrieved prior to the end of the utterance is called a partial hypothesis.
    Any hypothesis retrieved after the end of the utterance is called the final
    hypothesis.  See <I>{@link s3_decode_hypothesis s3_decode_hypothesis()}</I>
    on how to retrieve hypothesis.

    @param decoder Pointer to the decoder
    @see s3_decode_begin_utt
    @see s3_decode_process
    @see s3_decode_hypothesis
*/
S3DECODER_EXPORT
void s3_decode_end_utt(s3_decode_t *_decode);

/** Process a buffer of cepstrum frames for the current utterance.  This 
    function has to be called in the duration of an utterance.  That is, in
    between calls to <I>{@link s3_decode_begin_utt s3_decode_begin_utt()}</I>
    and <I>{@link s3_decode_end_utt s3_decode_end_utt()}</I>.

    One common issue with Sphinx3 decoder is the mismatch of parameters to
    the signal processor and accoustic model.  Please double check with the
    accoustic model training scripts and your signal processing front-end to
    make sure the cepstrals are generated consistently.

    @param decoder Pointer to the decoder.
    @param frames Buffer of audio feature frames.
    @param num_frames Number of frames in the buffer.
    @return 0 for success.  -1 for failure.
    @see s3_decode_begin_utt
    @see s3_decode_end_utt
    @see s3_decode_process_ceps
*/
S3DECODER_EXPORT
int s3_decode_process(s3_decode_t *_decode, 
                      float32 **_frames,
                      int32 _num_frames);

/** Retrieve partial or final decoding results (hypothesis).  Any
    hypothesis retrieved prior to the end of the utterance is called a 
    partial hypothesis.  Any hypothesis retrieved after the end of the 
    utterance is called the final hypothesis.  The hypothesis can be
    returned in a plain READ-ONLY string and/or an array of READ-ONLY word
    segments.  In the plain string result, all filler and end words are
    filtered out as well as the pronouciation information.  What is left is a
    very readable string representation of the decoding result.  There is no
    such filtering in the word segment result.

    Here is an example on how to use the result returned by
    <I>s3_decode_hypothesis</I>:

    <PRE>
    s3_decode_t d;
    char *str, *uttid;
    hyp_t **segs;

    ...

    s3_decode_hypothesis(&d, &uttid, &str, &segs);
    printf("Decoded string: %s\n", str);
    for (; *segs; segs++) {
    printf("Word-segment id: %i\n", (*segs)->id);
    }
    </PRE>
    
    @param decoder Pointer to the decoder.
    @param hyp_str Return pointer to a READ-ONLY string.  If <I>null</I>,
    the string is not returned.
    @param hyp_segs Return pointer to a null-terminated array of word
    segments.  If <I>null</I>, the array is not returned.
    @return 0 for success.  -1 for failure.
*/
S3DECODER_EXPORT
int s3_decode_hypothesis(s3_decode_t *_decode, char **_uttid,
                         char **_hyp_str, hyp_t ***_hyp_segs);

/** Retrieve a word graph of final hypothesis.  You must call
 * s3_decode_end_utt() before this.  See {@link dag.h} and {@link
 * astar.h} for information on what to do with this structure.
 *
 * @param decoder Pointer to the decoder.
 * @return A dag_t structure, or NULL on failure.  This pointer
 * becomes invalid after a call to s3_decode_begin_utt().
 */
S3DECODER_EXPORT
dag_t *s3_decode_word_graph(s3_decode_t *_decode);

/** Set LM 
    @param _decode Pointer to the decode
    @param lmname the language model name
    @see s3_decode_read_lm s3_decode_delete_lm
*/
S3DECODER_EXPORT
void s3_decode_set_lm(s3_decode_t *_decode, const char *lmname);

/** Delete LM 
    @param _decode Pointer to the live mode decode
    @param lmname the language model name 
    @see s3_decode_set_lm s3_decode_read_lm
*/
S3DECODER_EXPORT
void s3_decode_delete_lm(s3_decode_t *_decode, const char *lmname);


/** Read LM from a file. 
    @param _decode Pointer to the decoder. 
    @param lmfile LM file name. 
    @param lmname LM name associated with this file. 
    @see s3_decode_set_lm
*/
S3DECODER_EXPORT
void s3_decode_read_lm(s3_decode_t *_decode,
                       const char *lmfile, 
                       const char *lmname);

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

#endif