Browse Source

vi: Fix overflow due to lengthmod (#2103)

master
Samuel Thibault 5 months ago
parent
commit
d890919134
No account linked to committer's email address

+ 1
- 1
phsource/ph_vietnam View File

ELSE ELSE
Vowelout f1=3 f2=2300 300 400 f3=-200 80 len=40 rms=20 brk Vowelout f1=3 f2=2300 300 400 f3=-200 80 len=40 rms=20 brk
ENDIF ENDIF
lengthmod 12 // longer than 'n'
lengthmod 9 // longer than 'n'
IF thisPh(isWordEnd) THEN IF thisPh(isWordEnd) THEN
length 163 length 163
ENDIF ENDIF

+ 2
- 0
src/libespeak-ng/compiledata.c View File

#include <sys/stat.h> #include <sys/stat.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h>


#include <espeak-ng/espeak_ng.h> #include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
break; break;
case i_LENGTH_MOD: case i_LENGTH_MOD:
value = NextItem(ctx, tNUMBER); value = NextItem(ctx, tNUMBER);
assert(value < LENGTH_MOD_LIMIT);
ctx->phoneme_out->length_mod = value; ctx->phoneme_out->length_mod = value;
break; break;
case i_IPA_NAME: case i_IPA_NAME:

+ 4
- 4
src/libespeak-ng/setlengths.c View File

// indexes are the "length_mod" value for the following phonemes // indexes are the "length_mod" value for the following phonemes


// use this table if vowel is not the last in the word // use this table if vowel is not the last in the word
static const unsigned char length_mods_en[100] = {
static const unsigned char length_mods_en[LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT] = {
// a , t s n d z r N <- next // a , t s n d z r N <- next
100, 120, 100, 105, 100, 110, 110, 100, 95, 100, // a <- next2 100, 120, 100, 105, 100, 110, 110, 100, 95, 100, // a <- next2
105, 120, 105, 110, 125, 130, 135, 115, 125, 100, // , 105, 120, 105, 110, 125, 130, 135, 115, 125, 100, // ,
}; };


// as above, but for the last syllable in a word // as above, but for the last syllable in a word
static const unsigned char length_mods_en0[100] = {
static const unsigned char length_mods_en0[LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT] = {
// a , t s n d z r N <- next // a , t s n d z r N <- next
100, 150, 100, 105, 110, 115, 110, 110, 110, 100, // a <- next2 100, 150, 100, 105, 110, 115, 110, 110, 110, 100, // a <- next2
105, 150, 105, 110, 125, 135, 140, 115, 135, 100, // , 105, 150, 105, 110, 125, 135, 140, 115, 135, 100, // ,
}; };




static const unsigned char length_mods_equal[100] = {
static const unsigned char length_mods_equal[LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT] = {
// a , t s n d z r N <- next // a , t s n d z r N <- next
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // a <- next2 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // a <- next2
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // , 110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // ,
int value2; int value2;


tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100]; tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100];
if ((value2 = value / 100) != 0)
if ((value2 = value / (LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT)) != 0)
tr->langopts.length_mods0 = length_mod_tabs[value2]; tr->langopts.length_mods0 = length_mod_tabs[value2];
} }

+ 2
- 0
src/libespeak-ng/synthesize.h View File



#define i_StressLevel 0x800 #define i_StressLevel 0x800


#define LENGTH_MOD_LIMIT 10

typedef struct { typedef struct {
int pause_factor; int pause_factor;
int clause_pause_factor; int clause_pause_factor;

Loading…
Cancel
Save