1 /**
2  * @file   hmm.h
3  *
4  * <EN>
5  * @brief  Hidden Marcov Model for recognition.
6  *
7  * This file defines %HMM instance structure for recognition.
8  * When recognition, the required word %HMM or tree lexicon will be built
9  * using these structures referencing word dictionary and HTK %HMM Acoustic
10  * Model (defined in htk_hmm.h), and actual likelihood computation.
11  * </EN>
12  * <JA>
13  * @brief  ǧ���׻��Ѥ� Hidden Marcov Model
14  *
15  * ���Υե�����Ǥ�, ǧ���ˤ�����%HMM�ι�¤�Τ�������Ƥ��ޤ���
16  * ǧ�����ˤ�, ������Ӳ�����ǥ빽¤�� (htk_hmm.h) ����
17  * ɬ�פ�ñ��%HMM���ڹ�¤���������ι�¤�Τ��Ѥ��ƹ��ۤ���,
18  * �������ٷ׻��Ϥ��ξ�ǹԤ��ޤ���
19  * </JA>
20  *
21  * @author Akinobu LEE
22  * @date   Thu Feb 10 14:54:06 2005
23  *
24  * $Revision: 1.2 $
25  *
26  */
27 /*
28  * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University
29  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
30  * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology
31  * All rights reserved
32  */
33 
34 #ifndef __SENT_HMM_NEW2_H__
35 #define __SENT_HMM_NEW2_H__
36 
37 #include <sent/stddefs.h>
38 #include <sent/htk_hmm.h>
39 #include <sent/htk_param.h>
40 #include <sent/hmm_calc.h>
41 
42 /// Transition arc of %HMM state
43 typedef struct _a_cell {
44   LOGPROB		a;	///< Transition probability in log10
45   int			arc;	///< Transition destination in state ID
46   struct _a_cell	*next;  ///< Pointer to next transition on the same state
47 } A_CELL;
48 
49 /// %HMM State
50 typedef struct {
51   A_CELL		*ac;	///< List of transition arcs from this state
52   /**
53    * @brief Pointer to corresponding output state definition
54    *
55    * When a triphone model is used, if this state is located as a
56    * part of phoneme %HMM on @em word-edge, the corresponding
57    * @em pseudo-triphone, i.e. "*-e+g", "k-a+*", should be assigned.
58    * Otherwise, i.e. if this state is located at @em internal position
59    * of a word, pointer to the corresponding @em physical
60    * (actually defined) %HMM will be assigned.
61    * When a triphone model is used, phoneme %HMMs on @em word-edge should
62    * be @em pseudo-triphone, i.e. "*-e+g", "k-a+*".  In this case,  the
63    * belonging state should hold the output probability function
64    * in CD_State_Set.
65    * Otherwise, i.e. if this state is located at @em internal position
66    * of a word, pointer to the corresponding @em physical
67    * (actually defined) %HMM will be assigned.
68    */
69   union {
70     HTK_HMM_State *state;	///< Pointer to the mapped physical %HMM
71     CD_State_Set  *cdset;	///< Pointer to the pseudo %HMM
72   } out;
73   boolean is_pseudo_state;	///< TRUE if pseudo %HMM is assigned, FALSE if physical %HMM is assigned
74 } HMM_STATE;
75 
76 /**
77  * @brief %HMM state sequence
78  *
79  * @note This assumes that there is only one transition that goes outside
80  * this %HMM state sequence.
81  */
82 typedef struct {
83   int			len;	///< Length of state
84   HMM_STATE		*state;	///< Array of state
85   LOGPROB		accept_ac_a; ///< Transition probability outside this sequence (fixed to one) for normal mode
86 } HMM;
87 
88 
89 /**
90  * Token definition for viterbi segmentation.
91  *
92  */
93 typedef struct _seg_token {
94   int last_id;			///< ID of last unit
95   int last_end_frame;		///< Frame at which the last unit ends
96   LOGPROB last_end_score;	///< Score at which the last unit ends
97   struct _seg_token *next;	///< Pointer to previous token context, NULL if no context
98   struct _seg_token *list;	///< Link to next token, NULL if last
99 } SEGTOKEN;
100 
101 /* mkwhmm.c */
102 HMM *new_make_word_hmm(HTK_HMM_INFO *, HMM_Logical  **, int, boolean *);
103 HMM *new_make_word_hmm_with_lm(HTK_HMM_INFO *, HMM_Logical  **, int, boolean *, LOGPROB *);
104 void free_hmm(HMM *);
105 /* vsegment.c */
106 LOGPROB viterbi_segment(HMM *hmm, HTK_Param *param, HMMWork *wrk, boolean multipath, int *endstates, int ulen, int **id_ret, int **seg_ret, LOGPROB **uscore_ret, int *retlen);
107 
108 /* hmminfo/outprob.c */
109 LOGPROB outprob(HMMWork *wrk, int t, HMM_STATE *hmmstate, HTK_Param *param);
110 /* hmminfo/put_htkdata_info */
111 void put_hmm_arc(FILE *fp, HMM *d);
112 void put_hmm_outprob(FILE *fp, HMM *d);
113 void put_hmm(FILE *fp, HMM *d);
114 
115 #endif /* __SENT_HMM_NEW2_H__ */
116