From 8e13f7147c19465dfa445d744ba715009c2a1087 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sun, 19 Aug 2018 08:29:09 +0100 Subject: [PATCH] Add constants for use with PHONEME_LIST.newword. --- src/libespeak-ng/phonemelist.c | 6 +++--- src/libespeak-ng/setlengths.c | 2 +- src/libespeak-ng/synth_mbrola.c | 4 ++-- src/libespeak-ng/synthesize.c | 4 ++-- src/libespeak-ng/synthesize.h | 6 +++++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libespeak-ng/phonemelist.c b/src/libespeak-ng/phonemelist.c index cd0c8d79..1672fcfe 100644 --- a/src/libespeak-ng/phonemelist.c +++ b/src/libespeak-ng/phonemelist.c @@ -496,10 +496,10 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n if (plist3->sourceix != 0) { phlist[ix].sourceix = plist3->sourceix; - phlist[ix].newword = 1; // this phoneme is the start of a word + phlist[ix].newword = PHLIST_START_OF_WORD; if (start_sentence) { - phlist[ix].newword = 5; // start of sentence + start of word + phlist[ix].newword |= PHLIST_START_OF_SENTENCE; start_sentence = false; } } else @@ -523,7 +523,7 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n ix++; } } - phlist[ix].newword = 2; // end of clause + phlist[ix].newword = PHLIST_END_OF_CLAUSE; phlist[ix].phcode = phonPAUSE; phlist[ix].type = phPAUSE; // terminate with 2 Pause phonemes diff --git a/src/libespeak-ng/setlengths.c b/src/libespeak-ng/setlengths.c index f7d8b104..b16259a7 100644 --- a/src/libespeak-ng/setlengths.c +++ b/src/libespeak-ng/setlengths.c @@ -658,7 +658,7 @@ void CalcLengths(Translator *tr) if (p2->ph->code == phonPAUSE_CLAUSE) end_of_clause = 2; - if ((p2->newword & 2) && (more_syllables == 0)) + if ((p2->newword & PHLIST_END_OF_CLAUSE) && (more_syllables == 0)) end_of_clause = 2; // calc length modifier diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index 98f18266..7fa13a93 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -361,9 +361,9 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, bool resume, FILE *f_mb if (p->synthflags & SFLAG_EMBEDDED) DoEmbedded(&embedded_ix, p->sourceix); - if (p->newword & 4) + if (p->newword & PHLIST_START_OF_SENTENCE) DoMarker(espeakEVENT_SENTENCE, (p->sourceix & 0x7ff) + clause_start_char, 0, count_sentences); - if (p->newword & 1) + if (p->newword & PHLIST_START_OF_SENTENCE) DoMarker(espeakEVENT_WORD, (p->sourceix & 0x7ff) + clause_start_char, p->sourceix >> 11, clause_start_word + word_count++); name = GetMbrName(p, ph, ph_prev, ph_next, &name2, &len_percent, &control); diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 49f7cab6..b274ae42 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -1213,10 +1213,10 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume) sourceix = (p->sourceix & 0x7ff) + clause_start_char; - if (p->newword & 4) + if (p->newword & PHLIST_START_OF_SENTENCE) DoMarker(espeakEVENT_SENTENCE, sourceix, 0, count_sentences); // start of sentence - if (p->newword & 1) + if (p->newword & PHLIST_START_OF_WORD) DoMarker(espeakEVENT_WORD, sourceix, p->sourceix >> 11, clause_start_word + word_count++); // NOTE, this count doesn't include multiple-word pronunciations in *_list. eg (of a) } diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index bbddfbff..7d93cfa9 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -187,6 +187,10 @@ typedef struct { unsigned char tone_ph; // tone phoneme to use with this vowel } PHONEME_LIST2; +#define PHLIST_START_OF_WORD 1 +#define PHLIST_END_OF_CLAUSE 2 +#define PHLIST_START_OF_SENTENCE 4 + typedef struct { // The first section is a copy of PHONEME_LIST2 unsigned short synthflags; @@ -203,7 +207,7 @@ typedef struct { unsigned char prepause; unsigned char postpause; unsigned char amp; - unsigned char newword; // bit 0=start of word, bit 1=end of clause, bit 2=start of sentence + unsigned char newword; // bit flags, see PHLIST_(START|END)_OF_* unsigned char pitch1; unsigned char pitch2; unsigned char std_length;