Browse Source

code cleanup: reduce code duplication with ReInterpretPhoneme().

Found with pmd-cpd scanner. The new function could probably be named better.
master
Juho Hiltunen 2 years ago
parent
commit
7c13683b68
1 changed files with 17 additions and 21 deletions
  1. 17
    21
      src/libespeak-ng/phonemelist.c

+ 17
- 21
src/libespeak-ng/phonemelist.c View File

@@ -41,6 +41,7 @@
#include "speech.h"

static void SetRegressiveVoicing(int regression, PHONEME_LIST2 *plist2, PHONEME_TAB *ph, Translator *tr);
static void ReInterpretPhoneme(PHONEME_TAB *ph, PHONEME_TAB *ph2, PHONEME_LIST *plist3, Translator *tr, PHONEME_DATA *phdata, WORD_PH_DATA *worddata);

static const unsigned char pause_phonemes[8] = {
0, phonPAUSE_VSHORT, phonPAUSE_SHORT, phonPAUSE, phonPAUSE_LONG, phonGLOTTALSTOP, phonPAUSE_LONG, phonPAUSE_LONG
@@ -314,16 +315,7 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence)
plist3->ph = ph;
plist3->phcode = alternative;

if (ph->type == phVOWEL) {
plist3->synthflags |= SFLAG_SYLLABLE;
if (ph2->type != phVOWEL)
plist3->stresslevel = 0; // change from non-vowel to vowel, make sure it's unstressed
} else
plist3->synthflags &= ~SFLAG_SYLLABLE;

// re-interpret the changed phoneme
// But it doesn't obey a second ChangePhoneme()
InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
ReInterpretPhoneme(ph, ph2, plist3, tr, &phdata, &worddata);
}

if ((alternative = phdata.pd_param[pd_CHANGEPHONEME]) > 0) {
@@ -336,16 +328,7 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence)
if (alternative == 1)
deleted = true; // NULL phoneme, discard
else {
if (ph->type == phVOWEL) {
plist3->synthflags |= SFLAG_SYLLABLE;
if (ph2->type != phVOWEL)
plist3->stresslevel = 0; // change from non-vowel to vowel, make sure it's unstressed
} else
plist3->synthflags &= ~SFLAG_SYLLABLE;

// re-interpret the changed phoneme
// But it doesn't obey a second ChangePhoneme()
InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
ReInterpretPhoneme(ph, ph2, plist3, tr, &phdata, &worddata);
}
}

@@ -594,4 +577,17 @@ static void SetRegressiveVoicing(int regression, PHONEME_LIST2 *plist2, PHONEME_
}
}
}
}
}

static void ReInterpretPhoneme(PHONEME_TAB *ph, PHONEME_TAB *ph2, PHONEME_LIST *plist3, Translator *tr, PHONEME_DATA *phdata, WORD_PH_DATA *worddata) {
if (ph->type == phVOWEL) {
plist3->synthflags |= SFLAG_SYLLABLE;
if (ph2->type != phVOWEL)
plist3->stresslevel = 0; // change from non-vowel to vowel, make sure it's unstressed
} else
plist3->synthflags &= ~SFLAG_SYLLABLE;

// re-interpret the changed phoneme
// But it doesn't obey a second ChangePhoneme()
InterpretPhoneme(tr, 0x100, plist3, phdata, worddata);
}

Loading…
Cancel
Save