s2_semi_mgau.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  * Interface for "semi-continuous vector quantization", a.k.a. Sphinx2
39  * fast GMM computation.
40  */
41 
42 #ifndef __S2_SEMI_MGAU_H__
43 #define __S2_SEMI_MGAU_H__
44 
45 #include <logmath.h>
46 #include "s3types.h"
47 #include "fe.h"
48 #include "ascr.h"
49 #include "fast_algo_struct.h"
50 #include "kdtree.h"
51 
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 #if 0
57 /* Fool Emacs. */
58 }
59 #endif
60 
61 #define S2_NUM_ALPHABET 256
62 #define S2_NUM_FEATURES 4
63 #define S2_MAX_TOPN 6 /* max number of TopN codewords */
64 
65 typedef struct {
66  union {
67  int32 score;
68  int32 dist; /* distance to next closest vector */
69  } val;
70  int32 codeword; /* codeword (vector index) */
71 } vqFeature_t;
73 
74 typedef float32 mean_t;
75 typedef float32 var_t;
76 #define GMMSUB(a,b) ((a)-(b))
77 #define GMMADD(a,b) ((a)+(b))
78 
81  logmath_t *logmath;
82  int32 detArr[S2_NUM_FEATURES*S2_NUM_ALPHABET]; /* storage for det vectors */
83  int32 *dets[S2_NUM_FEATURES]; /* det values foreach feature */
84  mean_t *means[S2_NUM_FEATURES]; /* mean vectors foreach feature */
85  var_t *vars[S2_NUM_FEATURES]; /* var vectors foreach feature */
86 
87  unsigned char **OPDF_8B[4]; /* mixture weights */
88 
89  int32 topN;
90  int32 CdWdPDFMod;
91 
93  uint32 n_kdtrees;
94  uint32 kd_maxdepth;
95  int32 kd_maxbbi;
96  float64 dcep80msWeight;
98 
99  int32 num_frames;
101 
107 };
108 
109 s2_semi_mgau_t *s2_semi_mgau_init(const char *mean_path, const char *var_path,
110  float64 varfloor, const char *mixw_path,
111  float64 mixwfloor, int32 topn, logmath_t *logmath);
112 
114 
117  ascr_t *ascr,
118  fast_gmm_t *fgmm,
119  mfcc_t **feat,
120  int32 frame);
121 
122 int32 s2_semi_mgau_load_kdtree(s2_semi_mgau_t *s, const char *kdtree_path,
123  uint32 maxdepth, int32 maxbbi);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 
130 #endif /* __S2_SEMI_MGAU_H__ */