mdef.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  * mdef.h -- HMM model definition: base (CI) phones and triphones
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/22 16:52:51 arthchan2003
53  * Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Fixed memory leaks in mdef. 2, Fixed $, 3, Fixed dox-doc.
54  *
55  * Revision 1.12.4.2 2005/07/05 05:47:59 arthchan2003
56  * Fixed dox-doc. struct level of documentation are included.
57  *
58  * Revision 1.12.4.1 2005/07/03 22:54:09 arthchan2003
59  * move st2senmap into mdef_t, it was not properly freed before. \n
60  *
61  * Revision 1.12 2005/06/21 18:47:39 arthchan2003
62  * Log. 1, Added breport flag to mdef_init, 2, implemented reporting functions to
63  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added $Log$
64  * Revision 1.1 2006/04/05 20:27:30 dhdfu
65  * A Great Reorganzation of header files and executables
66  *
67  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added Revision 1.13 2006/02/22 16:52:51 arthchan2003
68  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added Merged from SPHINX3_5_2_RCI_IRII_BRANCH: 1, Fixed memory leaks in mdef. 2, Fixed $, 3, Fixed dox-doc.
69  * mdef_report. 3, Fixed doxygen-style documentation. 4, Added
70  *
71  * Revision 1.5 2005/06/13 04:02:55 archan
72  * Fixed most doxygen-style documentation under libs3decoder.
73  *
74  * Revision 1.4 2005/04/21 23:50:26 archan
75  * Some more refactoring on the how reporting of structures inside kbcore_t is done, it is now 50% nice. Also added class-based LM test case into test-decode.sh.in. At this moment, everything in search mode 5 is already done. It is time to test the idea whether the search can really be used.
76  *
77  * Revision 1.3 2005/03/30 01:22:47 archan
78  * Fixed mistakes in last updates. Add
79  *
80  * 19.Apr-2001 Ricky Houghton, added code for free allocated memory
81  *
82  * 14-Oct-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
83  * Added mdef_sseq2sen_active().
84  *
85  * 30-Apr-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
86  * Added senone-sequence id (ssid) to phone_t and appropriate functions to
87  * maintain it. Instead, moved state sequence info to mdef_t.
88  *
89  * 13-Jul-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
90  * Added mdef_phone_str().
91  *
92  * 01-Jan-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
93  * Created.
94  */
95 
96 
97 #ifndef _S3_MDEF_H_
98 #define _S3_MDEF_H_
99 
100 #include <stdio.h>
101 
102 #include <hash_table.h>
103 #include "s3types.h"
104 
105 #ifdef __cplusplus
106 extern "C" {
107 #endif
108 #if 0
109 } /* Fool Emacs into not indenting things. */
110 #endif
111 
120 typedef enum {
126 } word_posn_t;
127 #define N_WORD_POSN 4
128 #define WPOS_NAME "ibesu"
129 #define S3_SILENCE_CIPHONE "SIL"
135 typedef struct {
136  char *name;
137  int32 filler;
139 } ciphone_t;
140 
145 typedef struct {
150  s3cipid_t ci, lc, rc;
154 } phone_t;
155 
161 typedef struct ph_rc_s {
164  struct ph_rc_s *next;
165 } ph_rc_t;
166 
172 typedef struct ph_lc_s {
175  struct ph_lc_s *next;
176 } ph_lc_t;
177 
178 
184 typedef struct {
185  int32 n_ciphone;
186  int32 n_phone;
187  int32 n_emit_state;
188  int32 n_ci_sen;
189  int32 n_sen;
190  int32 n_tmat;
192  hash_table_t *ciphone_ht;
197  int32 n_sseq;
217 } mdef_t;
218 
220 #define mdef_is_fillerphone(m,p) ((m)->ciphone[p].filler)
221 #define mdef_n_ciphone(m) ((m)->n_ciphone)
222 #define mdef_n_phone(m) ((m)->n_phone)
223 #define mdef_n_sseq(m) ((m)->n_sseq)
224 #define mdef_n_emit_state(m) ((m)->n_emit_state)
225 #define mdef_n_sen(m) ((m)->n_sen)
226 #define mdef_n_tmat(m) ((m)->n_tmat)
227 #define mdef_pid2ssid(m,p) ((m)->phone[p].ssid)
228 #define mdef_pid2tmatid(m,p) ((m)->phone[p].tmat)
229 #define mdef_silphone(m) ((m)->sil)
230 #define mdef_sen2cimap(m) ((m)->sen2cimap)
231 #define mdef_sseq2sen(m,ss,pos) ((m)->sseq[ss][pos])
232 #define mdef_pid2ci(m,p) ((m)->phone[p].ci)
233 #define mdef_cd2cisen(m) ((m)->cd2cisen)
234 
241 mdef_t *mdef_init (const char *mdeffile,
242  int32 breport
243  );
244 
245 
251  const char *ciphone
252  );
253 
259 const char *mdef_ciphone_str (mdef_t *m,
260  s3cipid_t ci
261  );
262 
267 int32 mdef_is_ciphone (mdef_t *m,
268  s3pid_t p
269  );
270 
275 int32 mdef_is_cisenone(mdef_t *m,
276  s3senid_t s
277  );
278 
285  s3cipid_t b,
286  s3cipid_t l,
287  s3cipid_t r,
288  word_posn_t pos
289  );
290 
298  s3cipid_t b,
299  s3cipid_t l,
300  s3cipid_t r,
301  word_posn_t pos
302  );
303 
309 int32 mdef_phone_str (mdef_t *m,
310  s3pid_t pid,
311  char *buf
312  );
313 
319 int32 mdef_phone_components (mdef_t *m,
320  s3pid_t p,
321  s3cipid_t *b,
322  s3cipid_t *l,
323  s3cipid_t *r,
324  word_posn_t *pos
325  );
326 
332 int32 mdef_hmm_cmp (mdef_t *m,
333  s3pid_t p1,
334  s3pid_t p2
335  );
336 
341 void mdef_sseq2sen_active (mdef_t *mdef,
342  uint8 *sseq,
344  uint8 *sen
346  );
347 
349 void mdef_dump (FILE *fp,
350  mdef_t *m
351  );
352 
354 void mdef_report(mdef_t *m
355  );
356 
359  );
361  );
362 
365 void mdef_free (mdef_t *mdef
366  );
367 
368 
369 #if 0
370 { /* Stop indent from complaining */
371 #endif
372 #ifdef __cplusplus
373 }
374 #endif
375 
376 #endif
int32 n_sseq
Definition: mdef.h:197
strcture for storing the model definition.
Definition: mdef.h:184
S3DECODER_EXPORT s3pid_t mdef_phone_id(mdef_t *m, s3cipid_t b, s3cipid_t l, s3cipid_t r, word_posn_t pos)
struct ph_lc_s ph_lc_t
s3senid_t * state
Definition: mdef.h:152
int32 * ci
Definition: approx_cont_mgau.c:286
s3cipid_t * sen2cimap
Definition: mdef.h:202
int32 n_ciphone
Definition: mdef.h:185
int32 mdef_is_ciphone(mdef_t *m, s3pid_t p)
struct ph_lc_s * next
Definition: mdef.h:175
word_posn_t wpos
Definition: mdef.h:151
s3cipid_t rc
Definition: mdef.h:162
Definition: mdef.h:161
Definition: mdef.h:124
s3senid_t * cd2cisen
Definition: mdef.h:199
int32 filler
Definition: mdef.h:137
Definition: mdef.h:123
s3tmatid_t tmat
Definition: mdef.h:149
int32 n_phone
Definition: mdef.h:186
char * name
Definition: mdef.h:136
s3pid_t pid
Definition: mdef.h:163
int32 n_ci_sen
Definition: mdef.h:188
s3senid_t * st2senmap
Definition: mdef.h:212
int16 s3cipid_t
Definition: s3types.h:110
int32 s3tmatid_t
Definition: s3types.h:130
Size definition of semantically units. Common for both s3 and s3.X decoder.
int16 s3senid_t
Definition: s3types.h:178
void mdef_report(mdef_t *m)
void mdef_sseq2sen_active(mdef_t *mdef, uint8 *sseq, uint8 *sen)
#define S3DECODER_EXPORT
Definition: sphinx3_export.h:15
s3cipid_t sil
Definition: mdef.h:204
Structures for storing the left context.
s3ssid_t ssid
Definition: mdef.h:146
void mdef_dump(FILE *fp, mdef_t *m)
S3DECODER_EXPORT const char * mdef_ciphone_str(mdef_t *m, s3cipid_t ci)
s3pid_t s3ssid_t
Definition: s3types.h:124
Definition: mdef.h:125
s3cipid_t rc
Definition: mdef.h:150
s3senid_t ** sseq
Definition: mdef.h:195
S3DECODER_EXPORT void mdef_free(mdef_t *mdef)
S3DECODER_EXPORT s3pid_t mdef_phone_id_nearest(mdef_t *m, s3cipid_t b, s3cipid_t l, s3cipid_t r, word_posn_t pos)
S3DECODER_EXPORT int32 mdef_phone_str(mdef_t *m, s3pid_t pid, char *buf)
Triphone information, including base phones as a subset. For the latter, lc, rc and wpos are non-exis...
Definition: mdef.h:145
ph_rc_t * rclist
Definition: mdef.h:174
ciphone_t * ciphone
Definition: mdef.h:193
hash_table_t * ciphone_ht
Definition: mdef.h:192
CI phone information.
Definition: mdef.h:135
struct ph_rc_s ph_rc_t
void mdef_free_recursive_lc(ph_lc_t *lc)
S3DECODER_EXPORT mdef_t * mdef_init(const char *mdeffile, int32 breport)
int32 n_sen
Definition: mdef.h:189
int32 mdef_hmm_cmp(mdef_t *m, s3pid_t p1, s3pid_t p2)
Definition: mdef.h:122
Definition: mdef.h:172
s3cipid_t mdef_ciphone_id(mdef_t *m, const char *ciphone)
S3DECODER_EXPORT int32 mdef_phone_components(mdef_t *m, s3pid_t p, s3cipid_t *b, s3cipid_t *l, s3cipid_t *r, word_posn_t *pos)
int32 s3pid_t
Definition: s3types.h:118
struct ph_rc_s * next
Definition: mdef.h:164
Definition: mdef.h:121
int32 n_tmat
Definition: mdef.h:190
s3cipid_t lc
Definition: mdef.h:173
word_posn_t
Union of different type of word position.
Definition: mdef.h:120
int32 n_emit_state
Definition: mdef.h:187
int32 mdef_is_cisenone(mdef_t *m, s3senid_t s)
ph_lc_t *** wpos_ci_lclist
Definition: mdef.h:206
Structures needed for mapping &lt;ci,lc,rc,wpos&gt; into pid. (See mdef_t.wpos_ci_lclist below...
void mdef_free_recursive_rc(ph_rc_t *rc)
phone_t * phone
Definition: mdef.h:194