1
/* utterance.c -- Utterance builder
3
* Copyright (C) 1990, 1991 Speech Research Laboratory, Minsk
4
* Copyright (C) 2005 Igor Poretsky <poretsky@mlbox.ru>
5
* Copyright (C) 2021 Boris Lobanov <lobbormef@gmail.com>
6
* Copyright (C) 2021 Alexander Ivanov <ivalex01@gmail.com>
8
* SPDX-License-Identifier: MIT
14
#include "soundscript.h"
15
#include "transcription.h"
19
static const uint8_t soundset1[] =
28
static const uint8_t soundset2[] =
30
10, 20, 20, 20, 70, 50,
31
60, 60, 40, 10, 20, 80,
32
50, 60, 10, 20, 30, 50,
33
60, 70, 10, 20, 30, 50,
34
60, 70, 20, 60, 10, 20,
35
20, 50, 60, 60, 30, 70
37
static const uint8_t soundset3[] =
42
static const uint8_t soundset4[] =
49
/* Local subroutines */
51
/* Put specified sound into the soundscript */
52
static void put_sound(soundscript_t *script, uint8_t sound, uint8_t stage)
54
script->sounds[script->length].id = sound;
55
script->sounds[script->length++].stage = stage;
61
/* Build utterance according to phonetic transcription */
62
void build_utterance(uint8_t *transcription, soundscript_t *script)
64
uint16_t i = TRANSCRIPTION_START;
66
uint8_t c = transcription[i];
68
while ((a < 44) && (i < TRANSCRIPTION_BUFFER_SIZE))
73
for (j = i; j < TRANSCRIPTION_BUFFER_SIZE; j++)
74
if (transcription[j] != 43)
76
if (transcription[j] < 43)
77
for (j++; j < TRANSCRIPTION_BUFFER_SIZE; j++)
78
if (transcription[j] > 42)
80
if ((transcription[j] == 53) || (transcription[j] == 54))
87
while (i < TRANSCRIPTION_BUFFER_SIZE)
95
while (i < TRANSCRIPTION_BUFFER_SIZE)
97
c = transcription[++i];
105
put_sound(script, 190, 2);
117
put_sound(script, 189, 2);
120
put_sound(script, a + 143, 2);
121
put_sound(script, a + 145, 3);
123
else if ((a < 40) || (a == 41) || (c > 5))
124
put_sound(script, a + 145, 2);
125
else put_sound(script, a + soundset4[c], 2);
129
put_sound(script, a + 143, 2);
134
if ((a < 23) && (c < 6))
135
put_sound(script, a + soundset3[c], 3);
136
else put_sound(script, a + 119, 3);
139
put_sound(script, a + soundset3[c], 3);
140
else put_sound(script, a + 119, 3);
142
else put_sound(script, a + 119, 3);
145
else put_sound(script, a + 119, 2);
150
put_sound(script, a + 99, 1);
151
if ((a != 10) || (transcription[i + 1] > 52) || ((c > 5) && (c < 44)))
153
put_sound(script, a + 117, 2);
155
put_sound(script, a + 99, 3);
157
else put_sound(script, 122, 2);
166
j = soundset2[b - 6];
170
else j = (a != 5) ? 95 : 99;
171
put_sound(script, a + j, 1);
174
if ((b > 5) && (b < 42))
176
j = soundset1[b - 6];
180
else j = (a != 5) ? 0 : 4;
181
put_sound(script, a + j, 2);
183
if ((b > 5) && (b < 42))
184
put_sound(script, a + soundset1[b - 6] + ((a != 5) ? 95 : 94), 3);
185
else put_sound(script, a + ((a != 5) ? 95 : 99), 3);
192
j = transcription[i + 1];
196
put_sound(script, a + soundset2[j - 6] + ((a != 5) ? 5 : 4), 4);
197
else put_sound(script, a + ((a != 5) ? 90 : 89), 4);
200
put_sound(script, a + ((a != 5) ? 95 : 99), 4);
203
put_sound(script, a + ((a != 5) ? 90 : 89), 4);
204
else put_sound(script, a + soundset2[c - 6] + ((a != 5) ? 5 : 4), 4);
206
else put_sound(script, a + ((a != 5) ? 90 : 89), 4);
209
put_sound(script, a + ((a != 5) ? 95 : 99), 4);
214
if (i >= TRANSCRIPTION_BUFFER_SIZE)
216
put_sound(script, a + 147, 2);