Debian Codegraph @

external/espeak/readclause.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2005 to 2015 by Jonathan Duddington
3 * email: [email protected]
4 * Copyright (C) 2015-2017 Reece H. Dunn
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see: <http://www.gnu.org/licenses/>.
18 */
19
20 #include "espeak__config.h"cxx . . $ `<file>/external/espeak/espeak__config.h`/
21
22 #include <ctype.h>
23 #include <errno.h>
24 #include <locale.h>
25 #include <math.h>
26 #include <stdint.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <wchar.h>
32 #include "wctype_portable.h"cxx . . $ `<file>/kar/wctype_portable.h`/
33
34 #include "espeak_ng.h"cxx . . $ `<file>/external/espeak/espeak_ng.h`/
35 #include "speak_lib.h"cxx . . $ `<file>/external/espeak/speak_lib.h`/
36 #include "encoding.h"cxx . . $ `<file>/external/espeak/encoding.h`/
37 #include "ucd.h"cxx . . $ `<file>/external/espeak/ucd.h`/
38
39 #include "readclause.h"cxx . . $ `<file>/external/espeak/readclause.h`/
40 #include "common.h"cxx . . $ `<file>/external/espeak/common.h`/ // for GetFileLength, strncpy0
41 #include "dictionary.h"cxx . . $ `<file>/external/espeak/dictionary.h`/ // for LookupDictList, DecodePhonemes, Set...
42 #include "error.h"cxx . . $ `<file>/external/espeak/error.h`/ // for create_file_error_context
43 #include "phoneme.h"cxx . . $ `<file>/external/espeak/phoneme.h`/ // for phonSWITCH
44 #include "soundicon.h"cxx . . $ `<file>/external/espeak/soundicon.h`/ // for LookupSoundIcon
45 #include "speech.h"cxx . . $ `<file>/external/espeak/speech.h`/ // for LookupMnem, PATHSEP
46 #include "ssml.h"cxx . . $ `<file>/external/espeak/ssml.h`/ // for SSML_STACK, ProcessSsmlTag, N_PARAM...
47 #include "synthdata.h"cxx . . $ `<file>/external/espeak/synthdata.h`/ // for SelectPhonemeTable
48 #include "translate.h"cxx . . $ `<file>/external/espeak/translate.h`/ // for Translator, utf8_out, CLAUSE_OPTION...
49 #include "voice.h"cxx . . $ `<file>/external/espeak/voice.h`/ // for voice, voice_t, espeak_GetCurrentVoice
50
51 #define N_XML_BUFcxx . . $ `external/espeak/readclause.cpp:51:9`! 500
52
53 static void DecodeWithPhonemeModecxx . . $ DecodeWithPhonemeMode(70b958c0326d8b45).(char *buf, char *phonemes, Translator *tr, Translator *tr2, unsigned int flags[]);
54 static void TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(char *buf, int index, int *ungetc);
55
56 static const char *xmlbasecxx . . $ xmlbase. = ""; // base URL from <speak>
57
58 static int namedata_ixcxx . . $ namedata_ix. = 0;
59 static int n_namedatacxx . . $ n_namedata. = 0;
60 char *namedatacxx . . $ namedata. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
61
62 static int ungot_char2cxx . . $ ungot_char2. = 0;
63 espeak_ng_TEXT_DECODER *p_decodercxx . . $ p_decoder. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
64 static int ungot_charcxx . . $ ungot_char.;
65
66 static bool ignore_textcxx . . $ ignore_text. = false; // set during <sub> ... </sub> to ignore text which has been replaced by an alias
67 static bool audio_textcxx . . $ audio_text. = false; // set during <audio> ... </audio>
68 static bool clear_skipping_textcxx . . $ clear_skipping_text. = false; // next clause should clear the skipping_text flag
69 int count_characterscxx . . $ count_characters. = 0;
70 static int sayas_modecxx . . $ sayas_mode.;
71 static int sayas_startcxx . . $ sayas_start.;
72
73 #define N_SSML_STACKcxx . . $ `external/espeak/readclause.cpp:73:9`! 20
74 static int n_ssml_stackcxx . . $ n_ssml_stack.;
75 static SSML_STACK ssml_stackcxx . . $ ssml_stack.[N_SSML_STACKcxx . . $ `external/espeak/readclause.cpp:73:9`!];
76
77 static espeak_VOICEcxx . . $ espeak_VOICE# base_voicecxx . . $ base_voice.;
78 static char base_voice_variant_namecxx . . $ base_voice_variant_name.[40] = { 0 };
79 static char current_voice_idcxx . . $ current_voice_id.[40] = { 0 };
80
81 static int n_param_stackcxx . . $ n_param_stack.;
82 PARAM_STACK param_stackcxx . . $ param_stack.[N_PARAM_STACKcxx . . $ `external/espeak/ssml.h:45:9`!];
83
84 static int speech_parameterscxx . . $ speech_parameters.[N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.]; // current values, from param_stack
85 int saved_parameterscxx . . $ saved_parameters.[N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.]; // Parameters saved on synthesis start
86
87 #define ESPEAKNG_CLAUSE_TYPE_PROPERTY_MASKcxx . . $ `external/espeak/readclause.cpp:87:9`! 0xFFF0000000000000ull
88
89 int clause_type_from_codepointcxx . . $ clause_type_from_codepoint(4c679297bf94b9eb).(uint32_tcxx . . $ uint32_t# c)
90 {
91 ucd_category cat = ucd_lookup_category(c);
92 ucd_property props = ucd_properties(c, cat);
93
94 switch (props & ESPEAKNG_CLAUSE_TYPE_PROPERTY_MASKcxx . . $ `external/espeak/readclause.cpp:87:9`!)
95 {
96 case ESPEAKNG_PROPERTY_FULL_STOPcxx . . $ `external/espeak/ucd.h:395:9`!:
97 return CLAUSE_PERIODcxx . . $ `external/espeak/translate.h:236:9`!;
98 case ESPEAKNG_PROPERTY_FULL_STOPcxx . . $ `external/espeak/ucd.h:395:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`!:
99 return CLAUSE_PERIODcxx . . $ `external/espeak/translate.h:236:9`! | CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!;
100 case ESPEAKNG_PROPERTY_QUESTION_MARKcxx . . $ `external/espeak/ucd.h:394:9`!:
101 return CLAUSE_QUESTIONcxx . . $ `external/espeak/translate.h:240:9`!;
102 case ESPEAKNG_PROPERTY_QUESTION_MARKcxx . . $ `external/espeak/ucd.h:394:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`!:
103 return CLAUSE_QUESTIONcxx . . $ `external/espeak/translate.h:240:9`! | CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!;
104 case ESPEAKNG_PROPERTY_QUESTION_MARKcxx . . $ `external/espeak/ucd.h:394:9`! | ESPEAKNG_PROPERTY_PUNCTUATION_IN_WORDcxx . . $ `external/espeak/ucd.h:385:9`!:
105 return CLAUSE_QUESTIONcxx . . $ `external/espeak/translate.h:240:9`! | CLAUSE_PUNCTUATION_IN_WORDcxx . . $ `external/espeak/translate.h:215:9`!;
106 case ESPEAKNG_PROPERTY_EXCLAMATION_MARKcxx . . $ `external/espeak/ucd.h:393:9`!:
107 return CLAUSE_EXCLAMATIONcxx . . $ `external/espeak/translate.h:241:9`!;
108 case ESPEAKNG_PROPERTY_EXCLAMATION_MARKcxx . . $ `external/espeak/ucd.h:393:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`!:
109 return CLAUSE_EXCLAMATIONcxx . . $ `external/espeak/translate.h:241:9`! | CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!;
110 case ESPEAKNG_PROPERTY_EXCLAMATION_MARKcxx . . $ `external/espeak/ucd.h:393:9`! | ESPEAKNG_PROPERTY_PUNCTUATION_IN_WORDcxx . . $ `external/espeak/ucd.h:385:9`!:
111 return CLAUSE_EXCLAMATIONcxx . . $ `external/espeak/translate.h:241:9`! | CLAUSE_PUNCTUATION_IN_WORDcxx . . $ `external/espeak/translate.h:215:9`!;
112 case ESPEAKNG_PROPERTY_COMMAcxx . . $ `external/espeak/ucd.h:392:9`!:
113 return CLAUSE_COMMAcxx . . $ `external/espeak/translate.h:237:9`!;
114 case ESPEAKNG_PROPERTY_COMMAcxx . . $ `external/espeak/ucd.h:392:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`!:
115 return CLAUSE_COMMAcxx . . $ `external/espeak/translate.h:237:9`! | CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!;
116 case ESPEAKNG_PROPERTY_COLONcxx . . $ `external/espeak/ucd.h:391:9`!:
117 return CLAUSE_COLONcxx . . $ `external/espeak/translate.h:242:9`!;
118 case ESPEAKNG_PROPERTY_COLONcxx . . $ `external/espeak/ucd.h:391:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`!:
119 return CLAUSE_COLONcxx . . $ `external/espeak/translate.h:242:9`! | CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!;
120 case ESPEAKNG_PROPERTY_SEMI_COLONcxx . . $ `external/espeak/ucd.h:390:9`!:
121 case ESPEAKNG_PROPERTY_EXTENDED_DASHcxx . . $ `external/espeak/ucd.h:387:9`!:
122 return CLAUSE_SEMICOLONcxx . . $ `external/espeak/translate.h:243:9`!;
123 case ESPEAKNG_PROPERTY_SEMI_COLONcxx . . $ `external/espeak/ucd.h:390:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`!:
124 case ESPEAKNG_PROPERTY_QUESTION_MARKcxx . . $ `external/espeak/ucd.h:394:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`! | ESPEAKNG_PROPERTY_INVERTED_TERMINAL_PUNCTUATIONcxx . . $ `external/espeak/ucd.h:384:9`!:
125 case ESPEAKNG_PROPERTY_EXCLAMATION_MARKcxx . . $ `external/espeak/ucd.h:393:9`! | ESPEAKNG_PROPERTY_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/ucd.h:386:9`! | ESPEAKNG_PROPERTY_INVERTED_TERMINAL_PUNCTUATIONcxx . . $ `external/espeak/ucd.h:384:9`!:
126 return CLAUSE_SEMICOLONcxx . . $ `external/espeak/translate.h:243:9`! | CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!;
127 case ESPEAKNG_PROPERTY_ELLIPSIScxx . . $ `external/espeak/ucd.h:389:9`!:
128 return CLAUSE_SEMICOLONcxx . . $ `external/espeak/translate.h:243:9`! | CLAUSE_SPEAK_PUNCTUATION_NAMEcxx . . $ `external/espeak/translate.h:216:9`! | CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!;
129 case ESPEAKNG_PROPERTY_PARAGRAPH_SEPARATORcxx . . $ `external/espeak/ucd.h:388:9`!:
130 return CLAUSE_PARAGRAPHcxx . . $ `external/espeak/translate.h:233:9`!;
131 }
132
133 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
134 }
135
136 static int IsRomanUcxx . . $ IsRomanU(4c679297bf94b9eb).(unsigned int c)
137 {
138 if ((c == 'I') || (c == 'V') || (c == 'X') || (c == 'L'))
139 return 1;
140 return 0;
141 }
142
143 int Eofcxx . . $ Eof(b126dc7c1de90089).(void)
144 {
145 if (ungot_charcxx . . $ ungot_char. != 0)
146 return 0;
147
148 return text_decoder_eof(p_decodercxx . . $ p_decoder.);
149 }
150
151 static int GetCcxx . . $ GetC(b126dc7c1de90089).(void)
152 {
153 int c1;
154
155 if ((c1 = ungot_charcxx . . $ ungot_char.) != 0) {
156 ungot_charcxx . . $ ungot_char. = 0;
157 return c1;
158 }
159
160 count_characterscxx . . $ count_characters.++;
161 return text_decoder_getc(p_decodercxx . . $ p_decoder.);
162 }
163
164 static void UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(int c)
165 {
166 ungot_charcxx . . $ ungot_char. = c;
167 }
168
169 const char *WordToString2cxx . . $ WordToString2(d172961b102a89a5).(char buf[5], unsigned int word)
170 {
171 // Convert a language mnemonic word into a string
172 int ix;
173 char *p;
174
175 p = buf;
176 for (ix = 3; ix >= 0; ix--) {
177 if ((*p = word >> (ix*8)) != 0)
178 p++;
179 }
180 *p = 0;
181 return buf;
182 }
183
184 static const char *LookupSpecialcxx . . $ LookupSpecial(ab4b3a5573410439).(Translator *tr, const char *string, char *text_out)
185 {
186 unsigned int flags[2];
187 char phonemes[55];
188 char *string1 = (char *)string;
189
190 flags[0] = flags[1] = 0;
191 if (LookupDictList(tr, &string1, phonemes, flags, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) {
192 DecodeWithPhonemeModecxx . . $ DecodeWithPhonemeMode(70b958c0326d8b45).(text_out, phonemes, tr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, flags);
193 return text_out;
194 }
195 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
196 }
197
198 static const char *LookupCharNamecxx . . $ LookupCharName(676f645eacedaddc).(char buf[60], Translator *tr, int c, bool only)
199 {
200 // Find the phoneme string (in ascii) to speak the name of character c
201 // Used for punctuation characters and symbols
202
203 int ix;
204 unsigned int flags[2];
205 char single_letter[24];
206 char phonemes[60];
207 const char *lang_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
208 char *string;
209
210 buf[0] = 0;
211 flags[0] = 0;
212 flags[1] = 0;
213 single_letter[0] = 0;
214 single_letter[1] = '_';
215 ix = utf8_outcxx . . $ utf8_out(fa84e865f2d62ca9).(c, &single_letter[2]);
216 single_letter[2+ix] = 0;
217
218 if (only == true) {
219 string = &single_letter[2];
220 LookupDictList(tr, &string, phonemes, flags, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
221 }
222
223 if (only == false) {
224 string = &single_letter[1];
225 if (LookupDictList(tr, &string, phonemes, flags, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) == 0) {
226 // try _* then *
227 string = &single_letter[2];
228 if (LookupDictList(tr, &string, phonemes, flags, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) == 0) {
229 // now try the rules
230 single_letter[1] = ' ';
231 TranslateRules(tr, &single_letter[2], phonemes, sizeof(phonemes), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
232 }
233 }
234
235 if (((phonemes[0] == 0) || (phonemes[0] == phonSWITCHcxx . . $ `external/espeak/phoneme.h:218:9`!)) && (tr->translator_name != Lcxx . . $ `external/espeak/translate.h:33:9`!('e', 'n'))) {
236 // not found, try English
237 SetTranslator2(ESPEAKNG_DEFAULT_VOICEcxx . . $ `external/espeak/espeak_ng.h:39:9`!);
238 string = &single_letter[1];
239 single_letter[1] = '_';
240 if (LookupDictList(translator2, &string, phonemes, flags, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) == 0) {
241 string = &single_letter[2];
242 LookupDictList(translator2, &string, phonemes, flags, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
243 }
244 if (phonemes[0])
245 lang_name = ESPEAKNG_DEFAULT_VOICEcxx . . $ `external/espeak/espeak_ng.h:39:9`!;
246 else
247 SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
248 }
249 }
250
251 if (phonemes[0]) {
252 if (lang_name) {
253 DecodeWithPhonemeModecxx . . $ DecodeWithPhonemeMode(70b958c0326d8b45).(buf, phonemes, tr, translator2, flags);
254 SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
255 } else {
256 DecodeWithPhonemeModecxx . . $ DecodeWithPhonemeMode(70b958c0326d8b45).(buf, phonemes, tr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, flags);
257 }
258 } else if (only == false)
259 strcpy(buf, "[\002(X1)(X1)(X1)]]");
260
261 return buf;
262 }
263
264 static int AnnouncePunctuationcxx . . $ AnnouncePunctuation(cde2bc4d32c552c1).(Translator *tr, int c1, int *c2_ptr, char *output, int *bufix, int end_clause)
265 {
266 // announce punctuation names
267 // c1: the punctuation character
268 // c2: the following character
269
270
271 const char *punctname = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
272 int soundicon;
273 int attributes;
274 int short_pause;
275 int c2;
276 int len;
277 int bufix1;
278 char buf[200];
279 char ph_buf[30];
280 char cn_buf[60];
281
282 c2 = *c2_ptr;
283 buf[0] = 0;
284
285 if ((soundicon = LookupSoundicon(c1)) >= 0) {
286 // add an embedded command to play the soundicon
287 sprintf(buf, "\001%dI ", soundicon);
288 UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(c2);
289 } else {
290 if ((c1 == '.') && (end_clause) && (c2 != '.')) {
291 if (LookupSpecialcxx . . $ LookupSpecial(ab4b3a5573410439).(tr, "_.p", ph_buf))
292 punctname = ph_buf; // use word for 'period' instead of 'dot'
293 }
294 if (punctname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
295 punctname = LookupCharNamecxx . . $ LookupCharName(676f645eacedaddc).(cn_buf, tr, c1, false);
296
297 if (punctname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
298 return -1;
299
300
301 if ((*bufix == 0) || (end_clause == 0) || (tr->langopts.param[LOPT_ANNOUNCE_PUNCTcxx . . $ `external/espeak/translate.h:338:9`!] & 2)) {
302 int punct_count = 1;
303 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && (c2 == c1) && (c1 != '<')) { // don't eat extra '<', it can miss XML tags
304 punct_count++;
305 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
306 }
307 *c2_ptr = c2;
308 if (end_clause)
309 UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(c2);
310
311 if (punct_count == 1)
312 sprintf(buf, " %s", punctname); // we need the space before punctname, to ensure it doesn't merge with the previous word (eg. "2.-a")
313 else if (punct_count < 4) {
314 buf[0] = 0;
315 if (embedded_value[EMBED_Scxx . . $ `external/espeak/synthesize.h:64:9`!] < 300)
316 sprintf(buf, "\001+10S"); // Speak punctuation name faster, unless we are already speaking fast. It would upset Sonic SpeedUp
317
318 char buf2[80];
319 while (punct_count-- > 0) {
320 sprintf(buf2, " %s", punctname);
321 strcat(buf, buf2);
322 }
323
324 if (embedded_value[EMBED_Scxx . . $ `external/espeak/synthesize.h:64:9`!] < 300) {
325 sprintf(buf2, " \001-10S");
326 strcat(buf, buf2);
327 }
328 } else
329 sprintf(buf, " %s %d %s",
330 punctname, punct_count, punctname);
331 } else {
332 // end the clause now and pick up the punctuation next time
333 ungot_char2cxx . . $ ungot_char2. = c1;
334 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, 0, &c2);
335 }
336 }
337
338 bufix1 = *bufix;
339 len = strlen(buf);
340 strcpy(&output[*bufix], buf);
341 *bufix += len;
342
343 if (end_clause == 0)
344 return -1;
345
346 if (c1 == '-')
347 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!; // no pause
348
349 attributes = clause_type_from_codepointcxx . . $ clause_type_from_codepoint(4c679297bf94b9eb).(c1);
350
351 short_pause = CLAUSE_SHORTFALLcxx . . $ `external/espeak/translate.h:239:9`!;
352 if ((attributes & CLAUSE_INTONATION_TYPEcxx . . $ `external/espeak/translate.h:212:9`!) == 0x1000)
353 short_pause = CLAUSE_SHORTCOMMAcxx . . $ `external/espeak/translate.h:238:9`!;
354
355 if ((bufix1 > 0) && !(tr->langopts.param[LOPT_ANNOUNCE_PUNCTcxx . . $ `external/espeak/translate.h:338:9`!] & 2)) {
356 if ((attributes & ~CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!) == CLAUSE_SEMICOLONcxx . . $ `external/espeak/translate.h:243:9`!)
357 return CLAUSE_SHORTFALLcxx . . $ `external/espeak/translate.h:239:9`!;
358 return short_pause;
359 }
360
361 if (attributes & CLAUSE_TYPE_SENTENCEcxx . . $ `external/espeak/translate.h:230:9`!)
362 return attributes;
363
364 return short_pause;
365 }
366
367 int AddNameDatacxx . . $ AddNameData(cb7559238bb26814).(const char *name, int wide)
368 {
369 // Add the name to the namedata and return its position
370 // (Used by the Windows SAPI wrapper)
371
372 int ix;
373 int len;
374
375 if (wide) {
376 len = (wcslen((const wchar_t *)name)+1)*sizeof(wchar_t);
377 n_namedatacxx . . $ n_namedata. = (n_namedatacxx . . $ n_namedata. + sizeof(wchar_t) - 1) % sizeof(wchar_t); // round to wchar_t boundary
378 } else
379 len = strlen(name)+1;
380
381 if (namedata_ixcxx . . $ namedata_ix.+len >= n_namedatacxx . . $ n_namedata.) {
382 // allocate more space for marker names
383 void *vp;
384 if ((vp = realloccxx . . $ realloc(42b2a9dd8f084bf2).(namedatacxx . . $ namedata., namedata_ixcxx . . $ namedata_ix.+len + 1000)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
385 return -1; // failed to allocate, original data is unchanged but ignore this new name
386 // !!! Bug?? If the allocated data shifts position, then pointers given to user application will be invalid
387
388 namedatacxx . . $ namedata. = (char *)vp;
389 n_namedatacxx . . $ n_namedata. = namedata_ixcxx . . $ namedata_ix.+len + 1000;
390 }
391 memcpy(&namedatacxx . . $ namedata.[ix = namedata_ixcxx . . $ namedata_ix.], name, len);
392 namedata_ixcxx . . $ namedata_ix. += len;
393 return ix;
394 }
395
396 void SetVoiceStackcxx . . $ SetVoiceStack(5a646af9feb703a9).(espeak_VOICEcxx . . $ espeak_VOICE# *v, const char *variant_name)
397 {
398 SSML_STACK *sp;
399 sp = &ssml_stackcxx . . $ ssml_stack.[0];
400
401 if (v == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
402 memset(sp, 0, sizeof(ssml_stackcxx . . $ ssml_stack.[0]));
403 return;
404 }
405 if (v->languagescxx . . $ $anonymous_type_6337c0e5abb454c9_8#languages. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
406 strcpy(sp->language, v->languagescxx . . $ $anonymous_type_6337c0e5abb454c9_8#languages.);
407 if (v->namecxx . . $ $anonymous_type_6337c0e5abb454c9_8#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
408 strncpy0cxx . . $ strncpy0(3366d352079c3ed6).(sp->voice_name, v->namecxx . . $ $anonymous_type_6337c0e5abb454c9_8#name., sizeof(sp->voice_name));
409 sp->voice_variant_number = v->variantcxx . . $ $anonymous_type_6337c0e5abb454c9_8#variant.;
410 sp->voice_age = v->agecxx . . $ $anonymous_type_6337c0e5abb454c9_8#age.;
411 sp->voice_gender = v->gendercxx . . $ $anonymous_type_6337c0e5abb454c9_8#gender.;
412
413 if (variant_name[0] == '!' && variant_name[1] == 'v' && variant_name[2] == PATHSEPcxx . . $ `external/espeak/speech.h:71:9`!)
414 variant_name += 3; // strip variant directory name, !v plus PATHSEP
415 strncpy0cxx . . $ strncpy0(3366d352079c3ed6).(base_voice_variant_namecxx . . $ base_voice_variant_name., variant_name, sizeof(base_voice_variant_namecxx . . $ base_voice_variant_name.));
416 memcpy(&base_voicecxx . . $ base_voice., espeak_GetCurrentVoice(), sizeof(base_voicecxx . . $ base_voice.));
417 }
418
419 static void RemoveCharcxx . . $ RemoveChar(fda57c8427c60377).(char *p)
420 {
421 // Replace a UTF-8 character by spaces
422 int c;
423
424 memset(p, ' ', utf8_incxx . . $ utf8_in(80e674cbced5dd06).(&c, p));
425 }
426
427 static int lookupwchar2cxx . . $ lookupwchar2(f6891b3809dfa817).(const unsigned short *list, int c)
428 {
429 // Replace character c by another character.
430 // Returns 0 = not found, 1 = delete character
431
432 int ix;
433
434 for (ix = 0; list[ix] != 0; ix += 2) {
435 if (list[ix] == c)
436 return list[ix+1];
437 }
438 return 0;
439 }
440
441 static bool IgnoreOrReplaceCharcxx . . $ IgnoreOrReplaceChar(8e44e910ce0dd5c8).(Translator *tr, int *c1) {
442 int i;
443 if ((i = lookupwchar2cxx . . $ lookupwchar2(f6891b3809dfa817).(tr->chars_ignore, *c1)) != 0) {
444 if (i == 1) {
445 // ignore this character
446 return true;
447 }
448 *c1 = i; // replace current character with the result
449 }
450 return false;
451 }
452
453 static int CheckPhonemeModecxx . . $ CheckPhonemeMode(d4c1ccc1fe1a56c0).(int optionPhonemeInput, int phoneme_mode, int c1, int c2) {
454 if (optionPhonemeInput) {
455 if (phoneme_mode > 0)
456 phoneme_mode--;
457 else if ((c1 == '[') && (c2 == '['))
458 phoneme_mode = -1; // input is phoneme mnemonics, so don't look for punctuation
459 else if ((c1 == ']') && (c2 == ']'))
460 phoneme_mode = 2; // set phoneme_mode to zero after the next two characters
461
462 }
463 return phoneme_mode;
464 }
465
466 int ReadClausecxx . . $ ReadClause(b946059ff498144f).(Translator *tr, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change)
467 {
468 /* Find the end of the current clause.
469 Write the clause into buf
470
471 returns: clause type (bits 0-7: pause x10mS, bits 8-11 intonation type)
472
473 Also checks for blank line (paragraph) as end-of-clause indicator.
474
475 Does not end clause for:
476 punctuation immediately followed by alphanumeric eg. 1.23 !Speak :path
477 repeated punctuation, eg. ... !!!
478 */
479
480 int c1 = ' '; // current character
481 int c2; // next character
482 int cprev = ' '; // previous character
483 int c_next = 0;
484 int parag;
485 int ix = 0;
486 int j;
487 int nl_count;
488 int linelength = 0;
489 int phoneme_mode = 0;
490 int n_xml_buf;
491 int terminator;
492 bool any_alnum = false;
493 int punct_data = 0;
494 bool is_end_clause;
495 int announced_punctuation = 0;
496 bool stressed_word = false;
497 int end_clause_after_tag = 0;
498 int end_clause_index = 0;
499 wchar_t xml_buf[N_XML_BUFcxx . . $ `external/espeak/readclause.cpp:51:9`!+1];
500
501 #define N_XML_BUF2cxx . . $ `external/espeak/readclause.cpp:501:10`! 20
502 char xml_buf2[N_XML_BUF2cxx . . $ `external/espeak/readclause.cpp:501:10`!+2]; // for &<name> and &<number> sequences
503 static char ungot_string[N_XML_BUF2cxx . . $ `external/espeak/readclause.cpp:501:10`!+4];
504 static int ungot_string_ix = -1;
505
506 if (clear_skipping_textcxx . . $ clear_skipping_text.) {
507 skipping_text = false;
508 clear_skipping_textcxx . . $ clear_skipping_text. = false;
509 }
510
511 tr->phonemes_repeat_count = 0;
512 tr->clause_upper_count = 0;
513 tr->clause_lower_count = 0;
514 *tone_type = 0;
515 *voice_change = 0;
516
517 if (ungot_char2cxx . . $ ungot_char2. != 0) {
518 c2 = ungot_char2cxx . . $ ungot_char2.;
519 } else if (Eofcxx . . $ Eof(b126dc7c1de90089).()) {
520 c2 = 0;
521 } else {
522 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
523 }
524
525 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() || (ungot_charcxx . . $ ungot_char. != 0) || (ungot_char2cxx . . $ ungot_char2. != 0) || (ungot_string_ix >= 0)) {
526 if (!iswalnum_portable(c1)) {
527 if ((end_character_position > 0) && (count_characterscxx . . $ count_characters. > end_character_position)) {
528 return CLAUSE_EOFcxx . . $ `external/espeak/translate.h:234:9`!;
529 }
530
531 if ((skip_characters > 0) && (count_characterscxx . . $ count_characters. >= skip_characters)) {
532 // reached the specified start position
533 // don't break a word
534 clear_skipping_textcxx . . $ clear_skipping_text. = true;
535 skip_characters = 0;
536 UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(c2);
537 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
538 }
539 }
540 int cprev2 = cprev;
541 cprev = c1;
542 c1 = c2;
543
544 if (ungot_string_ix >= 0) {
545 if (ungot_string[ungot_string_ix] == 0) {
546 MAKE_MEM_UNDEFINEDcxx . . $ `external/espeak/speech.h:39:13`!(&ungot_string, sizeof(ungot_string));
547 ungot_string_ix = -1;
548 }
549 }
550
551 if ((ungot_string_ix == 0) && (ungot_char2cxx . . $ ungot_char2. == 0))
552 c1 = ungot_string[ungot_string_ix++];
553 if (ungot_string_ix >= 0) {
554 c2 = ungot_string[ungot_string_ix++];
555 } else if (Eofcxx . . $ Eof(b126dc7c1de90089).()) {
556 c2 = ' ';
557 } else {
558 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
559 }
560
561 ungot_char2cxx . . $ ungot_char2. = 0;
562
563 if ((option_ssml) && (phoneme_mode == 0)) {
564 if ((c1 == '&') && ((c2 == '#') || ((c2 >= 'a') && (c2 <= 'z')))) {
565 n_xml_buf = 0;
566 c1 = c2;
567 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && (iswalnum_portable(c1) || (c1 == '#')) && (n_xml_buf < N_XML_BUF2cxx . . $ `external/espeak/readclause.cpp:501:10`!)) {
568 xml_buf2[n_xml_buf++] = c1;
569 c1 = GetCcxx . . $ GetC(b126dc7c1de90089).();
570 }
571 xml_buf2[n_xml_buf] = 0;
572 if (Eofcxx . . $ Eof(b126dc7c1de90089).()) {
573 c2 = '\0';
574 } else {
575 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
576 }
577 sprintf(ungot_string, "%s%c%c", &xml_buf2[0], c1, c2);
578
579 int found = -1;
580 if (c1 == ';') {
581 found = ParseSsmlReference(xml_buf2, &c1, &c2);
582 }
583
584 if (found <= 0) {
585 ungot_string_ix = 0;
586 c1 = '&';
587 c2 = ' ';
588 }
589
590 if ((c1 <= 0x20) && ((sayas_modecxx . . $ sayas_mode. == SAYAS_SINGLE_CHARScxx . . $ `external/espeak/translate.h:249:9`!) || (sayas_modecxx . . $ sayas_mode. == SAYAS_KEYcxx . . $ `external/espeak/translate.h:250:9`!)))
591 c1 += 0xe000; // move into unicode private usage area
592 } else if (c1 == '<') {
593 if ((c2 == '/') || iswalpha_portable(c2) || c2 == '!' || c2 == '?') {
594 // check for space in the output buffer for embedded commands produced by the SSML tag
595 if (ix > (n_buf - 20)) {
596 // Perhaps not enough room, end the clause before the SSML tag
597 ungot_char2cxx . . $ ungot_char2. = c1;
598 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, &c2);
599 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
600 }
601
602 // SSML Tag
603 n_xml_buf = 0;
604 c1 = c2;
605 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && (c1 != '>') && (n_xml_buf < N_XML_BUFcxx . . $ `external/espeak/readclause.cpp:51:9`!)) {
606 xml_buf[n_xml_buf++] = c1;
607 c1 = GetCcxx . . $ GetC(b126dc7c1de90089).();
608 }
609 xml_buf[n_xml_buf] = 0;
610 c2 = ' ';
611
612 terminator = ProcessSsmlTag(xml_buf, buf, &ix, n_buf, xmlbasecxx . . $ xmlbase., &audio_textcxx . . $ audio_text., current_voice_idcxx . . $ current_voice_id., &base_voicecxx . . $ base_voice., base_voice_variant_namecxx . . $ base_voice_variant_name., &ignore_textcxx . . $ ignore_text., &clear_skipping_textcxx . . $ clear_skipping_text., &sayas_modecxx . . $ sayas_mode., &sayas_startcxx . . $ sayas_start., ssml_stackcxx . . $ ssml_stack., &n_ssml_stackcxx . . $ n_ssml_stack., &n_param_stackcxx . . $ n_param_stack., (int *)speech_parameterscxx . . $ speech_parameters.);
613
614 if (terminator != 0) {
615 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
616
617 if (terminator & CLAUSE_TYPE_VOICE_CHANGEcxx . . $ `external/espeak/translate.h:228:9`!)
618 strcpy(voice_change, current_voice_idcxx . . $ current_voice_id.);
619 return terminator;
620 }
621 c1 = ' ';
622 if (!Eofcxx . . $ Eof(b126dc7c1de90089).()) {
623 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
624 }
625 continue;
626 }
627 }
628 }
629
630 if (ignore_textcxx . . $ ignore_text.)
631 continue;
632
633 if ((c2 == '\n') && (option_linelength == -1)) {
634 // single-line mode, return immediately on NL
635 if ((terminator = clause_type_from_codepointcxx . . $ clause_type_from_codepoint(4c679297bf94b9eb).(c1)) == CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!) {
636 charix[ix] = count_characterscxx . . $ count_characters. - clause_start_char;
637 *charix_top = ix;
638 ix += utf8_outcxx . . $ utf8_out(fa84e865f2d62ca9).(c1, &buf[ix]);
639 terminator = CLAUSE_PERIODcxx . . $ `external/espeak/translate.h:236:9`!; // line doesn't end in punctuation, assume period
640 }
641 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
642 return terminator;
643 }
644
645 if (c1 == CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!) {
646 // an embedded command. If it's a voice change, end the clause
647 if (c2 == 'V') {
648 buf[ix++] = 0; // end the clause at this point
649 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && !iswspace_portable(c1 = GetCcxx . . $ GetC(b126dc7c1de90089).()) && (ix < (n_buf-1)))
650 buf[ix++] = c1; // add voice name to end of buffer, after the text
651 buf[ix++] = 0;
652 return CLAUSE_VOICEcxx . . $ `external/espeak/translate.h:235:9`!;
653 } else if (c2 == 'B') {
654 // set the punctuation option from an embedded command
655 // B0 B1 B<punct list><space>
656 strcpy(&buf[ix], " ");
657 ix += 3;
658
659 if (!Eofcxx . . $ Eof(b126dc7c1de90089).() && (c2 = GetCcxx . . $ GetC(b126dc7c1de90089).()) == '0')
660 option_punctuation = 0;
661 else {
662 option_punctuation = 1;
663 option_punctlist[0] = 0;
664 if (c2 != '1') {
665 // a list of punctuation characters to be spoken, terminated by space
666 j = 0;
667 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && !iswspace_portable(c2) && (j < N_PUNCTLISTcxx . . $ `external/espeak/translate.h:642:9`!-1)) {
668 option_punctlist[j++] = c2;
669 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
670 buf[ix++] = ' ';
671 }
672 option_punctlist[j] = 0; // terminate punctuation list
673 option_punctuation = 2;
674 }
675 }
676 if (!Eofcxx . . $ Eof(b126dc7c1de90089).())
677 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
678 continue;
679 }
680 }
681
682 linelength++;
683
684 if (IgnoreOrReplaceCharcxx . . $ IgnoreOrReplaceChar(8e44e910ce0dd5c8).(tr, &c1) == true)
685 continue;
686
687
688 if (iswalnum_portable(c1))
689 any_alnum = true;
690 else {
691 if (stressed_word) {
692 stressed_word = false;
693 c1 = CHAR_EMPHASIScxx . . $ `external/espeak/translate.h:254:9`!; // indicate this word is stressed
694 UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(c2);
695 c2 = ' ';
696 }
697
698 if (c1 == 0xf0b)
699 c1 = ' '; // Tibet inter-syllabic mark, ?? replace by space ??
700
701 if (c1 == 0xd4d) {
702 // Malayalam virama, check if next character is Zero-width-joiner
703 if (c2 == 0x200d)
704 c1 = 0xd4e; // use this unofficial code for chillu-virama
705 }
706 }
707
708 if (iswupper_portable(c1)) {
709 tr->clause_upper_count++;
710
711 if ((option_capitals == 2) && (sayas_modecxx . . $ sayas_mode. == 0) && !iswupper_portable(cprev)) {
712 char text_buf[30];
713 if (LookupSpecialcxx . . $ LookupSpecial(ab4b3a5573410439).(tr, "_cap", text_buf) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
714 j = strlen(text_buf);
715 if ((ix + j) < n_buf) {
716 strcpy(&buf[ix], text_buf);
717 ix += j;
718 }
719 }
720 }
721 } else if (iswalpha_portable(c1))
722 tr->clause_lower_count++;
723
724 phoneme_mode = CheckPhonemeModecxx . . $ CheckPhonemeMode(d4c1ccc1fe1a56c0).(option_phoneme_input, phoneme_mode, c1, c2);
725
726 if (c1 == '\n') {
727 parag = 0;
728
729 // count consecutive newlines, ignoring other spaces
730 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && iswspace_portable(c2)) {
731 if (c2 == '\n')
732 parag++;
733 c2 = GetCcxx . . $ GetC(b126dc7c1de90089).();
734 }
735 if (parag > 0) {
736 // 2nd newline, assume paragraph
737 if (end_clause_after_tag)
738 RemoveCharcxx . . $ RemoveChar(fda57c8427c60377).(&buf[end_clause_index]); // delete clause-end punctiation
739 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, &c2);
740 if (parag > 3)
741 parag = 3;
742 if (option_ssml) parag = 1;
743 return (CLAUSE_PARAGRAPHcxx . . $ `external/espeak/translate.h:233:9`!-30) + 30*parag; // several blank lines, longer pause
744 }
745
746 if (linelength <= option_linelength) {
747 // treat lines shorter than a specified length as end-of-clause
748 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, &c2);
749 return CLAUSE_COLONcxx . . $ `external/espeak/translate.h:242:9`!;
750 }
751
752 linelength = 0;
753 }
754
755 announced_punctuation = 0;
756
757 if ((phoneme_mode == 0) && (sayas_modecxx . . $ sayas_mode. == 0)) {
758 is_end_clause = false;
759
760 if (end_clause_after_tag) {
761 // Because of an xml tag, we are waiting for the
762 // next non-blank character to decide whether to end the clause
763 // i.e. is dot followed by an upper-case letter?
764
765 if (!iswspace_portable(c1)) {
766 if (!IsAlphacxx . . $ IsAlpha(4c679297bf94b9eb).(c1) || !iswlower_portable(c1)) {
767 ungot_char2cxx . . $ ungot_char2. = c1;
768 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, end_clause_index, &c2);
769 return end_clause_after_tag;
770 }
771 end_clause_after_tag = 0;
772 }
773 }
774
775 if ((c1 == '.') && (c2 == '.')) {
776 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && (c_next = GetCcxx . . $ GetC(b126dc7c1de90089).()) == '.') {
777 // 3 or more dots, replace by elipsis
778 c1 = 0x2026;
779 c2 = ' ';
780 }
781 if (c1 == 0x2026)
782 c2 = c_next;
783 else
784 UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(c_next);
785 }
786
787 punct_data = 0;
788 if ((punct_data = clause_type_from_codepointcxx . . $ clause_type_from_codepoint(4c679297bf94b9eb).(c1)) != CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!) {
789
790 // Handling of sequences of ? and ! like ??!?, !!??!, ?!! etc
791 // Use only first char as determinant
792 if(punct_data & (CLAUSE_QUESTIONcxx . . $ `external/espeak/translate.h:240:9`! | CLAUSE_EXCLAMATIONcxx . . $ `external/espeak/translate.h:241:9`!)) {
793 while(!Eofcxx . . $ Eof(b126dc7c1de90089).() && clause_type_from_codepointcxx . . $ clause_type_from_codepoint(4c679297bf94b9eb).(c2) & (CLAUSE_QUESTIONcxx . . $ `external/espeak/translate.h:240:9`! | CLAUSE_EXCLAMATIONcxx . . $ `external/espeak/translate.h:241:9`!)) {
794 c_next = GetCcxx . . $ GetC(b126dc7c1de90089).();
795 c2 = c_next;
796 }
797 }
798
799 if (punct_data & CLAUSE_PUNCTUATION_IN_WORDcxx . . $ `external/espeak/translate.h:215:9`!) {
800 // Armenian punctuation inside a word
801 stressed_word = true;
802 *tone_type = punct_data >> 12 & 0xf; // override the end-of-sentence type
803 continue;
804 }
805
806 if (iswspace_portable(c2) || (punct_data & CLAUSE_OPTIONAL_SPACE_AFTERcxx . . $ `external/espeak/translate.h:213:9`!) || IsBracketcxx . . $ IsBracket(7864480464b09eea).(c2) || (c2 == '?') || Eofcxx . . $ Eof(b126dc7c1de90089).() || c2 == CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!) { // don't check for '-' because it prevents recognizing ':-)'
807 // note: (c2='?') is for when a smart-quote has been replaced by '?'
808 is_end_clause = true;
809 }
810 }
811
812 // don't announce punctuation for the alternative text inside inside <audio> ... </audio>
813 if (c1 == 0xe000+'<') c1 = '<';
814 if (option_punctuation && iswpunct_portable(c1) && (audio_textcxx . . $ audio_text. == false)) {
815 // option is set to explicitly speak punctuation characters
816 // if a list of allowed punctuation has been set up, check whether the character is in it
817 if ((option_punctuation == 1) || (wcschr(option_punctlist, c1) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) {
818 tr->phonemes_repeat_count = 0;
819 if ((terminator = AnnouncePunctuationcxx . . $ AnnouncePunctuation(cde2bc4d32c552c1).(tr, c1, &c2, buf, &ix, is_end_clause)) >= 0)
820 return terminator;
821 announced_punctuation = c1;
822 }
823 }
824
825 if ((punct_data & CLAUSE_SPEAK_PUNCTUATION_NAMEcxx . . $ `external/espeak/translate.h:216:9`!) && (announced_punctuation == 0)) {
826 // used for elipsis (and 3 dots) if a pronunciation for elipsis is given in *_list
827 char *p2;
828
829 p2 = &buf[ix];
830 char cn_buf[60];
831 sprintf(p2, "%s", LookupCharNamecxx . . $ LookupCharName(676f645eacedaddc).(cn_buf, tr, c1, true));
832 if (p2[0] != 0) {
833 ix += strlen(p2);
834 announced_punctuation = c1;
835 punct_data = punct_data & ~CLAUSE_INTONATION_TYPEcxx . . $ `external/espeak/translate.h:212:9`!; // change intonation type to 0 (full-stop)
836 }
837 }
838
839 if (is_end_clause) {
840 nl_count = 0;
841 c_next = c2;
842
843 if (iswspace_portable(c_next)) {
844 while (!Eofcxx . . $ Eof(b126dc7c1de90089).() && iswspace_portable(c_next)) {
845 if (c_next == '\n')
846 nl_count++;
847 c_next = GetCcxx . . $ GetC(b126dc7c1de90089).(); // skip past space(s)
848 }
849 }
850
851 if ((c1 == '.') && (nl_count < 2))
852 punct_data |= CLAUSE_DOT_AFTER_LAST_WORDcxx . . $ `external/espeak/translate.h:217:9`!;
853
854 if (nl_count == 0) {
855 if ((c1 == ',') && (cprev == '.') && (tr->translator_name == Lcxx . . $ `external/espeak/translate.h:33:9`!('h', 'u')) && iswdigit_portable(cprev2) && (iswdigit_portable(c_next) || (iswlower_portable(c_next)))) {
856 // lang=hu, fix for ordinal numbers, eg: "december 2., szerda", ignore ',' after ordinal number
857 c1 = CHAR_COMMA_BREAKcxx . . $ `external/espeak/translate.h:255:9`!;
858 is_end_clause = false;
859 }
860
861 if (c1 == '.' && c_next == '\'' && text_decoder_peekc(p_decodercxx . . $ p_decoder.) == 's') {
862 // A special case to handle english acronym + genitive, eg. u.s.a.'s
863 // But avoid breaking clause handling if anything else follows the apostrophe.
864 is_end_clause = false;
865 }
866
867 if (c1 == '.') {
868 if ((tr->langopts.numbers & NUM_ORDINAL_DOTcxx . . $ `external/espeak/translate.h:450:9`!) &&
869 (iswdigit_portable(cprev) || (IsRomanUcxx . . $ IsRomanU(4c679297bf94b9eb).(cprev) && (IsRomanUcxx . . $ IsRomanU(4c679297bf94b9eb).(cprev2) || iswspace_portable(cprev2))))) { // lang=hu
870 // dot after a number indicates an ordinal number
871 if (!iswdigit_portable(cprev))
872 is_end_clause = false; // Roman number followed by dot
873 else if (iswlower_portable(c_next) || (c_next == '-')) // hyphen is needed for lang-hu (eg. 2.-kal)
874 is_end_clause = false; // only if followed by lower-case, (or if there is a XML tag)
875 }
876 if (iswlower_portable(c_next) && tr->langopts.lowercase_sentence == false) {
877 // next word has no capital letter, this dot is probably from an abbreviation
878 is_end_clause = false;
879 }
880 if (any_alnum == false) {
881 // no letters or digits yet, so probably not a sentence terminator
882 // Here, dot is followed by space or bracket
883 c1 = ' ';
884 is_end_clause = false;
885 }
886 } else {
887 if (any_alnum == false) {
888 // no letters or digits yet, so probably not a sentence terminator
889 is_end_clause = false;
890 }
891 }
892
893 if (is_end_clause && (c1 == '.') && (c_next == '<') && option_ssml) {
894 // wait until after the end of the xml tag, then look for upper-case letter
895 is_end_clause = false;
896 end_clause_index = ix;
897 end_clause_after_tag = punct_data;
898 }
899 }
900
901 if (is_end_clause) {
902 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, &c_next);
903
904 if (iswdigit_portable(cprev) && !IsAlphacxx . . $ IsAlpha(4c679297bf94b9eb).(c_next)) // ????
905 punct_data &= ~CLAUSE_DOT_AFTER_LAST_WORDcxx . . $ `external/espeak/translate.h:217:9`!;
906 if (nl_count > 1) {
907 if ((punct_data == CLAUSE_QUESTIONcxx . . $ `external/espeak/translate.h:240:9`!) || (punct_data == CLAUSE_EXCLAMATIONcxx . . $ `external/espeak/translate.h:241:9`!))
908 return punct_data + 35; // with a longer pause
909 return CLAUSE_PARAGRAPHcxx . . $ `external/espeak/translate.h:233:9`!;
910 }
911 return punct_data; // only recognise punctuation if followed by a blank or bracket/quote
912 } else if (!Eofcxx . . $ Eof(b126dc7c1de90089).()) {
913 if (iswspace_portable(c2))
914 UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(c_next);
915 }
916 }
917 }
918
919 if (speech_parameterscxx . . $ speech_parameters.[espeakSILENCEcxx . . $ espeakSILENCE.] == 1)
920 continue;
921
922 if (c1 == announced_punctuation) {
923 // This character has already been announced, so delete it so that it isn't spoken a second time.
924 // Unless it's a hyphen or apostrophe (which is used by TranslateClause() )
925 if (IsBracketcxx . . $ IsBracket(7864480464b09eea).(c1))
926 c1 = 0xe000 + '('; // Unicode private useage area. So TranslateRules() knows the bracket name has been spoken
927 else if (c1 != '-')
928 c1 = ' ';
929 }
930
931 j = ix+1;
932
933 if (c1 == 0xe000 + '<') c1 = '<';
934
935 ix += utf8_outcxx . . $ utf8_out(fa84e865f2d62ca9).(c1, &buf[ix]);
936 if (!iswspace_portable(c1) && !IsBracketcxx . . $ IsBracket(7864480464b09eea).(c1)) {
937 charix[ix] = count_characterscxx . . $ count_characters. - clause_start_char;
938 while (j < ix)
939 charix[j++] = -1; // subsequent bytes of a multibyte character
940 }
941 *charix_top = ix;
942
943 if (((ix > (n_buf-75)) && !IsAlphacxx . . $ IsAlpha(4c679297bf94b9eb).(c1) && !iswdigit_portable(c1)) || (ix >= (n_buf-4))) {
944 // clause too long, getting near end of buffer, so break here
945 // try to break at a word boundary (unless we actually reach the end of buffer).
946 // (n_buf-4) is to allow for 3 bytes of multibyte character plus terminator.
947 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, &c2);
948 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
949 }
950 }
951
952 if (stressed_word)
953 ix += utf8_outcxx . . $ utf8_out(fa84e865f2d62ca9).(CHAR_EMPHASIScxx . . $ `external/espeak/translate.h:254:9`!, &buf[ix]);
954 if (end_clause_after_tag)
955 RemoveCharcxx . . $ RemoveChar(fda57c8427c60377).(&buf[end_clause_index]); // delete clause-end punctiation
956 TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(buf, ix, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
957 return CLAUSE_EOFcxx . . $ `external/espeak/translate.h:234:9`!; // end of file
958 }
959
960 void InitNamedatacxx . . $ InitNamedata(49f6e7a06ebc5aa8).(void)
961 {
962 namedata_ixcxx . . $ namedata_ix. = 0;
963 if (namedatacxx . . $ namedata. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
964 freecxx . . $ free(bd21765a0afc8e3c).(namedatacxx . . $ namedata.);
965 namedatacxx . . $ namedata. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
966 n_namedatacxx . . $ n_namedata. = 0;
967 }
968 }
969
970 void InitText2cxx . . $ InitText2(49f6e7a06ebc5aa8).(void)
971 {
972 int param;
973
974 ungot_charcxx . . $ ungot_char. = 0;
975 ungot_char2cxx . . $ ungot_char2. = 0;
976
977 n_ssml_stackcxx . . $ n_ssml_stack. = 1;
978 MAKE_MEM_UNDEFINEDcxx . . $ `external/espeak/speech.h:39:13`!(&ssml_stack[1], sizeof(ssml_stack) - sizeof(ssml_stack[0]));
979 n_param_stackcxx . . $ n_param_stack. = 1;
980 MAKE_MEM_UNDEFINEDcxx . . $ `external/espeak/speech.h:39:13`!(&param_stack[1], sizeof(param_stack) - sizeof(param_stack[0]));
981 ssml_stackcxx . . $ ssml_stack.[0].tag_type = 0;
982
983 for (param = 0; param < N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.; param++)
984 speech_parameterscxx . . $ speech_parameters.[param] = param_stackcxx . . $ param_stack.[0].parameter[param]; // set all speech parameters to defaults
985
986 option_punctuation = speech_parameterscxx . . $ speech_parameters.[espeakPUNCTUATIONcxx . . $ espeakPUNCTUATION.];
987 option_capitals = speech_parameterscxx . . $ speech_parameters.[espeakCAPITALScxx . . $ espeakCAPITALS.];
988
989 current_voice_idcxx . . $ current_voice_id.[0] = 0;
990
991 ignore_textcxx . . $ ignore_text. = false;
992 audio_textcxx . . $ audio_text. = false;
993 clear_skipping_textcxx . . $ clear_skipping_text. = false;
994 count_characterscxx . . $ count_characters. = -1;
995 sayas_modecxx . . $ sayas_mode. = 0;
996
997 xmlbasecxx . . $ xmlbase. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
998 }
999
1000 static void TerminateBufWithSpaceAndZerocxx . . $ TerminateBufWithSpaceAndZero(928aee07933de1e).(char *buf, int index, int *ungetc) {
1001 buf[index] = ' ';
1002 buf[index+1] = 0;
1003
1004 if (ungetc != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1005 UngetCcxx . . $ UngetC(d4f767463ce0a6b3).(*ungetc);
1006 }
1007 }
1008
1009 static void DecodeWithPhonemeModecxx . . $ DecodeWithPhonemeMode(70b958c0326d8b45).(char *buf, char *phonemes, Translator *tr, Translator *tr2, unsigned int flags[]) {
1010 char phonemes2[55];
1011 if (tr2 == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1012 SetWordStress(tr, phonemes, flags, -1, 0);
1013 DecodePhonemes(phonemes, phonemes2);
1014 sprintf(buf, "[\002%s]]", phonemes2);
1015 } else {
1016 SetWordStress(tr2, phonemes, flags, -1, 0);
1017 DecodePhonemes(phonemes, phonemes2);
1018 char wbuf[5];
1019 sprintf(buf, "[\002_^_%s %s _^_%s]]", ESPEAKNG_DEFAULT_VOICEcxx . . $ `external/espeak/espeak_ng.h:39:9`!, phonemes2, WordToString2cxx . . $ WordToString2(d172961b102a89a5).(wbuf, tr->translator_name));
1020 }
1021 }