From afb4fe75e278ee9afd6a4a5aee4aab97cd4f0642 Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Sun, 14 Jan 2018 14:46:57 +0200 Subject: [PATCH] fi: fix behaviour of S_2_TO_HEAVY (adding secondary stress) Stress flag S_2_TO_HEAVY is currently only used by finnish. Current behaviour skips adding secondary stress if the following syllable is heavy. The behaviour should be to skip adding secondary stress if the rest of the word (excluding last syllable) contains a heavy syllable. Source of grammar rule and examples of expected behaviour: http://scripta.kotus.fi/visk/sisallys.php?p=13 --- src/libespeak-ng/dictionary.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 1b43acea..6ee34fb2 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -1373,6 +1373,19 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, if ((stress == 3) && (stressflags & S_NO_AUTO_2)) continue; // don't use secondary stress + // don't put secondary stress on a light syllable if the rest of the word (excluding last syllable) contains a heavy syllable + if ((v > 1) && (stressflags & S_2_TO_HEAVY) && (syllable_weight[v] == 0)) { + bool skip = false; + for (int i = v; i < vowel_count - 1; i++) { + if (syllable_weight[i] > 0) { + skip = true; + break; + } + } + if (skip == true) + continue; + } + if ((v > 1) && (stressflags & S_2_TO_HEAVY) && (syllable_weight[v] == 0) && (syllable_weight[v+1] > 0)) { // don't put secondary stress on a light syllable which is followed by a heavy syllable continue;