SphinxBase  5prealpha
cmn.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  * cmn.h -- Various forms of cepstral mean normalization
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.13 2006/02/23 03:48:27 arthchan2003
53  * Resolved conflict in cmn.h
54  *
55  *
56  * Revision 1.12 2006/02/22 23:43:55 arthchan2003
57  * Merged from the branch SPHINX3_5_2_RCI_IRII_BRANCH: Put data structure into the cmn_t structure.
58  *
59  * Revision 1.11.4.2 2005/10/17 04:45:57 arthchan2003
60  * Free stuffs in cmn and feat corectly.
61  *
62  * Revision 1.11.4.1 2005/07/05 06:25:08 arthchan2003
63  * Fixed dox-doc.
64  *
65  * Revision 1.11 2005/06/21 19:28:00 arthchan2003
66  * 1, Fixed doxygen documentation. 2, Added $ keyword.
67  *
68  * Revision 1.4 2005/06/13 04:02:56 archan
69  * Fixed most doxygen-style documentation under libs3decoder.
70  *
71  * Revision 1.3 2005/03/30 01:22:46 archan
72  * Fixed mistakes in last updates. Add
73  *
74  *
75  * 20.Apr.2001 RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu)
76  * Added cmn_free() and moved *mean and *var out global space and named them cmn_mean and cmn_var
77  *
78  * 28-Apr-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
79  * Copied from previous version.
80  */
81 
82 
83 #ifndef _S3_CMN_H_
84 #define _S3_CMN_H_
85 
86 /* Win32/WinCE DLL gunk */
87 #include <sphinxbase/sphinxbase_export.h>
88 #include <sphinxbase/prim_type.h>
89 #include <sphinxbase/fe.h>
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 #if 0
95 /* Fool Emacs. */
96 }
97 #endif
98 
110 typedef enum cmn_type_e {
111  CMN_NONE = 0,
112  CMN_BATCH,
113  CMN_LIVE
114 } cmn_type_t;
115 
117 SPHINXBASE_EXPORT
118 extern const char *cmn_type_str[];
119 
121 SPHINXBASE_EXPORT
122 cmn_type_t cmn_type_from_str(const char *str);
123 
128 typedef struct {
129  mfcc_t *cmn_mean;
130  mfcc_t *cmn_var;
131  mfcc_t *sum;
132  int32 nframe;
133  int32 veclen;
134 } cmn_t;
135 
136 SPHINXBASE_EXPORT
137 cmn_t* cmn_init(int32 veclen);
138 
142 SPHINXBASE_EXPORT
143 void cmn (cmn_t *cmn,
144  mfcc_t **mfc,
145  int32 varnorm,
148  int32 n_frame
149  );
150 
151 #define CMN_WIN_HWM 800 /* #frames after which window shifted */
152 #define CMN_WIN 500
153 
157 SPHINXBASE_EXPORT
158 void cmn_live(cmn_t *cmn,
160  mfcc_t **incep,
161  int32 varnorm,
162  int32 nfr
163  );
164 
168 SPHINXBASE_EXPORT
169 void cmn_live_update(cmn_t *cmn);
170 
174 SPHINXBASE_EXPORT
175 void cmn_live_set(cmn_t *cmn, mfcc_t const *vec);
176 
180 SPHINXBASE_EXPORT
181 void cmn_live_get(cmn_t *cmn, mfcc_t *vec);
182 
183 /* RAH, free previously allocated memory */
184 SPHINXBASE_EXPORT
185 void cmn_free (cmn_t *cmn);
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif
SPHINXBASE_EXPORT void cmn_live_set(cmn_t *cmn, mfcc_t const *vec)
Set the live mean.
Definition: cmn_live.c:51
Basic type definitions used in Sphinx.
SPHINXBASE_EXPORT void cmn(cmn_t *cmn, mfcc_t **mfc, int32 varnorm, int32 n_frame)
CMN for the whole sentence.
Definition: cmn.c:100
SPHINXBASE_EXPORT void cmn_live_get(cmn_t *cmn, mfcc_t *vec)
Get the live mean.
Definition: cmn_live.c:73
SPHINXBASE_EXPORT cmn_type_t cmn_type_from_str(const char *str)
Convert string representation (from command-line) to cmn_type_t.
Definition: cmn.c:72
wrapper of operation of the cepstral mean normalization.
Definition: cmn.h:128
enum cmn_type_e cmn_type_t
Types of cepstral mean normalization to apply to the features.
SPHINXBASE_EXPORT const char * cmn_type_str[]
String representations of cmn_type_t values.
Definition: cmn.c:59
SPHINXBASE_EXPORT void cmn_live(cmn_t *cmn, mfcc_t **incep, int32 varnorm, int32 nfr)
CMN for one block of data, using live mean.
Definition: cmn_live.c:145
cmn_type_e
Types of cepstral mean normalization to apply to the features.
Definition: cmn.h:110
mfcc_t * cmn_mean
Temporary variable: current means.
Definition: cmn.h:129
mfcc_t * cmn_var
Temporary variables: stored the cmn variance.
Definition: cmn.h:130
mfcc_t * sum
The sum of the cmn frames.
Definition: cmn.h:131
SPHINXBASE_EXPORT void cmn_live_update(cmn_t *cmn)
Update live mean based on observed data.
Definition: cmn_live.c:112
int32 veclen
Length of cepstral vector.
Definition: cmn.h:133
int32 nframe
Number of frames.
Definition: cmn.h:132