PocketSphinx
0.6
Main Page
Data Structures
Files
File List
Globals
hmm.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
42
#ifndef __HMM_H__
43
#define __HMM_H__
44
45
/* System headers. */
46
#include <stdio.h>
47
48
/* SphinxBase headers. */
49
#include <sphinxbase/fixpoint.h>
50
#include <sphinxbase/listelem_alloc.h>
51
52
/* PocketSphinx headers. */
53
#include "
bin_mdef.h
"
54
55
#ifdef __cplusplus
56
extern
"C"
{
57
#endif
58
#if 0
59
}
/* Fool Emacs into not indenting things. */
60
#endif
61
63
#define SENSCR_SHIFT 10
64
74
#define WORST_SCORE ((int)0xE0000000)
75
80
#define TMAT_WORST_SCORE (-255)
81
85
#define BETTER_THAN >
86
90
#define WORSE_THAN <
91
136
typedef
struct
hmm_context_s
{
137
int32
n_emit_state
;
138
uint8 **
const
*
tp
;
139
int16
const
*
senscore
;
141
uint16 *
const
*
sseq
;
142
int32 *
st_sen_scr
;
143
listelem_alloc_t *
mpx_ssid_alloc
;
144
void
*
udata
;
145
}
hmm_context_t
;
146
150
#define HMM_MAX_NSTATE 5
151
160
typedef
struct
hmm_s
{
161
hmm_context_t
*
ctx
;
162
int32
score
[
HMM_MAX_NSTATE
];
163
int32
history
[
HMM_MAX_NSTATE
];
164
int32
out_score
;
165
int32
out_history
;
166
uint16
ssid
;
167
uint16
senid
[
HMM_MAX_NSTATE
];
168
int32
bestscore
;
169
int16
tmatid
;
170
int16
frame
;
171
uint8
mpx
;
172
uint8
n_emit_state
;
173
}
hmm_t
;
174
176
#define hmm_context(h) (h)->ctx
177
#define hmm_is_mpx(h) (h)->mpx
178
179
#define hmm_in_score(h) (h)->score[0]
180
#define hmm_score(h,st) (h)->score[st]
181
#define hmm_out_score(h) (h)->out_score
182
183
#define hmm_in_history(h) (h)->history[0]
184
#define hmm_history(h,st) (h)->history[st]
185
#define hmm_out_history(h) (h)->out_history
186
187
#define hmm_bestscore(h) (h)->bestscore
188
#define hmm_frame(h) (h)->frame
189
#define hmm_mpx_ssid(h,st) (h)->senid[st]
190
#define hmm_nonmpx_ssid(h) (h)->ssid
191
#define hmm_ssid(h,st) (hmm_is_mpx(h) \
192
? hmm_mpx_ssid(h,st) : hmm_nonmpx_ssid(h))
193
#define hmm_mpx_senid(h,st) (hmm_mpx_ssid(h,st) == BAD_SENID \
194
? BAD_SENID : (h)->ctx->sseq[hmm_mpx_ssid(h,st)][st])
195
#define hmm_nonmpx_senid(h,st) ((h)->senid[st])
196
#define hmm_senid(h,st) (hmm_is_mpx(h) \
197
? hmm_mpx_senid(h,st) : hmm_nonmpx_senid(h,st))
198
#define hmm_senscr(h,st) (hmm_senid(h,st) == BAD_SENID \
199
? WORST_SCORE \
200
: -(h)->ctx->senscore[hmm_senid(h,st)])
201
#define hmm_tmatid(h) (h)->tmatid
202
#define hmm_tprob(h,i,j) (-(h)->ctx->tp[hmm_tmatid(h)][i][j])
203
#define hmm_n_emit_state(h) ((h)->n_emit_state)
204
#define hmm_n_state(h) ((h)->n_emit_state + 1)
205
209
hmm_context_t
*hmm_context_init(int32 n_emit_state,
210
uint8 **
const
*tp,
211
int16
const
*senscore,
212
uint16 *
const
*sseq);
213
217
#define hmm_context_set_senscore(ctx, senscr) ((ctx)->senscore = (senscr))
218
226
void
hmm_context_free(
hmm_context_t
*ctx);
227
231
void
hmm_init(
hmm_context_t
*ctx,
hmm_t
*hmm,
int
mpx,
int
ssid,
int
tmatid);
232
236
void
hmm_deinit(
hmm_t
*hmm);
237
243
void
hmm_clear(
hmm_t
*h);
244
248
void
hmm_clear_scores(
hmm_t
*h);
249
253
void
hmm_normalize(
hmm_t
*h, int32 bestscr);
254
258
void
hmm_enter(
hmm_t
*h, int32 score,
259
int32 histid,
int
frame);
260
273
int32 hmm_vit_eval(
hmm_t
*hmm);
274
275
279
int32 hmm_dump_vit_eval(
hmm_t
*hmm,
280
FILE *fp
281
);
282
287
void
hmm_dump(
hmm_t
*h,
288
FILE *fp
289
);
290
291
292
#if 0
293
{
/* Stop indent from complaining */
294
#endif
295
#ifdef __cplusplus
296
}
297
#endif
298
299
#endif
/* __HMM_H__ */
src
libpocketsphinx
hmm.h
Generated by
1.8.1.1