Browse Source

Revert "maintainability: pass n_ph_list2 and ph_list2 to MakePhonemeList() and SubstitutePhonemes() instead of using globals"

This reverts commit f0c345eb6a.

Fixes #824.
master
Juho Hiltunen 4 years ago
parent
commit
5f1a4f9cbd
3 changed files with 13 additions and 15 deletions
  1. 11
    8
      src/libespeak-ng/phonemelist.c
  2. 1
    6
      src/libespeak-ng/phonemelist.h
  3. 1
    1
      src/libespeak-ng/translate.c

+ 11
- 8
src/libespeak-ng/phonemelist.c View File

@@ -43,7 +43,10 @@ const unsigned char pause_phonemes[8] = {
0, phonPAUSE_VSHORT, phonPAUSE_SHORT, phonPAUSE, phonPAUSE_LONG, phonGLOTTALSTOP, phonPAUSE_LONG, phonPAUSE_LONG
};

static int SubstitutePhonemes(PHONEME_LIST *plist_out, int n_ph_list2, PHONEME_LIST2 *ph_list2)
extern int n_ph_list2;
extern PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes

static int SubstitutePhonemes(PHONEME_LIST *plist_out)
{
// Copy the phonemes list and perform any substitutions that are required for the
// current voice
@@ -109,7 +112,7 @@ static int SubstitutePhonemes(PHONEME_LIST *plist_out, int n_ph_list2, PHONEME_L
return n_plist_out;
}

void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n_ph_list2, PHONEME_LIST2 *ph_list2)
void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence)
{
int ix = 0;
int j;
@@ -143,11 +146,11 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n
memset(&worddata, 0, sizeof(worddata));
plist2 = ph_list2;
phlist = phoneme_list;
end_sourceix = plist2[*n_ph_list2 - 1].sourceix;
end_sourceix = plist2[n_ph_list2-1].sourceix;

// is the last word of the clause unstressed ?
max_stress = 0;
for (j = *n_ph_list2 - 3; j >= 0; j--) {
for (j = n_ph_list2-3; j >= 0; j--) {
// start with the last phoneme (before the terminating pauses) and move backwards
if ((plist2[j].stresslevel & 0x7f) > max_stress)
max_stress = plist2[j].stresslevel & 0x7f;
@@ -172,7 +175,7 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n
delete_count = 0;
current_phoneme_tab = tr->phoneme_tab_ix;
int deleted_sourceix = -1;
for (j = 0; j < *n_ph_list2; j++) {
for (j = 0; j < n_ph_list2; j++) {
if (current_phoneme_tab != tr->phoneme_tab_ix)
plist2[j].synthflags |= SFLAG_SWITCHED_LANG;

@@ -200,7 +203,7 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n
}

}
*n_ph_list2 -= delete_count;
n_ph_list2 -= delete_count;

if ((regression = tr->langopts.param[LOPT_REGRESSIVE_VOICING]) != 0) {
// set consonant clusters to all voiced or all unvoiced
@@ -209,7 +212,7 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n
bool stop_propagation = false;
voicing = 0;

for (j = *n_ph_list2 - 1; j >= 0; j--) {
for (j = n_ph_list2-1; j >= 0; j--) {
ph = phoneme_tab[plist2[j].phcode];
if (ph == NULL)
continue;
@@ -270,7 +273,7 @@ void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence, int *n
}
}

n_ph_list3 = SubstitutePhonemes(ph_list3, (int) *n_ph_list2, ph_list2) - 2;
n_ph_list3 = SubstitutePhonemes(ph_list3) - 2;

for (j = 0; (j < n_ph_list3) && (ix < N_PHONEME_LIST-3);) {
if (ph_list3[j].sourceix) {

+ 1
- 6
src/libespeak-ng/phonemelist.h View File

@@ -21,7 +21,6 @@
#ifndef ESPEAK_NG_PHONEMELIST_H
#define ESPEAK_NG_PHONEMELIST_H

#include "synthesize.h"
#include "translate.h"

#ifdef __cplusplus
@@ -33,11 +32,7 @@ extern "C"
}
#endif

void MakePhonemeList(Translator *tr,
int post_pause,
bool start_sentence,
int *n_ph_list2,
PHONEME_LIST2 *ph_list2);
void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence);

#endif


+ 1
- 1
src/libespeak-ng/translate.c View File

@@ -2719,7 +2719,7 @@ void TranslateClause(Translator *tr, int *tone_out, char **voice_change)
if (Eof() && ((word_count == 0) || (option_endpause == 0)))
clause_pause = 10;

MakePhonemeList(tr, clause_pause, new_sentence2, &n_ph_list2, ph_list2);
MakePhonemeList(tr, clause_pause, new_sentence2);
phoneme_list[N_PHONEME_LIST].ph = NULL; // recognize end of phoneme_list array, in Generate()
phoneme_list[N_PHONEME_LIST].sourceix = 1;


Loading…
Cancel
Save