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

0, phonPAUSE_VSHORT, phonPAUSE_SHORT, phonPAUSE, phonPAUSE_LONG, phonGLOTTALSTOP, phonPAUSE_LONG, phonPAUSE_LONG 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 // Copy the phonemes list and perform any substitutions that are required for the
// current voice // current voice
return n_plist_out; 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 ix = 0;
int j; int j;
memset(&worddata, 0, sizeof(worddata)); memset(&worddata, 0, sizeof(worddata));
plist2 = ph_list2; plist2 = ph_list2;
phlist = phoneme_list; 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 ? // is the last word of the clause unstressed ?
max_stress = 0; 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 // start with the last phoneme (before the terminating pauses) and move backwards
if ((plist2[j].stresslevel & 0x7f) > max_stress) if ((plist2[j].stresslevel & 0x7f) > max_stress)
max_stress = plist2[j].stresslevel & 0x7f; max_stress = plist2[j].stresslevel & 0x7f;
delete_count = 0; delete_count = 0;
current_phoneme_tab = tr->phoneme_tab_ix; current_phoneme_tab = tr->phoneme_tab_ix;
int deleted_sourceix = -1; 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) if (current_phoneme_tab != tr->phoneme_tab_ix)
plist2[j].synthflags |= SFLAG_SWITCHED_LANG; plist2[j].synthflags |= SFLAG_SWITCHED_LANG;


} }


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


if ((regression = tr->langopts.param[LOPT_REGRESSIVE_VOICING]) != 0) { if ((regression = tr->langopts.param[LOPT_REGRESSIVE_VOICING]) != 0) {
// set consonant clusters to all voiced or all unvoiced // set consonant clusters to all voiced or all unvoiced
bool stop_propagation = false; bool stop_propagation = false;
voicing = 0; 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]; ph = phoneme_tab[plist2[j].phcode];
if (ph == NULL) if (ph == NULL)
continue; continue;
} }
} }


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);) { for (j = 0; (j < n_ph_list3) && (ix < N_PHONEME_LIST-3);) {
if (ph_list3[j].sourceix) { if (ph_list3[j].sourceix) {

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

#ifndef ESPEAK_NG_PHONEMELIST_H #ifndef ESPEAK_NG_PHONEMELIST_H
#define ESPEAK_NG_PHONEMELIST_H #define ESPEAK_NG_PHONEMELIST_H


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


#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #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 #endif



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

if (Eof() && ((word_count == 0) || (option_endpause == 0))) if (Eof() && ((word_count == 0) || (option_endpause == 0)))
clause_pause = 10; 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].ph = NULL; // recognize end of phoneme_list array, in Generate()
phoneme_list[N_PHONEME_LIST].sourceix = 1; phoneme_list[N_PHONEME_LIST].sourceix = 1;



Loading…
Cancel
Save