Debian Codegraph @

external/espeak/setlengths.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2005 to 2011 by Jonathan Duddington
3 * email: [email protected]
4 * Copyright (C) 2015-2016 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 <errno.h>
23 #include <stdint.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 #include "espeak_ng.h"cxx . . $ `<file>/external/espeak/espeak_ng.h`/
28 #include "speak_lib.h"cxx . . $ `<file>/external/espeak/speak_lib.h`/
29 #include "encoding.h"cxx . . $ `<file>/external/espeak/encoding.h`/
30
31 #include "readclause.h"cxx . . $ `<file>/external/espeak/readclause.h`/
32 #include "setlengths.h"cxx . . $ `<file>/external/espeak/setlengths.h`/
33 #include "synthdata.h"cxx . . $ `<file>/external/espeak/synthdata.h`/
34 #include "wavegen.h"cxx . . $ `<file>/external/espeak/wavegen.h`/
35
36 #include "phoneme.h"cxx . . $ `<file>/external/espeak/phoneme.h`/
37 #include "voice.h"cxx . . $ `<file>/external/espeak/voice.h`/
38 #include "synthesize.h"cxx . . $ `<file>/external/espeak/synthesize.h`/
39 #include "translate.h"cxx . . $ `<file>/external/espeak/translate.h`/
40
41 static void SetSpeedFactorscxx . . $ SetSpeedFactors(a401a204ccd10ded).(voice_t *voice, int x, int speeds[3]);
42 static void SetSpeedModscxx . . $ SetSpeedMods(155ba40c2fe6fd3d).(SPEED_FACTORS *speed, int voiceSpeedF1, int wpm, int x);
43 static void SetSpeedMultipliercxx . . $ SetSpeedMultiplier(ce8f7825f8908cfa).(int *x, int *wpm);
44
45 extern int saved_parameterscxx . . $ saved_parameters.[];
46
47 // convert from words-per-minute to internal speed factor
48 // Use this to calibrate speed for wpm 80-450 (espeakRATE_MINIMUM - espeakRATE_MAXIMUM)
49 static const unsigned char speed_lookupcxx . . $ speed_lookup.[] = {
50 255, 255, 255, 255, 255, // 80
51 253, 249, 245, 242, 238, // 85
52 235, 232, 228, 225, 222, // 90
53 218, 216, 213, 210, 207, // 95
54 204, 201, 198, 196, 193, // 100
55 191, 188, 186, 183, 181, // 105
56 179, 176, 174, 172, 169, // 110
57 168, 165, 163, 161, 159, // 115
58 158, 155, 153, 152, 150, // 120
59 148, 146, 145, 143, 141, // 125
60 139, 137, 136, 135, 133, // 130
61 131, 130, 129, 127, 126, // 135
62 124, 123, 122, 120, 119, // 140
63 118, 117, 115, 114, 113, // 145
64 112, 111, 110, 109, 107, // 150
65 106, 105, 104, 103, 102, // 155
66 101, 100, 99, 98, 97, // 160
67 96, 95, 94, 93, 92, // 165
68 91, 90, 89, 89, 88, // 170
69 87, 86, 85, 84, 83, // 175
70 82, 82, 81, 80, 80, // 180
71 79, 78, 77, 76, 76, // 185
72 75, 75, 74, 73, 72, // 190
73 71, 71, 70, 69, 69, // 195
74 68, 67, 67, 66, 66, // 200
75 65, 64, 64, 63, 62, // 205
76 62, 61, 61, 60, 59, // 210
77 59, 58, 58, 57, 57, // 215
78 56, 56, 55, 54, 54, // 220
79 53, 53, 52, 52, 52, // 225
80 51, 50, 50, 49, 49, // 230
81 48, 48, 47, 47, 46, // 235
82 46, 46, 45, 45, 44, // 240
83 44, 44, 43, 43, 42, // 245
84 41, 40, 40, 40, 39, // 250
85 39, 39, 38, 38, 38, // 255
86 37, 37, 37, 36, 36, // 260
87 35, 35, 35, 35, 34, // 265
88 34, 34, 33, 33, 33, // 270
89 32, 32, 31, 31, 31, // 275
90 30, 30, 30, 29, 29, // 280
91 29, 29, 28, 28, 27, // 285
92 27, 27, 27, 26, 26, // 290
93 26, 26, 25, 25, 25, // 295
94 24, 24, 24, 24, 23, // 300
95 23, 23, 23, 22, 22, // 305
96 22, 21, 21, 21, 21, // 310
97 20, 20, 20, 20, 19, // 315
98 19, 19, 18, 18, 17, // 320
99 17, 17, 16, 16, 16, // 325
100 16, 16, 16, 15, 15, // 330
101 15, 15, 14, 14, 14, // 335
102 13, 13, 13, 12, 12, // 340
103 12, 12, 11, 11, 11, // 345
104 11, 10, 10, 10, 9, // 350
105 9, 9, 8, 8, 8, // 355
106 };
107
108 // speed_factor1 adjustments for speeds 350 to 374: pauses
109 static const unsigned char pause_factor_350cxx . . $ pause_factor_350.[] = {
110 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, // 350
111 21, 20, 20, 19, 19, 18, 17, 16, 15, 15, // 360
112 15, 15, 15, 15, 15 // 370
113 };
114
115 // wav_factor adjustments for speeds 350 to 450
116 // Use this to calibrate speed for wpm 350-450
117 static const unsigned char wav_factor_350cxx . . $ wav_factor_350.[] = {
118 120, 121, 120, 119, 119, // 350
119 118, 118, 117, 116, 116, // 355
120 115, 114, 113, 112, 112, // 360
121 111, 111, 110, 109, 108, // 365
122 107, 106, 106, 104, 103, // 370
123 103, 102, 102, 102, 101, // 375
124 101, 99, 98, 98, 97, // 380
125 96, 96, 95, 94, 93, // 385
126 91, 90, 91, 90, 89, // 390
127 88, 86, 85, 86, 85, // 395
128 85, 84, 82, 81, 80, // 400
129 79, 77, 78, 78, 76, // 405
130 77, 75, 75, 74, 73, // 410
131 71, 72, 70, 69, 69, // 415
132 69, 67, 65, 64, 63, // 420
133 63, 63, 61, 61, 59, // 425
134 59, 59, 58, 56, 57, // 430
135 58, 56, 54, 53, 52, // 435
136 52, 53, 52, 52, 50, // 440
137 48, 47, 47, 45, 46, // 445
138 45 // 450
139 };
140
141 static int len_speedscxx . . $ len_speeds.[3] = { 130, 121, 118 };
142
143 void SetSpeedcxx . . $ SetSpeed(d4f767463ce0a6b3).(int control)
144 {
145 int x;
146 int wpm;
147
148 speed.min_sample_len = espeakRATE_MAXIMUMcxx . . $ `external/espeak/speak_lib.h:84:9`!;
149 speed.lenmod_factor = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change
150 speed.lenmod2_factor = 100;
151
152 wpm = embedded_value[EMBED_Scxx . . $ `external/espeak/synthesize.h:64:9`!];
153 if (control == 2)
154 wpm = embedded_value[EMBED_S2cxx . . $ `external/espeak/synthesize.h:70:9`!];
155
156 speed.min_pause = 5;
157
158 #if USE_LIBSONIC
159 int wpm_value = wpm;
160
161 if (voice->speed_percent > 0)
162 wpm = (wpm * voice->speed_percent)/100;
163
164 if (control & 2)
165 DoSonicSpeed(1 * 1024);
166 if ((wpm_value >= espeakRATE_MAXIMUM) || ((wpm_value > speed.fast_settings) && (wpm > 350))) {
167 int wpm2;
168 wpm2 = wpm;
169 wpm = espeakRATE_NORMAL;
170
171 // set special eSpeak speed parameters for Sonic use
172 // The eSpeak output will be speeded up by at least x2
173 x = 73;
174 if (control & 1) {
175 len_speeds[0] = (x * voice->speedf1)/256;
176 len_speeds[1] = (x * voice->speedf2)/256;
177 len_speeds[2] = (x * voice->speedf3)/256;
178 }
179 if (control & 2) {
180 double sonic;
181 sonic = ((double)wpm2)/wpm;
182 DoSonicSpeed((int)(sonic * 1024));
183 speed.pause_factor = 85;
184 speed.clause_pause_factor = espeakRATE_MINIMUM;
185 speed.min_pause = 22;
186 speed.min_sample_len = espeakRATE_MAXIMUM*2;
187 speed.wav_factor = 211;
188 speed.lenmod_factor = 210;
189 speed.lenmod2_factor = 170;
190 }
191 return;
192 }
193
194 #else
195 if (voice->speed_percent > 0)
196 wpm = (wpm * voice->speed_percent)/100;
197 #endif
198
199 SetSpeedMultipliercxx . . $ SetSpeedMultiplier(ce8f7825f8908cfa).(&x, &wpm);
200
201 if (control & 1) {
202 SetSpeedFactorscxx . . $ SetSpeedFactors(a401a204ccd10ded).(voice, x, len_speedscxx . . $ len_speeds.);
203 }
204
205 if (control & 2) {
206 SetSpeedModscxx . . $ SetSpeedMods(155ba40c2fe6fd3d).(&speed, voice->speedf1, wpm, x);
207 }
208 }
209
210 static void SetSpeedMultipliercxx . . $ SetSpeedMultiplier(ce8f7825f8908cfa).(int *x, int *wpm) {
211 int wpm2;
212
213 if (*wpm > espeakRATE_MAXIMUMcxx . . $ `external/espeak/speak_lib.h:84:9`!)
214 *wpm = espeakRATE_MAXIMUMcxx . . $ `external/espeak/speak_lib.h:84:9`!;
215
216 wpm2 = *wpm;
217 if (*wpm > 359) wpm2 = 359;
218 if (*wpm < espeakRATE_MINIMUMcxx . . $ `external/espeak/speak_lib.h:83:9`!) {
219 wpm2 = espeakRATE_MINIMUMcxx . . $ `external/espeak/speak_lib.h:83:9`!;
220 }
221
222 *x = speed_lookupcxx . . $ speed_lookup.[wpm2-espeakRATE_MINIMUMcxx . . $ `external/espeak/speak_lib.h:83:9`!];
223
224 if (*wpm >= 380)
225 *x = 7;
226 if (*wpm >= 400)
227 *x = 6;
228 }
229
230 static void SetSpeedFactorscxx . . $ SetSpeedFactors(a401a204ccd10ded).(voice_t *voicet, int x, int speeds[3]) {
231 // set speed factors for different syllable positions within a word
232 // these are used in CalcLengths()
233 speeds[0] = (x * voicet->speedf1)/256;
234 speeds[1] = (x * voicet->speedf2)/256;
235 speeds[2] = (x * voicet->speedf3)/256;
236
237 if (x <= 7) {
238 speeds[0] = x;
239 speeds[1] = speeds[2] = x - 1;
240 }
241 }
242
243 static void SetSpeedModscxx . . $ SetSpeedMods(155ba40c2fe6fd3d).(SPEED_FACTORS *speedf, int voiceSpeedF1, int wpm, int x) {
244 // these are used in synthesis file
245
246 if (wpm > 350) {
247 speedf->lenmod_factor = 85 - (wpm - 350) / 3;
248 speedf->lenmod2_factor = 60 - (wpm - 350) / 8;
249 } else if (wpm > 250) {
250 speedf->lenmod_factor = 110 - (wpm - 250)/4;
251 speedf->lenmod2_factor = 110 - (wpm - 250)/2;
252 }
253
254
255 int s1 = (x * voiceSpeedF1)/256;
256
257 if (wpm >= 170)
258 speedf->wav_factor = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds
259 else
260 speedf->wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm
261
262 if (wpm >= 350)
263 speedf->wav_factor = wav_factor_350cxx . . $ wav_factor_350.[wpm-350];
264
265 if (wpm >= 390) {
266 speedf->min_sample_len = espeakRATE_MAXIMUMcxx . . $ `external/espeak/speak_lib.h:84:9`! - (wpm - 400)/2;
267 if (wpm > 440)
268 speedf->min_sample_len = 420 - (wpm - 440);
269 }
270
271 speedf->pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length
272 speedf->clause_pause_factor = 0;
273
274 if (wpm > 430)
275 speedf->pause_factor = 12;
276 else if (wpm > 400)
277 speedf->pause_factor = 13;
278 else if (wpm > 374)
279 speedf->pause_factor = 14;
280 else if (wpm > 350)
281 speedf->pause_factor = pause_factor_350cxx . . $ pause_factor_350.[wpm - 350];
282
283 if (speedf->clause_pause_factor == 0) {
284 // restrict the reduction of pauses between clauses
285 if ((speedf->clause_pause_factor = speedf->pause_factor) < 16)
286 speedf->clause_pause_factor = 16;
287 }
288 }
289
290 espeak_ng_STATUS SetParametercxx . . $ SetParameter(ecd4a0349528f191).(int parameter, int value, int relative)
291 {
292 // parameter: reset-all, amp, pitch, speed, linelength, expression, capitals, number grouping
293 // relative 0=absolute 1=relative
294
295 int new_value = value;
296 // extern const int param_defaults[N_SPEECH_PARAM];
297
298 if (relative) {
299 if (parameter < 5) {
300 int default_value;
301 default_value = param_defaultscxx . . $ param_defaults.[parameter];
302 new_value = default_value + (default_value * value)/100;
303 }
304 }
305 param_stack[0].parameter[parameter] = new_value;
306 saved_parameterscxx . . $ saved_parameters.[parameter] = new_value;
307
308 switch (parameter)
309 {
310 case espeakRATEcxx . . $ espeakRATE.:
311 embedded_value[EMBED_Scxx . . $ `external/espeak/synthesize.h:64:9`!] = new_value;
312 embedded_value[EMBED_S2cxx . . $ `external/espeak/synthesize.h:70:9`!] = new_value;
313 SetSpeedcxx . . $ SetSpeed(d4f767463ce0a6b3).(3);
314 break;
315 case espeakVOLUMEcxx . . $ espeakVOLUME.:
316 embedded_value[EMBED_Acxx . . $ `external/espeak/synthesize.h:65:9`!] = new_value;
317 GetAmplitude();
318 break;
319 case espeakPITCHcxx . . $ espeakPITCH.:
320 if (new_value > 99) new_value = 99;
321 if (new_value < 0) new_value = 0;
322 embedded_value[EMBED_Pcxx . . $ `external/espeak/synthesize.h:63:9`!] = new_value;
323 break;
324 case espeakRANGEcxx . . $ espeakRANGE.:
325 if (new_value > 99) new_value = 99;
326 embedded_value[EMBED_Rcxx . . $ `external/espeak/synthesize.h:66:9`!] = new_value;
327 break;
328 case espeakLINELENGTHcxx . . $ espeakLINELENGTH.:
329 option_linelength = new_value;
330 break;
331 case espeakWORDGAPcxx . . $ espeakWORDGAP.:
332 option_wordgap = new_value;
333 break;
334 case espeakINTONATIONcxx . . $ espeakINTONATION.:
335 if ((new_value & 0xff) != 0)
336 translator->langopts.intonation_group = new_value & 0xff;
337 option_tone_flags = new_value;
338 break;
339 case espeakSSML_BREAK_MULcxx . . $ espeakSSML_BREAK_MUL.:
340 break;
341 default:
342 return static_cast<espeak_ng_STATUS> (EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!);
343 }
344 return static_cast<espeak_ng_STATUS> (ENS_OK);
345 }
346
347 static void DoEmbedded2cxx . . $ DoEmbedded2(11b0e290e57a7e53).(int *embix)
348 {
349 // There were embedded commands in the text at this point
350
351 unsigned int word;
352
353 do {
354 word = embedded_list[(*embix)++];
355
356 if ((word & 0x1f) == EMBED_Scxx . . $ `external/espeak/synthesize.h:64:9`!) {
357 // speed
358 SetEmbedded(word & 0x7f, word >> 8); // adjusts embedded_value[EMBED_S]
359 SetSpeedcxx . . $ SetSpeed(d4f767463ce0a6b3).(1);
360 }
361 } while ((word & 0x80) == 0);
362 }
363
364 void CalcLengthscxx . . $ CalcLengths(801a8dd91605e066).(Translator *tr)
365 {
366 int ix;
367 int ix2;
368 PHONEME_LIST *prev;
369 PHONEME_LIST *next;
370 PHONEME_LIST *next2;
371 PHONEME_LIST *next3;
372 PHONEME_LIST *p;
373 PHONEME_LIST *p2;
374
375 static int more_syllables = 0;
376 bool pre_sonorant = false;
377 bool pre_voiced = false;
378 int last_pitch = 0;
379 int pitch_start;
380 int length_mod;
381
382 int next2type;
383 int len;
384 int env2;
385 int end_of_clause;
386 int embedded_ix = 0;
387 int min_drop;
388 int pitch1;
389
390 int tone_mod;
391 const unsigned char *pitch_env = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
392 PHONEME_DATA phdata_tone;
393
394
395 for (ix = 1; ix < n_phoneme_list; ix++) {
396 int stress;
397 int emphasized;
398
399 prev = &phoneme_list[ix-1];
400 p = &phoneme_list[ix];
401 stress = p->stresslevel & 0x7;
402 emphasized = p->stresslevel & 0x8;
403
404 next = &phoneme_list[ix+1];
405
406 if (p->synthflags & SFLAG_EMBEDDEDcxx . . $ `external/espeak/synthesize.h:53:9`!)
407 DoEmbedded2cxx . . $ DoEmbedded2(11b0e290e57a7e53).(&embedded_ix);
408
409 int type;
410 type = p->type;
411 if (p->synthflags & SFLAG_SYLLABLEcxx . . $ `external/espeak/synthesize.h:54:9`!)
412 type = phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!;
413
414 switch (type)
415 {
416 case phPAUSEcxx . . $ `external/espeak/phoneme.h:132:9`!:
417 last_pitch = 0;
418 break;
419 case phSTOPcxx . . $ `external/espeak/phoneme.h:136:9`!:
420 last_pitch = 0;
421 if (prev->type == phFRICATIVEcxx . . $ `external/espeak/phoneme.h:138:9`!)
422 p->prepause = 25;
423 else if ((more_syllables > 0) || (stress < 4))
424 p->prepause = 48;
425 else
426 p->prepause = 60;
427
428 if (prev->type == phSTOPcxx . . $ `external/espeak/phoneme.h:136:9`!)
429 p->prepause = 60;
430
431 if ((tr->langopts.word_gap & 0x10) && (p->newword))
432 p->prepause = 60;
433
434 if (p->ph->phflags & phLENGTHENSTOPcxx . . $ `external/espeak/phoneme.h:190:9`!)
435 p->prepause += 30;
436
437 if (p->synthflags & SFLAG_LENGTHENcxx . . $ `external/espeak/synthesize.h:55:9`!)
438 p->prepause += tr->langopts.long_stop;
439 break;
440 case phVFRICATIVEcxx . . $ `external/espeak/phoneme.h:139:9`!:
441 case phFRICATIVEcxx . . $ `external/espeak/phoneme.h:138:9`!:
442 if (p->newword) {
443 if ((prev->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) && (p->ph->phflags & phNOPAUSEcxx . . $ `external/espeak/phoneme.h:192:9`!)) {
444 } else
445 p->prepause = 15;
446 }
447
448 if (next->type == phPAUSEcxx . . $ `external/espeak/phoneme.h:132:9`! && prev->type == phNASALcxx . . $ `external/espeak/phoneme.h:140:9`! && !(p->ph->phflags&phVOICELESScxx . . $ `external/espeak/phoneme.h:181:9`!))
449 p->prepause = 25;
450
451 if (prev->ph->phflags & phBRKAFTERcxx . . $ `external/espeak/phoneme.h:187:9`!)
452 p->prepause = 30;
453
454 if ((tr->langopts.word_gap & 0x10) && (p->newword))
455 p->prepause = 30;
456
457 if ((p->ph->phflags & phSIBILANTcxx . . $ `external/espeak/phoneme.h:183:9`!) && next->type == phSTOPcxx . . $ `external/espeak/phoneme.h:136:9`! && !next->newword) {
458 if (prev->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!)
459 p->length = 200; // ?? should do this if it's from a prefix
460 else
461 p->length = 150;
462 } else
463 p->length = 256;
464
465 if (type == phVFRICATIVEcxx . . $ `external/espeak/phoneme.h:139:9`!) {
466 if (next->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!)
467 pre_voiced = true;
468 if ((prev->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) || (prev->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!))
469 p->length = (255 + prev->length)/2;
470 }
471 break;
472 case phVSTOPcxx . . $ `external/espeak/phoneme.h:137:9`!:
473 if (prev->type == phVFRICATIVEcxx . . $ `external/espeak/phoneme.h:139:9`! || prev->type == phFRICATIVEcxx . . $ `external/espeak/phoneme.h:138:9`! || (prev->ph->phflags & phSIBILANTcxx . . $ `external/espeak/phoneme.h:183:9`!) || (prev->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!))
474 p->prepause = 30;
475
476 if (next->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`! || next->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!) {
477 if ((next->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) || !next->newword)
478 pre_voiced = true;
479
480 p->prepause = 40;
481
482 if (prev->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) {
483 p->prepause = 0; // use murmur instead to link from the preceding vowel
484 } else if (prev->type == phPAUSEcxx . . $ `external/espeak/phoneme.h:132:9`!) {
485 // reduce by the length of the preceding pause
486 if (prev->length < p->prepause)
487 p->prepause -= prev->length;
488 else
489 p->prepause = 0;
490 } else if (p->newword == 0) {
491 if (prev->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!)
492 p->prepause = 20;
493 if (prev->type == phNASALcxx . . $ `external/espeak/phoneme.h:140:9`!)
494 p->prepause = 12;
495
496 if (prev->type == phSTOPcxx . . $ `external/espeak/phoneme.h:136:9`! && !(prev->ph->phflags & phVOICELESScxx . . $ `external/espeak/phoneme.h:181:9`!))
497 p->prepause = 0;
498 }
499 }
500 if ((tr->langopts.word_gap & 0x10) && (p->newword) && (p->prepause < 20))
501 p->prepause = 20;
502 break;
503 case phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!:
504 case phNASALcxx . . $ `external/espeak/phoneme.h:140:9`!:
505 p->amp = tr->stress_amps[0]; // unless changed later
506 p->length = 256; // TEMPORARY
507
508 if (p->newword) {
509 if (prev->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!)
510 p->prepause = 25;
511 if (prev->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) {
512 if (!(p->ph->phflags & phNOPAUSEcxx . . $ `external/espeak/phoneme.h:192:9`!))
513 p->prepause = 12;
514 }
515 }
516
517 if (next->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!)
518 pre_sonorant = true;
519 else {
520 p->pitch2 = last_pitch;
521
522 if ((prev->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) || (prev->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!)) {
523 p->length = prev->length;
524
525 if (p->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!)
526 p->length = len_speedscxx . . $ len_speeds.[0];
527
528 if (next->type == phVSTOPcxx . . $ `external/espeak/phoneme.h:137:9`!)
529 p->length = (p->length * 160)/100;
530 if (next->type == phVFRICATIVEcxx . . $ `external/espeak/phoneme.h:139:9`!)
531 p->length = (p->length * 120)/100;
532 } else {
533 for (ix2 = ix; ix2 < n_phoneme_list; ix2++) {
534 if (phoneme_list[ix2].type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) {
535 p->pitch2 = phoneme_list[ix2].pitch2;
536 break;
537 }
538 }
539 }
540
541 p->pitch1 = p->pitch2-16;
542 if (p->pitch2 < 16)
543 p->pitch1 = 0;
544 p->env = PITCHfallcxx . . $ `external/espeak/synthesize.h:447:9`!;
545 pre_voiced = false;
546 }
547 break;
548 case phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!:
549 min_drop = 0;
550 next2 = &phoneme_list[ix+2];
551 next3 = &phoneme_list[ix+3];
552
553 if (stress > 7) stress = 7;
554
555 if (stress <= 1)
556 stress = stress ^ 1; // swap diminished and unstressed (until we swap stress_amps,stress_lengths in tr_languages)
557 if (pre_sonorant)
558 p->amp = tr->stress_amps[stress]-1;
559 else
560 p->amp = tr->stress_amps[stress];
561
562 if (emphasized)
563 p->amp = 25;
564
565 if (ix >= (n_phoneme_list-3)) {
566 // last phoneme of a clause, limit its amplitude
567 if (p->amp > tr->langopts.param[LOPT_MAXAMP_EOCcxx . . $ `external/espeak/translate.h:315:9`!])
568 p->amp = tr->langopts.param[LOPT_MAXAMP_EOCcxx . . $ `external/espeak/translate.h:315:9`!];
569 }
570
571 // is the last syllable of a word ?
572 more_syllables = 0;
573 end_of_clause = 0;
574 for (p2 = p+1; p2->newword == 0; p2++) {
575 if ((p2->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) && !(p2->ph->phflags & phNONSYLLABICcxx . . $ `external/espeak/phoneme.h:188:9`!))
576 more_syllables++;
577
578 if (p2->ph->code == phonPAUSE_CLAUSEcxx . . $ `external/espeak/phoneme.h:224:9`!)
579 end_of_clause = 2;
580 }
581 if (p2->ph->code == phonPAUSE_CLAUSEcxx . . $ `external/espeak/phoneme.h:224:9`!)
582 end_of_clause = 2;
583
584 if ((p2->newword & PHLIST_END_OF_CLAUSEcxx . . $ `external/espeak/synthesize.h:184:9`!) && (more_syllables == 0))
585 end_of_clause = 2;
586
587 // calc length modifier
588 if ((next->ph->code == phonPAUSE_VSHORTcxx . . $ `external/espeak/phoneme.h:220:9`!) && (next2->type == phPAUSEcxx . . $ `external/espeak/phoneme.h:132:9`!)) {
589 // if PAUSE_VSHORT is followed by a pause, then use that
590 next = next2;
591 next2 = next3;
592 next3 = &phoneme_list[ix+4];
593 }
594
595 next2type = next2->ph->length_mod;
596 if (more_syllables == 0) {
597 if (next->newword || next2->newword) {
598 // don't use 2nd phoneme over a word boundary, unless it's a pause
599 if (next2type != 1)
600 next2type = 0;
601 }
602
603 len = tr->langopts.length_mods0[next2type *10+ next->ph->length_mod];
604
605 if ((next->newword) && (tr->langopts.word_gap & 0x20)) {
606 // consider as a pause + first phoneme of the next word
607 length_mod = (len + tr->langopts.length_mods0[next->ph->length_mod *10+ 1])/2;
608 } else
609 length_mod = len;
610 } else {
611 length_mod = tr->langopts.length_mods[next2type *10+ next->ph->length_mod];
612
613 if ((next->type == phNASALcxx . . $ `external/espeak/phoneme.h:140:9`!) && (next2->type == phSTOPcxx . . $ `external/espeak/phoneme.h:136:9`! || next2->type == phVSTOPcxx . . $ `external/espeak/phoneme.h:137:9`!) && (next3->ph->phflags & phVOICELESScxx . . $ `external/espeak/phoneme.h:181:9`!))
614 length_mod -= 15;
615 }
616
617 if (more_syllables == 0)
618 length_mod *= len_speedscxx . . $ len_speeds.[0];
619 else if (more_syllables == 1)
620 length_mod *= len_speedscxx . . $ len_speeds.[1];
621 else
622 length_mod *= len_speedscxx . . $ len_speeds.[2];
623
624 length_mod = length_mod / 128;
625
626 if (length_mod < 8)
627 length_mod = 8; // restrict how much lengths can be reduced
628
629 if (stress >= 7) {
630 // tonic syllable, include a constant component so it doesn't decrease directly with speed
631 length_mod += tr->langopts.lengthen_tonic;
632 if (emphasized)
633 length_mod += (tr->langopts.lengthen_tonic/2);
634 } else if (emphasized)
635 length_mod += tr->langopts.lengthen_tonic;
636
637 if ((len = tr->stress_lengths[stress]) == 0)
638 len = tr->stress_lengths[6];
639
640 length_mod = length_mod * len;
641
642 if (p->tone_ph != 0) {
643 if ((tone_mod = phoneme_tab[p->tone_ph]->std_length) > 0) {
644 // a tone phoneme specifies a percentage change to the length
645 length_mod = (length_mod * tone_mod) / 100;
646 }
647 }
648
649 if ((end_of_clause == 2) && !(tr->langopts.stress_flags & S_NO_EOC_LENGTHENcxx . . $ `external/espeak/translate.h:425:9`!)) {
650 // this is the last syllable in the clause, lengthen it - more for short vowels
651 len = (p->ph->std_length * 2);
652 if (tr->langopts.stress_flags & S_EO_CLAUSE1cxx . . $ `external/espeak/translate.h:415:9`!)
653 len = 200; // don't lengthen short vowels more than long vowels at end-of-clause
654 length_mod = length_mod * (256 + (280 - len)/3)/256;
655 }
656
657 if (length_mod > tr->langopts.max_lengthmod*len_speedscxx . . $ len_speeds.[0]) {
658 // limit the vowel length adjustment for some languages
659 length_mod = (tr->langopts.max_lengthmod*len_speedscxx . . $ len_speeds.[0]);
660 }
661
662 length_mod = length_mod / 128;
663
664 if (p->type != phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) {
665 length_mod = 256; // syllabic consonant
666 min_drop = 16;
667 }
668 p->length = length_mod;
669
670 if (p->env >= (N_ENVELOPE_DATAcxx . . $ `external/espeak/synthesize.h:449:9`!-1)) {
671 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "espeak: Bad intonation data\n");
672 p->env = 0;
673 }
674
675 // pre-vocalic part
676 // set last-pitch
677 env2 = p->env + 1; // version for use with preceding semi-vowel
678
679 if (p->tone_ph != 0) {
680 InterpretPhoneme2(p->tone_ph, &phdata_tone);
681 pitch_env = GetEnvelope(phdata_tone.pitch_env);
682 } else
683 pitch_env = envelope_data[env2];
684
685 pitch_start = p->pitch1 + ((p->pitch2-p->pitch1)*pitch_env[0])/256;
686
687 if (pre_sonorant || pre_voiced) {
688 // set pitch for pre-vocalic part
689 if (pitch_start == 255)
690 last_pitch = pitch_start; // pitch is not set
691
692 if (pitch_start - last_pitch > 16)
693 last_pitch = pitch_start - 16;
694
695 prev->pitch1 = last_pitch;
696 prev->pitch2 = pitch_start;
697 if (last_pitch < pitch_start) {
698 prev->env = PITCHrisecxx . . $ `external/espeak/synthesize.h:448:9`!;
699 p->env = env2;
700 } else
701 prev->env = PITCHfallcxx . . $ `external/espeak/synthesize.h:447:9`!;
702
703 prev->length = length_mod;
704
705 prev->amp = p->amp;
706 if ((prev->type != phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!) && (prev->amp > 18))
707 prev->amp = 18;
708 }
709
710 // vowel & post-vocalic part
711 next->synthflags &= ~SFLAG_SEQCONTINUEcxx . . $ `external/espeak/synthesize.h:52:9`!;
712 if (next->type == phNASALcxx . . $ `external/espeak/phoneme.h:140:9`! && next2->type != phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!)
713 next->synthflags |= SFLAG_SEQCONTINUEcxx . . $ `external/espeak/synthesize.h:52:9`!;
714
715 if (next->type == phLIQUIDcxx . . $ `external/espeak/phoneme.h:135:9`!) {
716 next->synthflags |= SFLAG_SEQCONTINUEcxx . . $ `external/espeak/synthesize.h:52:9`!;
717
718 if (next2->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!)
719 next->synthflags &= ~SFLAG_SEQCONTINUEcxx . . $ `external/espeak/synthesize.h:52:9`!;
720
721 if (next2->type != phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) {
722 if (next->ph->mnemonic == ('/'*256+'r'))
723 next->synthflags &= ~SFLAG_SEQCONTINUEcxx . . $ `external/espeak/synthesize.h:52:9`!;
724 }
725 }
726
727 if ((min_drop > 0) && ((p->pitch2 - p->pitch1) < min_drop)) {
728 pitch1 = p->pitch2 - min_drop;
729 if (pitch1 < 0)
730 pitch1 = 0;
731 p->pitch1 = pitch1;
732 }
733
734 last_pitch = p->pitch1 + ((p->pitch2-p->pitch1)*envelope_data[p->env][127])/256;
735 pre_sonorant = false;
736 pre_voiced = false;
737 break;
738 }
739 }
740 }
741 // Tables of the relative lengths of vowels, depending on the
742 // type of the two phonemes that follow
743 // indexes are the "length_mod" value for the following phonemes
744
745 // use this table if vowel is not the last in the word
746 static const unsigned char length_mods_encxx . . $ length_mods_en.[100] = {
747 // a , t s n d z r N <- next
748 100, 120, 100, 105, 100, 110, 110, 100, 95, 100, // a <- next2
749 105, 120, 105, 110, 125, 130, 135, 115, 125, 100, // ,
750 105, 120, 75, 100, 75, 105, 120, 85, 75, 100, // t
751 105, 120, 85, 105, 95, 115, 120, 100, 95, 100, // s
752 110, 120, 95, 105, 100, 115, 120, 100, 100, 100, // n
753 105, 120, 100, 105, 95, 115, 120, 110, 95, 100, // d
754 105, 120, 100, 105, 105, 122, 125, 110, 105, 100, // z
755 105, 120, 100, 105, 105, 122, 125, 110, 105, 100, // r
756 105, 120, 95, 105, 100, 115, 120, 110, 100, 100, // N
757 100, 120, 100, 100, 100, 100, 100, 100, 100, 100
758 };
759
760 // as above, but for the last syllable in a word
761 static const unsigned char length_mods_en0cxx . . $ length_mods_en0.[100] = {
762 // a , t s n d z r N <- next
763 100, 150, 100, 105, 110, 115, 110, 110, 110, 100, // a <- next2
764 105, 150, 105, 110, 125, 135, 140, 115, 135, 100, // ,
765 105, 150, 90, 105, 90, 122, 135, 100, 90, 100, // t
766 105, 150, 100, 105, 100, 122, 135, 100, 100, 100, // s
767 105, 150, 100, 105, 105, 115, 135, 110, 105, 100, // n
768 105, 150, 100, 105, 105, 122, 130, 120, 125, 100, // d
769 105, 150, 100, 105, 110, 122, 125, 115, 110, 100, // z
770 105, 150, 100, 105, 105, 122, 135, 120, 105, 100, // r
771 105, 150, 100, 105, 105, 115, 135, 110, 105, 100, // N
772 100, 100, 100, 100, 100, 100, 100, 100, 100, 100
773 };
774
775
776 static const unsigned char length_mods_equalcxx . . $ length_mods_equal.[100] = {
777 // a , t s n d z r N <- next
778 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // a <- next2
779 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // ,
780 110, 120, 100, 110, 100, 110, 110, 110, 100, 110, // t
781 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // s
782 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // n
783 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // d
784 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // z
785 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // r
786 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // N
787 110, 120, 100, 110, 110, 110, 110, 110, 110, 110
788 };
789
790 static const unsigned char *const length_mod_tabscxx . . $ length_mod_tabs.[6] = {
791 length_mods_encxx . . $ length_mods_en.,
792 length_mods_encxx . . $ length_mods_en., // 1
793 length_mods_en0cxx . . $ length_mods_en0., // 2
794 length_mods_equalcxx . . $ length_mods_equal., // 3
795 length_mods_equalcxx . . $ length_mods_equal., // 4
796 length_mods_equalcxx . . $ length_mods_equal. // 5
797 };
798
799 void SetLengthModscxx . . $ SetLengthMods(44ca618724cd7367).(Translator *tr, int value)
800 {
801 int value2;
802
803 tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabscxx . . $ length_mod_tabs.[value % 100];
804 if ((value2 = value / 100) != 0)
805 tr->langopts.length_mods0 = length_mod_tabscxx . . $ length_mod_tabs.[value2];
806 }