diff --git a/CHANGELOG.md b/CHANGELOG.md index 127acaf9..8dcf92a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/docs/voices.md b/docs/voices.md index 32438157..649e3189 100644 --- a/docs/voices.md +++ b/docs/voices.md @@ -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> diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index f9c4a060..99bef3e4 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -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; }