• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  srec_arb.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 #ifndef __SREC_ARB_H__
21 #define __SREC_ARB_H__
22 
23 #include"sizes.h"
24 #include"hmm_desc.h"           /* 'cuz we're still using the old tree nodes */
25 #include"search_network.h"     /* for EPSILON_OFFSET */
26 
27 #define PSET_BIT_ARRAY_SIZE 7  /* max phonemes is 7*16 (128) */
28 typedef asr_uint16_t phonemeID;
29 #define MAXphonemeID 255
30 #define SILENCE_CODE '#'
31 #define OPTSILENCE_CODE '&'
32 #define SILENCE_CODE_STR "#"
33 #define OPTSILENCE_CODE_STR "&"
34 #define HMM_COUNTER_OFFSET EPSILON_OFFSET
35 #define NUM_SILENCE_HMMS 3
36 #define WBPHONEME_CODE '_'
37 #define USE_WWTRIPHONE 0
38 
39 #define QUESTION_LEFT  1
40 #define QUESTION_RIGHT 2
41 #define QUESTION_WBLEFT  3
42 #define QUESTION_WBRIGHT 4
43 #define ANSWER_FAIL    0
44 #define ANSWER_PASS    1
45 
46 /**
47  * @todo document
48  */
49 typedef struct
50 {
51   asr_uint16_t qtype;
52   asr_uint16_t membership_bits[PSET_BIT_ARRAY_SIZE];
53 }
54 srec_question;
55 #define BIT_ADDRESS(K,A,B) { A=(K)/16; B=1<<((K)%16); }
56 
57 #define MAX_PHONEME_NAME_LEN 8/BYTES_PER_ATOM
58 
59 /**
60  * @todo document
61  */
62 typedef struct
63 {
64   char   name[MAX_PHONEME_NAME_LEN];
65   asr_uint16_t code;
66   tree_node* model_nodes; /* pelid at the bottom, is really a HMM model ID */
67   asr_uint16_t num_states;
68   tree_node* state_nodes[MAX_PHONE_STATES];
69 }
70 phoneme_data;
71 
72 /**
73  * @todo document
74  */
75 typedef struct
76 {
77   char name[MAX_PHONEME_NAME_LEN]; /* 6400 bytes to free up here */
78   asr_int16_t num_states;
79   asr_int16_t* state_indices; /* only the first HMMInfo owns the pointer data */
80 }
81 HMMInfo;
82 
83 #define NUM_PHONEME_INDICES 256
84 /**
85  * @todo document
86  */
87 typedef struct
88 {
89   char* image;
90   asr_uint16_t image_size;
91   asr_int16_t num_phonemes;
92   phoneme_data* pdata;
93   asr_int16_t num_questions;
94   srec_question* questions;
95   asr_int16_t num_states; /* total number of states, all allophones, phonemes */
96   asr_int16_t num_hmms;
97   HMMInfo* hmm_infos;
98   phonemeID phoneme_index[NUM_PHONEME_INDICES]; /* from short code to phoneme index */
99   /* later add a data member called 'hmm_ilabel_offset', such that
100      for graphs prepared with OSR/SGC, the ilabels on that graph
101      must be offset by this number to get hmms */
102   // struct PCPinfo* pcpinfo;
103   void* pcpinfo;
104 }
105 srec_arbdata;
106 
107 /*---------------------------------------------------------------------------*
108  *                                                                           *
109  *                                                                           *
110  *                                                                           *
111  *---------------------------------------------------------------------------*/
112 
113 #if defined(__cplusplus) /*&& !defined(_ASCPP)*/
114 extern "C"
115 {
116 #endif
117 
118   int get_modelid_for_pic(srec_arbdata* allotree,
119                           phonemeID lphon, phonemeID cphon, phonemeID rphon);
120 
121   int get_modelids_for_pron(srec_arbdata* allotree, const char* phonemes,
122                             int num_phonemes, modelID* acoustic_model_ids);
123 
124   int read_arbdata_from_stream(srec_arbdata** pallotree, char* buffer, int buffer_size);
125   unsigned int version_arbdata_models(srec_arbdata* a);
126 
127 #if defined(__cplusplus) /*&& !defined(_ASCPP)*/
128 }
129 #endif
130 
131 #endif
132