code cleanup: move stressLength, stressAdd and stressAmp handling in LoadVoice()

From now on, stressLength must be set before stressAdd because
stressLength will overwrite any previous value. Usually stressLength is
set in a language file and stressAdd in a voice file.

Previously the order of the two commands didn't matter.
This commit is contained in:
Juho Hiltunen
2021-05-22 13:38:03 +03:00
parent 7c32085dcd
commit fb233a7b0c
3 changed files with 40 additions and 21 deletions
+2 -1
View File
@@ -11,8 +11,9 @@ The espeak-ng project is a fork of the espeak project.
* Add support for speechPlayer.
* Add more tests to check the various parts of espeak-ng.
* Various changes to clean up the codebase.
* Various changes to clean up the codebase (Juho Hiltunen)
* Restructure "option brackets" language option to "brackets" and "bracketsAnnounced".
* Restructure "stressLength" and "stressAdd" language option
* New Language option: "lowercaseSentence" for ending a sentence if a period is followed by a lower case letter.
* Added voice variants
* Renamed zh to cmn (Mandarin)
+3
View File
@@ -458,6 +458,9 @@ Eight integer parameters. These are added to the voice's corresponding
`stressLength` values. They are used in the voice variant files in
`espeak-ng-data/voices/!v` to give some variety. Negative values may be used.
Note that setting `stressLength` after `stressAdd` will overwrite this value.
`stressLength` must be set before `stressAdd`.
### stressAmp
stressAmp <8 integer values>
+35 -20
View File
@@ -491,9 +491,6 @@ voice_t *LoadVoice(const char *vname, int control)
int tone_only = control & 2;
bool language_set = false;
bool phonemes_set = false;
int stress_amps_set = 0;
int stress_lengths_set = 0;
int stress_add_set = 0;
int conditional_rules = 0;
char voicename[40];
@@ -506,8 +503,6 @@ voice_t *LoadVoice(const char *vname, int control)
char path_voices[sizeof(path_home)+12];
int dict_min = 0;
int stress_amps[8];
int stress_lengths[8];
int stress_add[8];
char names[8][40];
char name1[40];
@@ -673,15 +668,44 @@ voice_t *LoadVoice(const char *vname, int control)
voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch
}
break;
case V_STRESSLENGTH: // stressLength
stress_lengths_set = Read8Numbers(p, stress_lengths);
case V_STRESSLENGTH: {// stressLength
if (translator) {
int stress_lengths_set = 0;
int stress_lengths[8];
stress_lengths_set = Read8Numbers(p, stress_lengths);
for (ix = 0; ix < stress_lengths_set; ix++) {
translator->stress_lengths[ix] = stress_lengths[ix];
}
} else
fprintf(stderr, "Cannot set stressLength: language not set, or is invalid.\n");
break;
case V_STRESSAMP: // stressAmp
stress_amps_set = Read8Numbers(p, stress_amps);
}
case V_STRESSAMP: { // stressAmp
if (translator) {
int stress_amps_set = 0;
int stress_amps[8];
stress_amps_set = Read8Numbers(p, stress_amps);
for (ix = 0; ix < stress_amps_set; ix++) {
translator->stress_amps[ix] = stress_amps[ix];
}
} else
fprintf(stderr, "Cannot set stressAmp: language not set, or is invalid.\n");
break;
case V_STRESSADD: // stressAdd
stress_add_set = Read8Numbers(p, stress_add);
}
case V_STRESSADD: { // stressAdd
if (translator) {
int stress_add_set = 0;
stress_add_set = Read8Numbers(p, stress_add);
for (ix = 0; ix < stress_add_set; ix++) {
translator->stress_lengths[ix] += stress_add[ix];
}
} else
fprintf(stderr, "Cannot set stressAdd: language not set, or is invalid.\n");
break;
}
case V_INTONATION: // intonation
sscanf(p, "%d", &option_tone_flags);
if ((option_tone_flags & 0xff) != 0) {
@@ -899,15 +923,6 @@ voice_t *LoadVoice(const char *vname, int control)
voice->width[0] = (voice->width[0] * 105)/100;
// relative lengths of different stress syllables
for (ix = 0; ix < stress_lengths_set; ix++)
translator->stress_lengths[ix] = stress_lengths[ix];
for (ix = 0; ix < stress_add_set; ix++)
translator->stress_lengths[ix] += stress_add[ix];
for (ix = 0; ix < stress_amps_set; ix++) {
translator->stress_amps[ix] = stress_amps[ix];
}
return voice;
}