Browse Source

Don't store the unused phoneme equivalence tables in the phoneme data files.

master
Reece H. Dunn 8 years ago
parent
commit
6a0ea584ea

+ 2
- 0
CHANGELOG.md View File

### 1.49.2 - (In Development) ### 1.49.2 - (In Development)


* Support describing all IPA phonemes in the phoneme tables. * Support describing all IPA phonemes in the phoneme tables.
* Removed support for phoneme equivalence tables. These were disabled in the
French and German language files.


updated languages: updated languages:



+ 0
- 1
src/libespeak-ng/compiledata.c View File

fputc(phoneme_tab_list2[ix].includes, f_phtab); fputc(phoneme_tab_list2[ix].includes, f_phtab);
fputc(0, f_phtab); fputc(0, f_phtab);
fputc(0, f_phtab); fputc(0, f_phtab);
Write4Bytes(f_phtab, phoneme_tab_list2[ix].equivalence_tables); // byte index into phondata for equivalence tables


fwrite(phoneme_tab_list2[ix].name, 1, N_PHONEME_TAB_NAME, f_phtab); fwrite(phoneme_tab_list2[ix].name, 1, N_PHONEME_TAB_NAME, f_phtab);



+ 0
- 1
src/libespeak-ng/phoneme.h View File

PHONEME_TAB *phoneme_tab_ptr; PHONEME_TAB *phoneme_tab_ptr;
int n_phonemes; int n_phonemes;
int includes; // also include the phonemes from this other phoneme table int includes; // also include the phonemes from this other phoneme table
int equivalence_tables; // lists of equivalent phonemes to match other languages, byte index into phondata
} PHONEME_TAB_LIST; } PHONEME_TAB_LIST;


// table of phonemes to be replaced with different phonemes, for the current voice // table of phonemes to be replaced with different phonemes, for the current voice

+ 1
- 3
src/libespeak-ng/synthdata.c View File

n_phonemes = p[0]; n_phonemes = p[0];
phoneme_tab_list[ix].n_phonemes = p[0]; phoneme_tab_list[ix].n_phonemes = p[0];
phoneme_tab_list[ix].includes = p[1]; phoneme_tab_list[ix].includes = p[1];
pw = (int *)p;
phoneme_tab_list[ix].equivalence_tables = Reverse4Bytes(pw[1]);
p += 8;
p += 4;
memcpy(phoneme_tab_list[ix].name, p, N_PHONEME_TAB_NAME); memcpy(phoneme_tab_list[ix].name, p, N_PHONEME_TAB_NAME);
p += N_PHONEME_TAB_NAME; p += N_PHONEME_TAB_NAME;
phoneme_tab_list[ix].phoneme_tab_ptr = (PHONEME_TAB *)p; phoneme_tab_list[ix].phoneme_tab_ptr = (PHONEME_TAB *)p;

+ 0
- 84
src/libespeak-ng/translate.c View File



extern char *phondata_ptr; extern char *phondata_ptr;


int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes)
{
// tr: the original language
// lang2: phoneme table number for the temporary language
// phonemes: the phonemes to be replaced

int ix;
int len;
char phon;
char *p;
unsigned char *pb;
char *eqlist;
char *p_out;
char *p_in;
int remove_stress = 0;
char phonbuf[N_WORD_PHONEMES];

// has a phoneme equivalence table been specified for this language pair?
if ((ix = phoneme_tab_list[tr->phoneme_tab_ix].equivalence_tables) == 0)
return 0;

pb = (unsigned char *)&phondata_ptr[ix];

for (;;) {
if (pb[0] == 0)
return 0; // table not found

if (pb[0] == lang2)
break;

len = (pb[2] << 8) + pb[3]; // size of this table in words
pb += (len * 4);
}
remove_stress = pb[1];

if (option_phonemes & espeakPHONEMES_TRACE) {
DecodePhonemes(phonemes, phonbuf);
fprintf(f_trans, "(%s) %s -> (%s) ", phoneme_tab_list[lang2].name, phonbuf, phoneme_tab_list[tr->phoneme_tab_ix].name);
}

p_in = phonemes;
eqlist = (char *)&pb[8];
p_out = phonbuf;

while ((phon = *p_in++) != 0) {
if (remove_stress && ((phon & 0xff) < phonSTRESS_PREV))
continue; // remove stress marks

// is there a translation for this phoneme code?
p = eqlist;
while (*p != 0) {
len = strlen(&p[1]);
if (*p == phon) {
strcpy(p_out, &p[1]);
p_out += len;
break;
}
p += (len + 2);
}
if (*p == 0) {
// no translation found
*p_out++ = phon;
}
}
*p_out = 0;

if (remove_stress)
SetWordStress(tr, phonbuf, NULL, -1, 0);

strcpy(phonemes, phonbuf);

if (option_phonemes & espeakPHONEMES_TRACE) {
SelectPhonemeTable(tr->phoneme_tab_ix);
DecodePhonemes(phonemes, phonbuf);
fprintf(f_trans, "%s\n\n", phonbuf);
}
return 1;
}

int TranslateWord(Translator *tr, char *word_start, WORD_TAB *wtab, char *word_out) int TranslateWord(Translator *tr, char *word_start, WORD_TAB *wtab, char *word_out)
{ {
// word1 is terminated by space (0x20) character // word1 is terminated by space (0x20) character
p[2] = 0; p[2] = 0;
} }


if (ChangeEquivalentPhonemes(tr, switch_phonemes, (char *)p)) {
// Phonemes have been converted from the foreign language to the native language
switch_phonemes = -1;
}

if (switch_phonemes == -1) { if (switch_phonemes == -1) {
strcpy(dictionary_name, old_dictionary_name); strcpy(dictionary_name, old_dictionary_name);
SelectPhonemeTable(voice->phoneme_tab_ix); SelectPhonemeTable(voice->phoneme_tab_ix);

Loading…
Cancel
Save