root / trunk / Linux / addons / ofxASR / libs / sphinx / include / sphinx3 / gs.h @ 59

View | Annotate | Download (6.3 KB)

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
 * gs.h -- gaussian density module.
39
 *
40
 * **********************************************
41
 * CMU ARPA Speech Project
42
 *
43
 * Copyright (c) 1996 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.7  2006/02/22 16:41:58  arthchan2003
53
 * Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Fixed issue in $ keyword, 2, Fixed dox-doc
54
 *
55
 * Revision 1.6.4.1  2005/07/05 05:47:59  arthchan2003
56
 * Fixed dox-doc. struct level of documentation are included.
57
 *
58
 * Revision 1.6  2005/06/21 18:28:05  arthchan2003
59
 * Log. 1, Fixed doxygen documentation. 2, Add $Log$
60
 * Revision 1.1  2006/04/05  20:27:30  dhdfu
61
 * A Great Reorganzation of header files and executables
62
 * 
63
 * Log. 1, Fixed doxygen documentation. 2, Add Revision 1.7  2006/02/22 16:41:58  arthchan2003
64
 * Log. 1, Fixed doxygen documentation. 2, Add Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Fixed issue in $ keyword, 2, Fixed dox-doc
65
 * Log. 1, Fixed doxygen documentation. 2, Add
66
 * Log. 1, Fixed doxygen documentation. 2, Add Revision 1.6.4.1  2005/07/05 05:47:59  arthchan2003
67
 * Log. 1, Fixed doxygen documentation. 2, Add Fixed dox-doc. struct level of documentation are included.
68
 * Log. 1, Fixed doxygen documentation. 2, Add keyword.
69
 *
70
 * Revision 1.4  2005/06/13 04:02:55  archan
71
 * Fixed most doxygen-style documentation under libs3decoder.
72
 *
73
 * Revision 1.3  2005/03/30 01:22:46  archan
74
 * Fixed mistakes in last updates. Add
75
 *
76
 * 
77
 * 29-Dec-03    A. Chan ([email protected]) at Carnegie Mellon University.
78
 *              Initial version created           
79
 */
80
81
#ifndef _LIB_GS_H_
82
#define _LIB_GS_H_
83
84
#include <stdio.h>
85
86
#include <s3types.h>
87
#include <logmath.h>
88
89
/**  \file gs.h
90
 * \brief (Not opened to public) Gaussian selector Implentation
91
 * 
92
 * Implementation of Bochierri 93's idea of Gaussian Selection. A
93
 * pre-computed Gaussian selector map (not distributed in Sphinx 3 but
94
 * in s3fast.tgz distributed in Arthur Chan's web page) encode the
95
 * closest neighbors of a given codeword and a given GMM.
96
 *
97
 * In decoding, the closest codeword of the feature is first found and
98
 * the nearest neighborhood(s) for all GMMs will be retrieved from the
99
 * Gaussian selector map. 
100
 * 
101
 * The reason why this file is not opened to the public is because
102
 * sub-vector quantization supersed this idea conceptually.  Although
103
 * our SVQ implementation do not assume multiple Gaussians to be
104
 * computed given a sub-stream(sub-vector) codeword is found. It is
105
 * not difficult to extend the implementation to accomplish that. 
106
 * 
107
 * Saying this, for implementation symmetry, we should still check in the 
108
 * Gaussian selector implementation in this archive. 
109
 */
110
111
#ifdef __cplusplus
112
extern "C" {
113
#endif
114
#if 0
115
} /* Fool Emacs into not indenting things. */
116
#endif
117
118
/**
119
 *  \struct gs_t
120
 *  Wrapper structure of the gaussian selection algorithm
121
 */
122
typedef struct gs_s {
123
    logmath_t *logmath;
124
    int32 n_mgau;  /**< number of GMMs */
125
    int32 n_feat;  /**< number of streams */
126
    int32 n_code;  /**< number of code word */
127
    int32 n_density; /**< number of density */
128
    int32 n_featlen; /**< (This is not consistent to the Gaussian family of function */
129
    int32 n_mbyte; /**< number of bytes to read each time */
130
    float32 **codeword; /**< n_code * n_featlen */
131
    uint32 ***codemap; /**< n_feat * n_mgau * n_code*/
132
    FILE *fp;       /**< A file pointer to dump the gaussian selector */
133
    int32* mgau_sl; /**< The short list for how many Gaussians will be computed */
134
} gs_t;
135
136
137
/** display the Gaussian selector */
138
139
int32 gs_display(char *file, /**< file to display*/
140
                 gs_t *gs    /**< The structure of the gaussian selector*/
141
    );
142
143
/** Read the Gaussian selector */
144
gs_t* gs_read(const char *file, /**< a file to display */
145
              logmath_t *logmath
146
    );
147
148
/** Choose the closet Gaussian codebook to use */
149
int32 gc_compute_closest_cw ( gs_t *gs, /**< gaussain selector */
150
                              float32 *feat /**< feature */
151
    );
152
153
/** Find the short list of the Gaussian selector */
154
int32 gs_mgau_shortlist(gs_t *gs,  /**< gaussain selector */
155
                        int32 m,   /**< mixture index */
156
                        int32 n,   /**< number of mixtures */
157
                        float32 *feat, /**< feature vector */
158
                        int32 bst_codeid /**< best code indx */
159
    );
160
161
#if 0
162
{ /* Stop indent from complaining */
163
#endif
164
#ifdef __cplusplus
165
}
166
#endif
167
168
#endif