Debian Codegraph @

external/espeak/ssml.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 * Copyright (C) 2018 Juho Hiltunen
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see: <http://www.gnu.org/licenses/>.
19 */
20
21
22 #include "espeak__config.h"cxx . . $ `<file>/external/espeak/espeak__config.h`/
23
24 #include <ctype.h>
25 #include <errno.h>
26 #include <locale.h>
27 #include <math.h>
28 #include <stdint.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <wchar.h>
34 #include "wctype_portable.h"cxx . . $ `<file>/kar/wctype_portable.h`/
35
36
37 #include "espeak_ng.h"cxx . . $ `<file>/external/espeak/espeak_ng.h`/
38 #include "speak_lib.h"cxx . . $ `<file>/external/espeak/speak_lib.h`/
39 #include "encoding.h"cxx . . $ `<file>/external/espeak/encoding.h`/
40 #include "ucd.h"cxx . . $ `<file>/external/espeak/ucd.h`/
41
42 #include "ssml.h"cxx . . $ `<file>/external/espeak/ssml.h`/
43 #include "common.h"cxx . . $ `<file>/external/espeak/common.h`/ // for strncpy0
44 #include "mnemonics.h"cxx . . $ `<file>/external/espeak/mnemonics.h`/ // for LookupMnemName, MNEM_TAB,
45 #include "readclause.h"cxx . . $ `<file>/external/espeak/readclause.h`/ // for PARAM_STACK, param_stack, AddNameData
46 #include "soundicon.h"cxx . . $ `<file>/external/espeak/soundicon.h`/ // for LoadSoundFile2
47 #include "synthesize.h"cxx . . $ `<file>/external/espeak/synthesize.h`/ // for SPEED_FACTORS, speed
48 #include "translate.h"cxx . . $ `<file>/external/espeak/translate.h`/ // for CTRL_EMBEDDED
49 #include "voice.h"cxx . . $ `<file>/external/espeak/voice.h`/ // for SelectVoice, SelectVoiceByName
50 #include "speech.h"cxx . . $ `<file>/external/espeak/speech.h`/ // for MAKE_MEM_UNDEFINED
51
52 static const MNEM_TAB ssmltagscxx . . $ ssmltags.[] = {
53 { "speak", SSML_SPEAKcxx . . $ `external/espeak/ssml.h:47:9`! },
54 { "voice", SSML_VOICEcxx . . $ `external/espeak/ssml.h:48:9`! },
55 { "prosody", SSML_PROSODYcxx . . $ `external/espeak/ssml.h:49:9`! },
56 { "say-as", SSML_SAYAScxx . . $ `external/espeak/ssml.h:50:9`! },
57 { "mark", SSML_MARKcxx . . $ `external/espeak/ssml.h:51:9`! },
58 { "s", SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`! },
59 { "p", SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`! },
60 { "phoneme", SSML_PHONEMEcxx . . $ `external/espeak/ssml.h:54:9`! },
61 { "sub", SSML_SUBcxx . . $ `external/espeak/ssml.h:55:9`! },
62 { "tts:style", SSML_STYLEcxx . . $ `external/espeak/ssml.h:56:9`! },
63 { "audio", SSML_AUDIOcxx . . $ `external/espeak/ssml.h:57:9`! },
64 { "emphasis", SSML_EMPHASIScxx . . $ `external/espeak/ssml.h:58:9`! },
65 { "break", SSML_BREAKcxx . . $ `external/espeak/ssml.h:59:9`! },
66 { "metadata", SSML_IGNORE_TEXTcxx . . $ `external/espeak/ssml.h:60:9`! },
67
68 { "br", HTML_BREAKcxx . . $ `external/espeak/ssml.h:61:9`! },
69 { "li", HTML_BREAKcxx . . $ `external/espeak/ssml.h:61:9`! },
70 { "dd", HTML_BREAKcxx . . $ `external/espeak/ssml.h:61:9`! },
71 { "img", HTML_BREAKcxx . . $ `external/espeak/ssml.h:61:9`! },
72 { "td", HTML_BREAKcxx . . $ `external/espeak/ssml.h:61:9`! },
73 { "h1", SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`! },
74 { "h2", SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`! },
75 { "h3", SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`! },
76 { "h4", SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`! },
77 { "hr", SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`! },
78 { "script", SSML_IGNORE_TEXTcxx . . $ `external/espeak/ssml.h:60:9`! },
79 { "style", SSML_IGNORE_TEXTcxx . . $ `external/espeak/ssml.h:60:9`! },
80 { "font", HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`! },
81 { "b", HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`! },
82 { "i", HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`! },
83 { "strong", HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`! },
84 { "em", HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`! },
85 { "code", HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`! },
86
87 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0 }
88 };
89
90 static int (*uri_callbackcxx . . $ uri_callback.)(int, const char *, const char *) = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
91
92 static int attrcmpcxx . . $ attrcmp(8001583cad347d5c).(const wchar_t *string1, const char *string2)
93 {
94 int ix;
95
96 if (string1 == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
97 return 1;
98
99 for (ix = 0; (string1[ix] == string2[ix]) && (string1[ix] != 0); ix++)
100 ;
101 if (((string1[ix] == '"') || (string1[ix] == '\'')) && (string2[ix] == 0))
102 return 0;
103 return 1;
104 }
105
106
107 static int attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(const wchar_t *string1, const MNEM_TAB *mtab)
108 {
109 int ix;
110
111 for (ix = 0; mtab[ix].mnem != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; ix++) {
112 if (attrcmpcxx . . $ attrcmp(8001583cad347d5c).(string1, mtab[ix].mnem) == 0)
113 return mtab[ix].value;
114 }
115 return mtab[ix].value;
116 }
117
118 static int attrnumbercxx . . $ attrnumber(e2fda020b3a577de).(const wchar_t *pw, int default_value, int type)
119 {
120 int value = 0;
121
122 if ((pw == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) || !IsDigit09cxx . . $ IsDigit09(4c679297bf94b9eb).(*pw))
123 return default_value;
124
125 while (IsDigit09cxx . . $ IsDigit09(4c679297bf94b9eb).(*pw))
126 value = value*10 + *pw++ - '0';
127 if ((type == 1) && (ucd_tolower(*pw) == 's')) {
128 // time: seconds rather than ms
129 value *= 1000;
130 }
131 return value;
132 }
133
134 static int attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(char *buf, const wchar_t *pw, int len)
135 {
136 // Convert attribute string into utf8, write to buf, and return its utf8 length
137 int ix = 0;
138
139 if (pw != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
140 wchar_t quote = pw[-1];
141 if ((quote != '"') && (quote != '\'')) quote = 0;
142
143 unsigned int c;
144 int prev_c = 0;
145 while ((ix < (len-4)) && ((c = *pw++) != 0)) {
146 if ((quote == 0) && (isspace(c) || (c == '/')))
147 break;
148 if ((quote != 0) && (c == quote) && (prev_c != '\\'))
149 break; // " indicates end of attribute, unless preceded by backstroke
150
151 int n = utf8_outcxx . . $ utf8_out(fa84e865f2d62ca9).(c, &buf[ix]);
152 ix += n;
153 prev_c = c;
154 }
155 }
156 buf[ix] = 0;
157 return ix;
158 }
159
160 static int attr_prosody_valuecxx . . $ attr_prosody_value(4b509fcfd7c37067).(int param_type, const wchar_t *pw, int *value_out)
161 {
162 int sign = 0;
163 wchar_t *tail;
164 double value;
165
166 while (iswspace_portable(*pw)) pw++;
167 if (*pw == '+') {
168 pw++;
169 sign = 1;
170 }
171 if (*pw == '-') {
172 pw++;
173 sign = -1;
174 }
175 value = (double)wcstod(pw, &tail);
176 if (tail == pw) {
177 // failed to find a number, return 100%
178 *value_out = 100;
179 return 2;
180 }
181
182 if (*tail == '%') {
183 if (sign != 0)
184 value = 100 + (sign * value);
185 *value_out = (int)value;
186 return 2; // percentage
187 }
188
189 if ((tail[0] == 's') && (tail[1] == 't')) {
190 double x;
191 // convert from semitones to a frequency percentage
192 x = powcxx . . $ pow(b71928d39fde4295).((double)2.0, (double)((value*sign)/12)) * 100;
193 *value_out = (int)x;
194 return 2; // percentage
195 }
196
197 if (param_type == espeakRATEcxx . . $ espeakRATE.) {
198 if (sign == 0)
199 *value_out = (int)(value * 100);
200 else
201 *value_out = 100 + (int)(sign * value * 100);
202 return 2; // percentage
203 }
204
205 *value_out = (int)value;
206 return sign; // -1, 0, or 1
207 }
208
209 static const char *VoiceFromStackcxx . . $ VoiceFromStack(c2565f771045a2b6).(SSML_STACK *ssml_stack, int n_ssml_stack, espeak_VOICEcxx . . $ espeak_VOICE# *base_voice, char base_voice_variant_name[40])
210 {
211 // Use the voice properties from the SSML stack to choose a voice, and switch
212 // to that voice if it's not the current voice
213
214 int ix;
215 const char *p;
216 SSML_STACK *sp;
217 const char *v_id;
218 int voice_found;
219 espeak_VOICEcxx . . $ espeak_VOICE# voice_select;
220 static char voice_name[40];
221 char language[40];
222
223 MAKE_MEM_UNDEFINEDcxx . . $ `external/espeak/speech.h:39:13`!(&voice_name, sizeof(voice_name));
224
225 strcpy(voice_name, ssml_stack[0].voice_name);
226 strcpy(language, ssml_stack[0].language);
227 voice_select.agecxx . . $ $anonymous_type_6337c0e5abb454c9_8#age. = ssml_stack[0].voice_age;
228 voice_select.gendercxx . . $ $anonymous_type_6337c0e5abb454c9_8#gender. = ssml_stack[0].voice_gender;
229 voice_select.variantcxx . . $ $anonymous_type_6337c0e5abb454c9_8#variant. = ssml_stack[0].voice_variant_number;
230 voice_select.identifiercxx . . $ $anonymous_type_6337c0e5abb454c9_8#identifier. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
231
232 for (ix = 0; ix < n_ssml_stack; ix++) {
233 sp = &ssml_stack[ix];
234 int voice_name_specified = 0;
235
236 if ((sp->voice_name[0] != 0) && (SelectVoiceByName(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, sp->voice_name) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) {
237 voice_name_specified = 1;
238 strcpy(voice_name, sp->voice_name);
239 language[0] = 0;
240 voice_select.gendercxx . . $ $anonymous_type_6337c0e5abb454c9_8#gender. = ENGENDER_UNKNOWN;
241 voice_select.agecxx . . $ $anonymous_type_6337c0e5abb454c9_8#age. = 0;
242 voice_select.variantcxx . . $ $anonymous_type_6337c0e5abb454c9_8#variant. = 0;
243 }
244 if (sp->language[0] != 0) {
245 strcpy(language, sp->language);
246
247 // is this language provided by the base voice?
248 p = base_voice->languagescxx . . $ $anonymous_type_6337c0e5abb454c9_8#languages.;
249 while (*p++ != 0) {
250 if (strcmp(p, language) == 0) {
251 // yes, change the language to the main language of the base voice
252 strcpy(language, &base_voice->languagescxx . . $ $anonymous_type_6337c0e5abb454c9_8#languages.[1]);
253 break;
254 }
255 p += (strlen(p) + 1);
256 }
257
258 if (voice_name_specified == 0)
259 voice_name[0] = 0; // forget a previous voice name if a language is specified
260 }
261 if (sp->voice_gender != ENGENDER_UNKNOWN)
262 voice_select.gendercxx . . $ $anonymous_type_6337c0e5abb454c9_8#gender. = sp->voice_gender;
263
264 if (sp->voice_age != 0)
265 voice_select.agecxx . . $ $anonymous_type_6337c0e5abb454c9_8#age. = sp->voice_age;
266 if (sp->voice_variant_number != 0)
267 voice_select.variantcxx . . $ $anonymous_type_6337c0e5abb454c9_8#variant. = sp->voice_variant_number;
268 }
269
270 voice_select.namecxx . . $ $anonymous_type_6337c0e5abb454c9_8#name. = voice_name;
271 voice_select.languagescxx . . $ $anonymous_type_6337c0e5abb454c9_8#languages. = language;
272 v_id = SelectVoice(&voice_select, &voice_found);
273 if (v_id == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
274 return "default";
275
276 if ((strchr(v_id, '+') == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && ((voice_select.gendercxx . . $ $anonymous_type_6337c0e5abb454c9_8#gender. == ENGENDER_UNKNOWN) || (voice_select.gendercxx . . $ $anonymous_type_6337c0e5abb454c9_8#gender. == base_voice->gendercxx . . $ $anonymous_type_6337c0e5abb454c9_8#gender.)) && (base_voice_variant_name[0] != 0)) {
277 // a voice variant has not been selected, use the original voice variant
278 char buf[80];
279 sprintf(buf, "%s+%s", v_id, base_voice_variant_name);
280 strncpy0cxx . . $ strncpy0(3366d352079c3ed6).(voice_name, buf, sizeof(voice_name));
281 return voice_name;
282 }
283 return v_id;
284 }
285
286
287 static const wchar_t *GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(wchar_t *pw, const char *name)
288 {
289 // Gets the value string for an attribute.
290 // Returns NULL if the attribute is not present
291
292 int ix;
293 static const wchar_t empty[1] = { 0 };
294
295 while (*pw != 0) {
296 if (iswspace_portable(pw[-1])) {
297 ix = 0;
298 while (*pw == name[ix]) {
299 pw++;
300 ix++;
301 }
302 if (name[ix] == 0) {
303 // found the attribute, now get the value
304 while (iswspace_portable(*pw)) pw++;
305 if (*pw == '=') pw++;
306 while (iswspace_portable(*pw)) pw++;
307 if ((*pw == '"') || (*pw == '\'')) // allow single-quotes ?
308 return pw+1;
309 else if (iswspace_portable(*pw) || (*pw == '/')) // end of attribute
310 return empty;
311 else
312 return pw;
313 }
314 }
315 pw++;
316 }
317 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
318 }
319
320
321 static int GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(wchar_t *pw, int tag_type, SSML_STACK *ssml_sp, SSML_STACK *ssml_stack, int n_ssml_stack, char current_voice_id[40], espeak_VOICEcxx . . $ espeak_VOICE# *base_voice, char *base_voice_variant_name)
322 {
323 // Determines whether voice attribute are specified in this tag, and if so, whether this means
324 // a voice change.
325 // If it's a closing tag, delete the top frame of the stack and determine whether this implies
326 // a voice change.
327 // Returns CLAUSE_TYPE_VOICE_CHANGE if there is a voice change
328
329 const char *new_voice_id;
330
331 static const MNEM_TAB mnem_gender[] = {
332 { "male", ENGENDER_MALE },
333 { "female", ENGENDER_FEMALE },
334 { "neutral", ENGENDER_NEUTRAL },
335 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, ENGENDER_UNKNOWN }
336 };
337
338 if (tag_type & SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!) {
339 // delete a stack frame
340 if (n_ssml_stack > 1)
341 n_ssml_stack--;
342 } else {
343 const wchar_t *lang;
344 const wchar_t *gender;
345 const wchar_t *name;
346 const wchar_t *age;
347 const wchar_t *variant;
348
349 // add a stack frame if any voice details are specified
350 lang = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(pw, "xml:lang");
351
352 if (tag_type != SSML_VOICEcxx . . $ `external/espeak/ssml.h:48:9`!) {
353 // only expect an xml:lang attribute
354 name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
355 variant = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
356 age = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
357 gender = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
358 } else {
359 name = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(pw, "name");
360 variant = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(pw, "variant");
361 age = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(pw, "age");
362 gender = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(pw, "gender");
363 }
364
365 if ((tag_type != SSML_VOICEcxx . . $ `external/espeak/ssml.h:48:9`!) && (lang == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!))
366 return 0; // <s> or <p> without language spec, nothing to do
367
368 ssml_sp = &ssml_stack[n_ssml_stack++];
369
370 int value;
371
372 attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(ssml_sp->language, lang, sizeof(ssml_sp->language));
373 attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(ssml_sp->voice_name, name, sizeof(ssml_sp->voice_name));
374 if ((value = attrnumbercxx . . $ attrnumber(e2fda020b3a577de).(variant, 1, 0)) > 0)
375 value--; // variant='0' and variant='1' the same
376 ssml_sp->voice_variant_number = value;
377 ssml_sp->voice_age = attrnumbercxx . . $ attrnumber(e2fda020b3a577de).(age, 0, 0);
378 ssml_sp->voice_gender = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(gender, mnem_gender);
379 ssml_sp->tag_type = tag_type;
380 }
381
382 new_voice_id = VoiceFromStackcxx . . $ VoiceFromStack(c2565f771045a2b6).(ssml_stack, n_ssml_stack, base_voice, base_voice_variant_name);
383 if (strcmp(new_voice_id, current_voice_id) != 0) {
384 // add an embedded command to change the voice
385 strcpy(current_voice_id, new_voice_id);
386 return CLAUSE_TYPE_VOICE_CHANGEcxx . . $ `external/espeak/translate.h:228:9`!;
387 }
388
389 return 0;
390 }
391
392 static void ProcessParamStackcxx . . $ ProcessParamStack(58ab4b1ddb62313c).(char *outbuf, int *outix, int n_param_stack, PARAM_STACK *paramStack, int *speech_parameters)
393 {
394 // Set the speech parameters from the parameter stack
395 int param;
396 int ix;
397 char buf[20];
398 int new_parameters[N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.];
399 static const char cmd_letter[N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.] = { 0, 'S', 'A', 'P', 'R', 0, 'C', 0, 0, 0, 0, 0, 'F' }; // embedded command letters
400
401 for (param = 0; param < N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.; param++)
402 new_parameters[param] = -1;
403
404 for (ix = 0; ix < n_param_stack; ix++) {
405 for (param = 0; param < N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.; param++) {
406 if (paramStack[ix].parameter[param] >= 0)
407 new_parameters[param] = paramStack[ix].parameter[param];
408 }
409 }
410
411 for (param = 0; param < N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.; param++) {
412 int value;
413 if ((value = new_parameters[param]) != speech_parameters[param]) {
414 buf[0] = 0;
415
416 switch (param)
417 {
418 case espeakPUNCTUATIONcxx . . $ espeakPUNCTUATION.:
419 option_punctuation = value-1;
420 break;
421 case espeakCAPITALScxx . . $ espeakCAPITALS.:
422 option_capitals = value;
423 break;
424 case espeakRATEcxx . . $ espeakRATE.:
425 case espeakVOLUMEcxx . . $ espeakVOLUME.:
426 case espeakPITCHcxx . . $ espeakPITCH.:
427 case espeakRANGEcxx . . $ espeakRANGE.:
428 case espeakEMPHASIScxx . . $ espeakEMPHASIS.:
429 sprintf(buf, "%c%d%c", CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!, value, cmd_letter[param]);
430 break;
431 }
432
433 speech_parameters[param] = new_parameters[param];
434 strcpy(&outbuf[*outix], buf);
435 *outix += strlen(buf);
436 }
437 }
438 }
439
440 static PARAM_STACK *PushParamStackcxx . . $ PushParamStack(968c6b1d2c3ef9c4).(int tag_type, int *n_param_stack, PARAM_STACK *paramStack)
441 {
442 int ix;
443 PARAM_STACK *sp;
444
445 sp = &paramStack[*n_param_stack];
446 if (*n_param_stack < (N_PARAM_STACKcxx . . $ `external/espeak/ssml.h:45:9`!-1))
447 (*n_param_stack)++;
448
449 sp->type = tag_type;
450 for (ix = 0; ix < N_SPEECH_PARAMcxx . . $ N_SPEECH_PARAM.; ix++)
451 sp->parameter[ix] = -1;
452 return sp;
453 }
454
455 static void PopParamStackcxx . . $ PopParamStack(8bfc8c1a638c28e7).(int tag_type, char *outbuf, int *outix, int *n_param_stack, PARAM_STACK *paramStack, int *speech_parameters)
456 {
457 // unwind the stack up to and including the previous tag of this type
458 int ix;
459 int top = 0;
460
461 if (tag_type >= SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!)
462 tag_type -= SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!;
463
464 for (ix = 0; ix < *n_param_stack; ix++) {
465 if (paramStack[ix].type == tag_type)
466 top = ix;
467 }
468 if (top > 0)
469 *n_param_stack = top;
470 ProcessParamStackcxx . . $ ProcessParamStack(58ab4b1ddb62313c).(outbuf, outix, *n_param_stack, paramStack, speech_parameters);
471 }
472
473 static int ReplaceKeyNamecxx . . $ ReplaceKeyName(fa322d2ebdf80961).(char *outbuf, int index, int *outix)
474 {
475 // Replace some key-names by single characters, so they can be pronounced in different languages
476 static const MNEM_TAB keynames[] = {
477 { "space ", 0xe020 },
478 { "tab ", 0xe009 },
479 { "underscore ", 0xe05f },
480 { "double-quote ", '"' },
481 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0 }
482 };
483
484 int letter;
485 char *p;
486
487 p = &outbuf[index];
488
489 if ((letter = LookupMnem(keynames, p)) != 0) {
490 int ix;
491 ix = utf8_outcxx . . $ utf8_out(fa84e865f2d62ca9).(letter, p);
492 *outix = index + ix;
493 return letter;
494 }
495 return 0;
496 }
497
498 static void SetProsodyParametercxx . . $ SetProsodyParameter(f447a4c66227cd7b).(int param_type, const wchar_t *attr1, PARAM_STACK *sp, PARAM_STACK *paramStack, int *speech_parameters)
499 {
500 int value;
501
502
503 static const MNEM_TAB mnem_volume[] = {
504 { "default", 100 },
505 { "silent", 0 },
506 { "x-soft", 30 },
507 { "soft", 65 },
508 { "medium", 100 },
509 { "loud", 150 },
510 { "x-loud", 230 },
511 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
512 };
513
514 static const MNEM_TAB mnem_rate[] = {
515 { "default", 100 },
516 { "x-slow", 60 },
517 { "slow", 80 },
518 { "medium", 100 },
519 { "fast", 125 },
520 { "x-fast", 160 },
521 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
522 };
523
524 static const MNEM_TAB mnem_pitch[] = {
525 { "default", 100 },
526 { "x-low", 70 },
527 { "low", 85 },
528 { "medium", 100 },
529 { "high", 110 },
530 { "x-high", 120 },
531 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
532 };
533
534 static const MNEM_TAB mnem_range[] = {
535 { "default", 100 },
536 { "x-low", 20 },
537 { "low", 50 },
538 { "medium", 100 },
539 { "high", 140 },
540 { "x-high", 180 },
541 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
542 };
543
544 static const MNEM_TAB * const mnem_tabs[5] = {
545 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mnem_rate, mnem_volume, mnem_pitch, mnem_range
546 };
547
548 if ((value = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr1, mnem_tabs[param_type])) >= 0) {
549 // mnemonic specifies a value as a percentage of the base pitch/range/rate/volume
550 sp->parameter[param_type] = (paramStack[0].parameter[param_type] * value)/100;
551 } else {
552 int sign = attr_prosody_valuecxx . . $ attr_prosody_value(4b509fcfd7c37067).(param_type, attr1, &value);
553
554 if (sign == 0)
555 sp->parameter[param_type] = value; // absolute value in Hz
556 else if (sign == 2) {
557 // change specified as percentage or in semitones
558 sp->parameter[param_type] = (speech_parameters[param_type] * value)/100;
559 } else {
560 // change specified as plus or minus Hz
561 sp->parameter[param_type] = speech_parameters[param_type] + (value*sign);
562 }
563 }
564 }
565
566 int ProcessSsmlTagcxx . . $ ProcessSsmlTag(441df88b892ba17d).(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, const char *xmlbase, bool *audio_text, char *current_voice_id, espeak_VOICEcxx . . $ espeak_VOICE# *base_voice, char *base_voice_variant_name, bool *ignore_text, bool *clear_skipping_text, int *sayas_mode, int *sayas_start, SSML_STACK *ssml_stack, int *n_ssml_stack, int *n_param_stack, int *speech_parameters)
567 {
568 // xml_buf is the tag and attributes with a zero terminator in place of the original '>'
569 // returns a clause terminator value.
570
571 unsigned int ix;
572 int index;
573 int tag_type;
574 int value;
575 int value2;
576 int value3;
577 int voice_change_flag;
578 wchar_t *px;
579 const wchar_t *attr1;
580 const wchar_t *attr2;
581 const wchar_t *attr3;
582 int terminator;
583 int param_type;
584 char tag_name[40];
585 char buf[160];
586 PARAM_STACK *sp;
587 SSML_STACK *ssml_sp;
588
589 // don't process comments and xml declarations
590 if (wcsncmp(xml_buf, (wchar_t *) "!--", 3) == 0 || wcsncmp(xml_buf, (wchar_t *) "?xml", 4) == 0) {
591 return 0;
592 }
593
594 // these tags have no effect if they are self-closing, eg. <voice />
595 static const char ignore_if_self_closing[] = { 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0 };
596
597 bool self_closing = false;
598 int len;
599 len = wcslen(xml_buf);
600 if (xml_buf[len - 1] == '/') {
601 // a self-closing tag
602 xml_buf[len - 1] = ' ';
603 self_closing = true;
604 }
605
606 static const MNEM_TAB mnem_phoneme_alphabet[] = {
607 { "espeak", 1 },
608 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
609 };
610
611 static const MNEM_TAB mnem_punct[] = {
612 { "none", 1 },
613 { "all", 2 },
614 { "some", 3 },
615 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
616 };
617
618 static const MNEM_TAB mnem_capitals[] = {
619 { "no", 0 },
620 { "icon", 1 },
621 { "spelling", 2 },
622 { "pitch", 20 }, // this is the amount by which to raise the pitch
623 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
624 };
625
626 static const MNEM_TAB mnem_interpret_as[] = {
627 { "characters", SAYAS_CHARScxx . . $ `external/espeak/translate.h:247:9`! },
628 { "tts:char", SAYAS_SINGLE_CHARScxx . . $ `external/espeak/translate.h:249:9`! },
629 { "tts:key", SAYAS_KEYcxx . . $ `external/espeak/translate.h:250:9`! },
630 { "tts:digits", SAYAS_DIGITScxx . . $ `external/espeak/translate.h:251:9`! },
631 { "telephone", SAYAS_DIGITS1cxx . . $ `external/espeak/translate.h:252:9`! },
632 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
633 };
634
635 static const MNEM_TAB mnem_sayas_format[] = {
636 { "glyphs", 1 },
637 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
638 };
639
640 static const MNEM_TAB mnem_break[] = {
641 { "none", 0 },
642 { "x-weak", 1 },
643 { "weak", 2 },
644 { "medium", 3 },
645 { "strong", 4 },
646 { "x-strong", 5 },
647 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
648 };
649
650 static const MNEM_TAB mnem_emphasis[] = {
651 { "none", 1 },
652 { "reduced", 2 },
653 { "moderate", 3 },
654 { "strong", 4 },
655 { "x-strong", 5 },
656 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
657 };
658
659 static const char * const prosody_attr[5] = {
660 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, "rate", "volume", "pitch", "range"
661 };
662
663 for (ix = 0; ix < (sizeof(tag_name)-1); ix++) {
664 int c;
665 if (((c = xml_buf[ix]) == 0) || iswspace_portable(c))
666 break;
667 tag_name[ix] = tolower((char)c);
668 }
669 tag_name[ix] = 0;
670
671 px = &xml_buf[ix]; // the tag's attributes
672
673 if (tag_name[0] == '/') {
674 // closing tag
675 if ((tag_type = LookupMnem(ssmltagscxx . . $ ssmltags., &tag_name[1])) != HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`!)
676 outbuf[(*outix)++] = ' ';
677 tag_type += SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!;
678 } else {
679 if ((tag_type = LookupMnem(ssmltagscxx . . $ ssmltags., tag_name)) != HTML_NOSPACEcxx . . $ `external/espeak/ssml.h:62:9`!) {
680 // separate SSML tags from the previous word (but not HMTL tags such as <b> <font> which can occur inside a word)
681 outbuf[(*outix)++] = ' ';
682 }
683
684 if (self_closing && ignore_if_self_closing[tag_type])
685 return 0;
686 }
687
688 voice_change_flag = 0;
689 ssml_sp = &ssml_stack[*n_ssml_stack-1];
690
691 switch (tag_type)
692 {
693 case SSML_STYLEcxx . . $ `external/espeak/ssml.h:56:9`!:
694 sp = PushParamStackcxx . . $ PushParamStack(968c6b1d2c3ef9c4).(tag_type, n_param_stack, (PARAM_STACK *) param_stack);
695 attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "field");
696 attr2 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "mode");
697
698
699 if (attrcmpcxx . . $ attrcmp(8001583cad347d5c).(attr1, "punctuation") == 0) {
700 value = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr2, mnem_punct);
701 sp->parameter[espeakPUNCTUATIONcxx . . $ espeakPUNCTUATION.] = value;
702 } else if (attrcmpcxx . . $ attrcmp(8001583cad347d5c).(attr1, "capital_letters") == 0) {
703 value = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr2, mnem_capitals);
704 sp->parameter[espeakCAPITALScxx . . $ espeakCAPITALS.] = value;
705 }
706 ProcessParamStackcxx . . $ ProcessParamStack(58ab4b1ddb62313c).(outbuf, outix, *n_param_stack, param_stack, speech_parameters);
707 break;
708 case SSML_PROSODYcxx . . $ `external/espeak/ssml.h:49:9`!:
709 sp = PushParamStackcxx . . $ PushParamStack(968c6b1d2c3ef9c4).(tag_type, n_param_stack, (PARAM_STACK *) param_stack);
710
711 // look for attributes: rate, volume, pitch, range
712 for (param_type = espeakRATEcxx . . $ espeakRATE.; param_type <= espeakRANGEcxx . . $ espeakRANGE.; param_type++) {
713 if ((attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, prosody_attr[param_type])) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
714 SetProsodyParametercxx . . $ SetProsodyParameter(f447a4c66227cd7b).(param_type, attr1, sp, param_stack, speech_parameters);
715 }
716
717 ProcessParamStackcxx . . $ ProcessParamStack(58ab4b1ddb62313c).(outbuf, outix, *n_param_stack, param_stack, speech_parameters);
718 break;
719 case SSML_EMPHASIScxx . . $ `external/espeak/ssml.h:58:9`!:
720 sp = PushParamStackcxx . . $ PushParamStack(968c6b1d2c3ef9c4).(tag_type, n_param_stack, (PARAM_STACK *) param_stack);
721 value = 3; // default is "moderate"
722 if ((attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "level")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
723 value = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr1, mnem_emphasis);
724
725 if (translator->langopts.tone_language == 1) {
726 static const unsigned char emphasis_to_pitch_range[] = { 50, 50, 40, 70, 90, 100 };
727 static const unsigned char emphasis_to_volume[] = { 100, 100, 70, 110, 135, 150 };
728 // tone language (eg.Chinese) do emphasis by increasing the pitch range.
729 sp->parameter[espeakRANGEcxx . . $ espeakRANGE.] = emphasis_to_pitch_range[value];
730 sp->parameter[espeakVOLUMEcxx . . $ espeakVOLUME.] = emphasis_to_volume[value];
731 } else {
732 static const unsigned char emphasis_to_volume2[] = { 100, 100, 75, 100, 120, 150 };
733 sp->parameter[espeakVOLUMEcxx . . $ espeakVOLUME.] = emphasis_to_volume2[value];
734 sp->parameter[espeakEMPHASIScxx . . $ espeakEMPHASIS.] = value;
735 }
736 ProcessParamStackcxx . . $ ProcessParamStack(58ab4b1ddb62313c).(outbuf, outix, *n_param_stack, param_stack, speech_parameters);
737 break;
738 case SSML_STYLEcxx . . $ `external/espeak/ssml.h:56:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
739 case SSML_PROSODYcxx . . $ `external/espeak/ssml.h:49:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
740 case SSML_EMPHASIScxx . . $ `external/espeak/ssml.h:58:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
741 PopParamStackcxx . . $ PopParamStack(8bfc8c1a638c28e7).(tag_type, outbuf, outix, n_param_stack, (PARAM_STACK *) param_stack, (int *) speech_parameters);
742 break;
743 case SSML_PHONEMEcxx . . $ `external/espeak/ssml.h:54:9`!:
744 attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "alphabet");
745 attr2 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "ph");
746 value = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr1, mnem_phoneme_alphabet);
747 if (value == 1) { // alphabet="espeak"
748 outbuf[(*outix)++] = '[';
749 outbuf[(*outix)++] = '[';
750 *outix += attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(&outbuf[*outix], attr2, n_outbuf-*outix);
751 outbuf[(*outix)++] = ']';
752 outbuf[(*outix)++] = ']';
753 }
754 break;
755 case SSML_SAYAScxx . . $ `external/espeak/ssml.h:50:9`!:
756 attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "interpret-as");
757 attr2 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "format");
758 attr3 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "detail");
759 value = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr1, mnem_interpret_as);
760 value2 = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr2, mnem_sayas_format);
761 if (value2 == 1)
762 value = SAYAS_GLYPHScxx . . $ `external/espeak/translate.h:248:9`!;
763
764 value3 = attrnumbercxx . . $ attrnumber(e2fda020b3a577de).(attr3, 0, 0);
765
766 if (value == SAYAS_DIGITScxx . . $ `external/espeak/translate.h:251:9`!) {
767 if (value3 <= 1)
768 value = SAYAS_DIGITS1cxx . . $ `external/espeak/translate.h:252:9`!;
769 else
770 value = SAYAS_DIGITScxx . . $ `external/espeak/translate.h:251:9`! + value3;
771 }
772
773 sprintf(buf, "%c%dY", CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!, value);
774 strcpy(&outbuf[*outix], buf);
775 *outix += strlen(buf);
776
777 *sayas_start = *outix;
778 *sayas_mode = value; // punctuation doesn't end clause during SAY-AS
779 break;
780 case SSML_SAYAScxx . . $ `external/espeak/ssml.h:50:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
781 if (*sayas_mode == SAYAS_KEYcxx . . $ `external/espeak/translate.h:250:9`!) {
782 outbuf[*outix] = 0;
783 ReplaceKeyNamecxx . . $ ReplaceKeyName(fa322d2ebdf80961).(outbuf, *sayas_start, outix);
784 }
785
786 outbuf[(*outix)++] = CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!;
787 outbuf[(*outix)++] = 'Y';
788 *sayas_mode = 0;
789 break;
790 case SSML_SUBcxx . . $ `external/espeak/ssml.h:55:9`!:
791 if ((attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "alias")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
792 // use the alias rather than the text
793 *ignore_text = true;
794 *outix += attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(&outbuf[*outix], attr1, n_outbuf-*outix);
795 }
796 break;
797 case SSML_IGNORE_TEXTcxx . . $ `external/espeak/ssml.h:60:9`!:
798 *ignore_text = true;
799 break;
800 case SSML_SUBcxx . . $ `external/espeak/ssml.h:55:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
801 case SSML_IGNORE_TEXTcxx . . $ `external/espeak/ssml.h:60:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
802 *ignore_text = false;
803 break;
804 case SSML_MARKcxx . . $ `external/espeak/ssml.h:51:9`!:
805 if ((attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "name")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
806 // add name to circular buffer of marker names
807 attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(buf, attr1, sizeof(buf));
808
809 if ((buf[0] != 0) && (strcmp(skip_marker, buf) == 0)) {
810 // This is the marker we are waiting for before starting to speak
811 *clear_skipping_text = true;
812 skip_marker[0] = 0;
813 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
814 }
815
816 if ((index = AddNameData(buf, 0)) >= 0) {
817 sprintf(buf, "%c%dM", CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!, index);
818 strcpy(&outbuf[*outix], buf);
819 *outix += strlen(buf);
820 }
821 }
822 break;
823 case SSML_AUDIOcxx . . $ `external/espeak/ssml.h:57:9`!:
824 sp = PushParamStackcxx . . $ PushParamStack(968c6b1d2c3ef9c4).(tag_type, n_param_stack, (PARAM_STACK *)param_stack);
825
826 if ((attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "src")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
827 attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(buf, attr1, sizeof(buf));
828
829 if (uri_callbackcxx . . $ uri_callback. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
830 if ((xmlbase != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (buf[0] != '/')) {
831 char fname[256];
832 sprintf(fname, "%s/%s", xmlbase, buf);
833 index = LoadSoundFile2(fname);
834 } else
835 index = LoadSoundFile2(buf);
836 if (index >= 0) {
837 sprintf(buf, "%c%dI", CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!, index);
838 strcpy(&outbuf[*outix], buf);
839 *outix += strlen(buf);
840 sp->parameter[espeakSILENCEcxx . . $ espeakSILENCE.] = 1;
841 }
842 } else {
843 if ((index = AddNameData(buf, 0)) >= 0) {
844 char *uri;
845 uri = &namedata[index];
846 if (uri_callbackcxx . . $ uri_callback.(1, uri, xmlbase) == 0) {
847 sprintf(buf, "%c%dU", CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!, index);
848 strcpy(&outbuf[*outix], buf);
849 *outix += strlen(buf);
850 sp->parameter[espeakSILENCEcxx . . $ espeakSILENCE.] = 1;
851 }
852 }
853 }
854 }
855 ProcessParamStackcxx . . $ ProcessParamStack(58ab4b1ddb62313c).(outbuf, outix, *n_param_stack, param_stack, speech_parameters);
856
857 if (self_closing)
858 PopParamStackcxx . . $ PopParamStack(8bfc8c1a638c28e7).(tag_type, outbuf, outix, n_param_stack, (PARAM_STACK *) param_stack, (int *) speech_parameters);
859 else
860 *audio_text = true;
861 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
862 case SSML_AUDIOcxx . . $ `external/espeak/ssml.h:57:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
863 PopParamStackcxx . . $ PopParamStack(8bfc8c1a638c28e7).(tag_type, outbuf, outix, n_param_stack, (PARAM_STACK *) param_stack, (int *) speech_parameters);
864 *audio_text = false;
865 return CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
866 case SSML_BREAKcxx . . $ `external/espeak/ssml.h:59:9`!:
867 value = 21;
868 terminator = CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
869
870 if ((attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "strength")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
871 static const int break_value[6] = { 0, 7, 14, 21, 40, 80 }; // *10mS
872 value = attrlookupcxx . . $ attrlookup(90f43cf760c553d8).(attr1, mnem_break);
873 if (value < 0) value = 2;
874 if (value < 3) {
875 // adjust prepause on the following word
876 sprintf(&outbuf[*outix], "%c%dB", CTRL_EMBEDDEDcxx . . $ `external/espeak/translate.h:37:9`!, value);
877 *outix += 3;
878 terminator = 0;
879 }
880 value = break_value[value];
881 }
882 if ((attr2 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "time")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
883 value2 = attrnumbercxx . . $ attrnumber(e2fda020b3a577de).(attr2, 0, 1); // pause in mS
884
885 value2 = value2 * speech_parameters[espeakSSML_BREAK_MULcxx . . $ espeakSSML_BREAK_MUL.] / 100;
886
887 int wpm = speech_parameters[espeakRATEcxx . . $ espeakRATE.];
888 espeak_SetParameter(espeakRATEcxx . . $ espeakRATE., wpm, 0);
889
890 #if USE_LIBSONIC
891 if (wpm >= espeakRATE_MAXIMUM) {
892 // Compensate speedup with libsonic, see function SetSpeed()
893 double sonic = ((double)wpm)/espeakRATE_NORMAL;
894 value2 = value2 * sonic;
895 }
896 #endif
897
898 // compensate for speaking speed to keep constant pause length, see function PauseLength()
899 // 'value' here is x 10mS
900 value = (value2 * 256) / (speed.clause_pause_factor * 10);
901 if (value < 200)
902 value = (value2 * 256) / (speed.pause_factor * 10);
903
904 if (terminator == 0)
905 terminator = CLAUSE_NONEcxx . . $ `external/espeak/translate.h:232:9`!;
906 }
907 if (terminator) {
908 if (value > 0xfff) {
909 // scale down the value and set a scaling indicator bit
910 value = value / 32;
911 if (value > 0xfff)
912 value = 0xfff;
913 terminator |= CLAUSE_PAUSE_LONGcxx . . $ `external/espeak/translate.h:218:9`!;
914 }
915 return terminator + value;
916 }
917 break;
918 case SSML_SPEAKcxx . . $ `external/espeak/ssml.h:47:9`!:
919 if ((attr1 = GetSsmlAttributecxx . . $ GetSsmlAttribute(c05087d953d38d22).(px, "xml:base")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
920 attrcopy_utf8cxx . . $ attrcopy_utf8(5d211e4a04af9f8c).(buf, attr1, sizeof(buf));
921 if ((index = AddNameData(buf, 0)) >= 0)
922 xmlbase = &namedata[index];
923 }
924 if (GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name) == 0)
925 return 0; // no voice change
926 return CLAUSE_VOICEcxx . . $ `external/espeak/translate.h:235:9`!;
927 case SSML_VOICEcxx . . $ `external/espeak/ssml.h:48:9`!:
928 if (GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name) == 0)
929 return 0; // no voice change
930 return CLAUSE_VOICEcxx . . $ `external/espeak/translate.h:235:9`!;
931 case SSML_SPEAKcxx . . $ `external/espeak/ssml.h:47:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
932 // unwind stack until the previous <voice> or <speak> tag
933 while ((*n_ssml_stack > 1) && (ssml_stack[*n_ssml_stack-1].tag_type != SSML_SPEAKcxx . . $ `external/espeak/ssml.h:47:9`!))
934 (*n_ssml_stack)--;
935 return CLAUSE_PERIODcxx . . $ `external/espeak/translate.h:236:9`! + GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
936 case SSML_VOICEcxx . . $ `external/espeak/ssml.h:48:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
937 // unwind stack until the previous <voice> or <speak> tag
938 while ((*n_ssml_stack > 1) && (ssml_stack[*n_ssml_stack-1].tag_type != SSML_VOICEcxx . . $ `external/espeak/ssml.h:48:9`!))
939 (*n_ssml_stack)--;
940
941 terminator = 0; // ?? Sentence intonation, but no pause ??
942 return terminator + GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
943 case HTML_BREAKcxx . . $ `external/espeak/ssml.h:61:9`!:
944 case HTML_BREAKcxx . . $ `external/espeak/ssml.h:61:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
945 return CLAUSE_COLONcxx . . $ `external/espeak/translate.h:242:9`!;
946 case SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`!:
947 if (ssml_sp->tag_type == SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`!) {
948 // new sentence implies end-of-sentence
949 voice_change_flag = GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`!+SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
950 }
951 voice_change_flag |= GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
952 return CLAUSE_PARAGRAPHcxx . . $ `external/espeak/translate.h:233:9`! + voice_change_flag;
953 case SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`!:
954 if (ssml_sp->tag_type == SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`!) {
955 // new paragraph implies end-of-sentence or end-of-paragraph
956 voice_change_flag = GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`!+SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
957 }
958 if (ssml_sp->tag_type == SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`!) {
959 // new paragraph implies end-of-sentence or end-of-paragraph
960 voice_change_flag |= GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`!+SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
961 }
962 voice_change_flag |= GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
963 return CLAUSE_PARAGRAPHcxx . . $ `external/espeak/translate.h:233:9`! + voice_change_flag;
964 case SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
965 if (ssml_sp->tag_type == SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`!) {
966 // end of a sentence which specified a language
967 voice_change_flag = GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name);
968 }
969 return CLAUSE_PERIODcxx . . $ `external/espeak/translate.h:236:9`! + voice_change_flag;
970 case SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`! + SSML_CLOSEcxx . . $ `external/espeak/ssml.h:63:9`!:
971 if ((ssml_sp->tag_type == SSML_SENTENCEcxx . . $ `external/espeak/ssml.h:52:9`!) || (ssml_sp->tag_type == SSML_PARAGRAPHcxx . . $ `external/espeak/ssml.h:53:9`!)) {
972 // End of a paragraph which specified a language.
973 // (End-of-paragraph also implies end-of-sentence)
974 return GetVoiceAttributescxx . . $ GetVoiceAttributes(218a4d811adad16c).(px, tag_type, ssml_sp, ssml_stack, *n_ssml_stack, current_voice_id, base_voice, base_voice_variant_name) + CLAUSE_PARAGRAPHcxx . . $ `external/espeak/translate.h:233:9`!;
975 }
976 return CLAUSE_PARAGRAPHcxx . . $ `external/espeak/translate.h:233:9`!;
977 }
978 return 0;
979 }
980
981 #pragma GCC visibility push(default)
982 ESPEAK_APIcxx . . $ `external/espeak/speak_lib.h:38:9`! void espeak_SetUriCallbackcxx . . $ espeak_SetUriCallback(bc3bd9bc6fae9363).(int (*UriCallback)(int, const char *, const char *))
983 {
984 uri_callbackcxx . . $ uri_callback. = UriCallback;
985 }
986 #pragma GCC visibility pop
987
988 static const MNEM_TAB xml_entity_mnemonicscxx . . $ xml_entity_mnemonics.[] = {
989 { "gt", '>' },
990 { "lt", 0xe000 + '<' }, // private usage area, to avoid confusion with XML tag
991 { "amp", '&' },
992 { "quot", '"' },
993 { "nbsp", ' ' },
994 { "apos", '\'' },
995 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1 }
996 };
997
998 int ParseSsmlReferencecxx . . $ ParseSsmlReference(706dade7bab5a6e2).(char *ref, int *c1, int *c2) {
999 // Check if buffer *ref contains an XML character or entity reference
1000 // if found, set *c1 to the replacement char
1001 // change *c2 for entity references
1002 // returns >= 0 on success
1003
1004 if (ref[0] == '#') {
1005 // character reference
1006 if (ref[1] == 'x')
1007 return sscanf(&ref[2], "%x", c1);
1008 else
1009 return sscanf(&ref[1], "%d", c1);
1010 } else {
1011 // entity reference
1012 int found;
1013 if ((found = LookupMnem(xml_entity_mnemonicscxx . . $ xml_entity_mnemonics., ref)) != -1) {
1014 *c1 = found;
1015 if (*c2 == 0)
1016 *c2 = ' ';
1017 return found;
1018 }
1019 }
1020 return -1;
1021 }