• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  hmm_desc.h  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 
21 
22 #ifndef _h_hmm_desc_
23 #define _h_hmm_desc_
24 
25 #ifdef SET_RCSID
26 static const char hmm_desc_h[] = "$Id: hmm_desc.h,v 1.2.10.6 2008/01/21 20:30:05 dahan Exp $";
27 #endif
28 
29 #include "creccons.h"   /* CREC Public Constants    */
30 
31 #include "all_defs.h"
32 #include "hmm_type.h"
33 #include "sizes.h"
34 
35 
36 
37 #define PDTYP(X)        ((X) & 0x0f)
38 
39 #define DIAG            (1<<4) /* Diagonal covariance model */
40 #define FULL            (2<<4) /* Full covariance model */
41 #define VARTYP(X)       ((X) & 0x30)
42 
43 #define EXPDUR  (1<<6) /* Exponential duration model */
44 #define DURTYP(X) ((X) & 0xc0)
45 
46 /**
47  * @todo document
48  */
49 typedef struct
50 {
51   unsigned char phone; /*  Internal phoneme symbol */
52   unsigned char pr_code[4]; /*  Printable phone code */
53   unsigned char near_phone;
54   int  num_states;
55   unsigned char dict_code;    /*  single char printable code */
56 }
57 phoneme_info;
58 
59 /**
60  * @todo document
61  */
62 typedef struct
63 {
64   int  num_phones;
65   phoneme_info *phoneme;
66   int  index[256];
67 }
68 phoneme_set;
69 
70 /**
71  * The space_filler var here is to make sure that this structure is
72  * always the same size on different platforms.  ARM unix appears to
73  * want structures to by a multiple of 4 bytes, hence the filler.
74  */
75 typedef struct
76 {
77   unsigned char left_phone[MAX_PHONEMES];
78   unsigned char right_phone[MAX_PHONEMES];
79   short  apply;
80   short  space_filler; /* TODO: revisit this issue */
81 }
82 question;
83 
84 #define NON_GENERIC 0
85 #define RIGHT_GENERIC 1
86 #define LEFT_GENERIC 2 /*  Was the other way */
87 #define BOTH_GENERIC 3
88 #define DIPHONE  9
89 
90 /* the terminal_tree_node structure is used in a union with tree_branch_info
91    resulting in a "tree_node".  We must initialize "tree_node"s of both
92    both types in large static array, which is hard.  So instead we initialize
93    a static array of terminal_tree_node's but need to fill that structure up
94    with dummies to be the same size as the full "tree_node".  For 2-byte
95    pointer configurations this may not be memory efficient :( */
96 
97 /**
98  * @todo document
99  */
100 typedef struct terminal_tree_node_info
101 {
102   asr_int16_t    quest_index;
103   asr_int16_t   pelid;
104   asr_int16_t   avg_durn;
105   asr_int16_t          dummy_filler1, dummy_filler2, dummy_filler3;
106 }
107 terminal_tree_node;
108 
109 /**
110  * @todo document
111  */
112 typedef struct tree_branch_info
113 {
114   asr_int16_t  quest_index;
115   struct tree_branch_info  *fail;
116   struct tree_branch_info  *pass;
117 }
118 tree_branch_info;
119 
120 /**
121  * @todo document
122  */
123 typedef union {
124   struct tree_branch_info    node;
125   struct terminal_tree_node_info term;
126 } tree_node;
127 
128 /**
129  * @todo document
130  */
131 typedef struct
132 {
133   int       no_states;
134   /*    int       phoneme; */
135   tree_node *root[MAX_PHONE_STATES];
136 }
137 tree_info;
138 
139 /**
140  * holds the body of a sorted .ok dictionary file
141  */
142 typedef struct
143 {
144   char* ok_file_data; /* data in the .ok file */
145   int ok_file_data_length; /* length of data ok_file_data */
146   const char* first_entry; /* first entry in the dictionary */
147   const char* last_entry; /* last entry in the dictionary */
148   int hasUpper; /* nonzero if upper case present in dictionary (usually not) */
149 }
150 vocab_info;
151 
152 #endif
153