1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//! Phoneme type definitions, flag constants, and binary data loader.
//!
//! Rust port of `phoneme.h`, `phoneme.c`, and the phoneme-loading portions
//! of `synthdata.c`.
//!
//! # Binary data layout
//!
//! The `phontab` file contains a list of phoneme tables:
//! ```text
//! [u8 n_tables, u8 0, u8 0, u8 0]
//! For each table:
//! [u8 n_phonemes, u8 includes, u8 0, u8 0]
//! [u8 × 32] name (null-padded)
//! [PhonemeTab × n_phonemes] entries (16 bytes each, little-endian)
//! ```
//!
//! `phondata` starts with `[u32le version, u32le sample_rate, …]`.
//! `phonindex` is a flat array of `u16le` word-indices into `phondata`.
//! `intonations` is a flat array of `Tune` structs (68 bytes each).
pub use PhonemeFeature;
pub use PhonemeData;
pub use ;
// ---------------------------------------------------------------------------
// Phoneme type constants (PHONEME_TAB::type)
// ---------------------------------------------------------------------------
/// Phoneme type: pause / silence. C: `phPAUSE`.
pub const PH_PAUSE: u8 = 0;
/// Phoneme type: stress marker. C: `phSTRESS`.
pub const PH_STRESS: u8 = 1;
/// Phoneme type: vowel. C: `phVOWEL`.
pub const PH_VOWEL: u8 = 2;
/// Phoneme type: liquid (l, r). C: `phLIQUID`.
pub const PH_LIQUID: u8 = 3;
/// Phoneme type: voiceless stop (p, t, k). C: `phSTOP`.
pub const PH_STOP: u8 = 4;
/// Phoneme type: voiced stop (b, d, g). C: `phVSTOP`.
pub const PH_VSTOP: u8 = 5;
/// Phoneme type: voiceless fricative (f, s, ʃ). C: `phFRICATIVE`.
pub const PH_FRICATIVE: u8 = 6;
/// Phoneme type: voiced fricative (v, z, ʒ). C: `phVFRICATIVE`.
pub const PH_VFRICATIVE: u8 = 7;
/// Phoneme type: nasal (m, n, ŋ). C: `phNASAL`.
pub const PH_NASAL: u8 = 8;
/// Phoneme type: virtual / placeholder. C: `phVIRTUAL`.
pub const PH_VIRTUAL: u8 = 9;
/// Phoneme type: deleted (marked for removal). C: `phDELETED`.
pub const PH_DELETED: u8 = 14;
/// Phoneme type: invalid / sentinel. C: `phINVALID`.
pub const PH_INVALID: u8 = 15;
// ---------------------------------------------------------------------------
// Place of articulation (stored in bits 16-19 of phflags)
// ---------------------------------------------------------------------------
/// Place of articulation: bilabial (p, b, m).
pub const PLACE_BILABIAL: u32 = 1;
/// Place of articulation: labiodental (f, v).
pub const PLACE_LABIODENTAL: u32 = 2;
/// Place of articulation: dental (θ, ð).
pub const PLACE_DENTAL: u32 = 3;
/// Place of articulation: alveolar (t, d, s, z, n, l).
pub const PLACE_ALVEOLAR: u32 = 4;
/// Place of articulation: retroflex.
pub const PLACE_RETROFLEX: u32 = 5;
/// Place of articulation: palato-alveolar (ʃ, ʒ, tʃ, dʒ).
pub const PLACE_PALATO_ALVEOLAR: u32 = 6;
/// Place of articulation: palatal (j).
pub const PLACE_PALATAL: u32 = 7;
/// Place of articulation: velar (k, g, ŋ).
pub const PLACE_VELAR: u32 = 8;
/// Place of articulation: labio-velar (w).
pub const PLACE_LABIO_VELAR: u32 = 9;
/// Place of articulation: uvular (q, ʁ).
pub const PLACE_UVULAR: u32 = 10;
/// Place of articulation: pharyngeal.
pub const PLACE_PHARYNGEAL: u32 = 11;
/// Place of articulation: glottal (h, ʔ).
pub const PLACE_GLOTTAL: u32 = 12;
// ---------------------------------------------------------------------------
// Phoneme flag bits (PHONEME_TAB::phflags)
// ---------------------------------------------------------------------------
/// Mask for the articulation place field (bits 16-19).
pub const PHFLAG_ARTICULATION: u32 = 0x000f_0000;
/// Flag: phoneme has reduced / unstressed form.
pub const PH_UNSTRESSED: u32 = 1 << 1;
/// Flag: phoneme is voiceless.
pub const PH_VOICELESS: u32 = 1 << 3;
/// Flag: phoneme is voiced.
pub const PH_VOICED: u32 = 1 << 4;
/// Flag: phoneme is a sibilant fricative.
pub const PH_SIBILANT: u32 = 1 << 5;
/// Flag: no linking to the previous phoneme.
pub const PH_NOLINK: u32 = 1 << 6;
/// Flag: phoneme has a trill.
pub const PH_TRILL: u32 = 1 << 7;
/// Flag: phoneme is palatalised.
pub const PH_PALATAL: u32 = 1 << 9;
/// Flag: insert a break after this phoneme.
pub const PH_BRKAFTER: u32 = 1 << 14;
/// Flag: phoneme is non-syllabic (e.g. semivowel in diphthong).
pub const PH_NONSYLLABIC: u32 = 1 << 20;
/// Flag: phoneme is long.
pub const PH_LONG: u32 = 1 << 21;
/// Flag: lengthen preceding stop.
pub const PH_LENGTHENSTOP: u32 = 1 << 22;
/// Flag: phoneme is rhotic (r-coloured).
pub const PH_RHOTIC: u32 = 1 << 23;
/// Flag: do not add a pause before this phoneme.
pub const PH_NOPAUSE: u32 = 1 << 24;
/// Flag: phoneme has pre-voicing.
pub const PH_PREVOICE: u32 = 1 << 25;
/// Language-defined flag 1.
pub const PH_FLAG1: u32 = 1 << 28;
/// Language-defined flag 2.
pub const PH_FLAG2: u32 = 1 << 29;
/// Flag: local phoneme (language-switching context).
pub const PH_LOCAL: u32 = 1 << 31;
// ---------------------------------------------------------------------------
// Well-known fixed phoneme codes (indices into the active phoneme table)
// ---------------------------------------------------------------------------
/// Code 1: control marker.
pub const PHON_CONTROL: u8 = 1;
/// Code 2: unstressed (`%`).
pub const PHON_STRESS_U: u8 = 2;
/// Code 3: stress-down (`%%`).
pub const PHON_STRESS_D: u8 = 3;
/// Code 4: secondary stress `,`.
pub const PHON_STRESS_2: u8 = 4;
/// Code 5: tertiary stress.
pub const PHON_STRESS_3: u8 = 5;
/// Code 6: primary stress `ˈ`.
pub const PHON_STRESS_P: u8 = 6;
/// Code 7: primary stress (tonic syllable) `ˈˈ`.
pub const PHON_STRESS_P2: u8 = 7;
/// Code 8: revert to previous stress level.
pub const PHON_STRESS_PREV: u8 = 8;
/// Code 9: pause.
pub const PHON_PAUSE: u8 = 9;
/// Code 10: short pause.
pub const PHON_PAUSE_SHORT: u8 = 10;
/// Code 11: no-link pause.
pub const PHON_PAUSE_NOLINK: u8 = 11;
/// Code 12: lengthening mark `ː`.
pub const PHON_LENGTHEN: u8 = 12;
/// Code 13: schwa `ə`.
pub const PHON_SCHWA: u8 = 13;
/// Code 14: short schwa.
pub const PHON_SCHWA_SHORT: u8 = 14;
/// Code 15: end-of-word boundary `||`.
pub const PHON_END_WORD: u8 = 15;
/// Code 17: default tone marker.
pub const PHON_DEFAULTTONE: u8 = 17;
/// Code 18: capital letter marker.
pub const PHON_CAPITAL: u8 = 18;
/// Code 19: glottal stop `ʔ`.
pub const PHON_GLOTTALSTOP: u8 = 19;
/// Code 20: syllabic marker.
pub const PHON_SYLLABIC: u8 = 20;
/// Code 21: language-switch marker.
pub const PHON_SWITCH: u8 = 21;
/// Code 22: language-defined marker X1.
pub const PHON_X1: u8 = 22;
/// Code 23: very-short pause.
pub const PHON_PAUSE_VSHORT: u8 = 23;
/// Code 24: long pause.
pub const PHON_PAUSE_LONG: u8 = 24;
/// Code 25: reduced /t/ (American English flap).
pub const PHON_T_REDUCED: u8 = 25;
/// Code 26: tonic stress.
pub const PHON_STRESS_TONIC: u8 = 26;
/// Code 27: clause-boundary pause.
pub const PHON_PAUSE_CLAUSE: u8 = 27;
/// First code of the vowel-type range (codes 28-33).
pub const PHON_VOWELTYPES: u8 = 28;
// ---------------------------------------------------------------------------
// Table dimension limits
// ---------------------------------------------------------------------------
/// Maximum number of phoneme tables that can be loaded simultaneously.
pub const N_PHONEME_TABS: usize = 150;
/// Number of phoneme slots per table (one per possible code value 0-255).
pub const N_PHONEME_TAB: usize = 256;
/// Maximum number of bytes in a phoneme table name (null-padded).
pub const N_PHONEME_TAB_NAME: usize = 32;
/// Maximum number of phoneme substitution rules per voice.
pub const N_REPLACE_PHONEMES: usize = 60;
/// Version magic that must match bytes 0-3 of the `phondata` file.
pub const VERSION_PHDATA: u32 = 0x01_48_01;