[1.48.11]

Command-line: added options --sep --tie.

API, changed the meaning of the "phonememode" parameter in espeak_SetPhonemeTrace() and espeak_TextToPhonemes().

Language changes to:  en, eu, pt.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@385 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2014-08-31 15:50:07 +00:00
parent 2315736555
commit b27f69bb5a
33 changed files with 1151 additions and 769 deletions
+54 -45
View File
@@ -637,8 +637,11 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
/* Called after a clause has been translated into phonemes, in order
to display the clause in phoneme mnemonic form.
phoneme_mode bits 0-3: 0=only phoneme names, 1=ties, 2=ZWJ, 3=underscore separator
bit 4: 0=eSpeak phoneme names, 1=IPA
phoneme_mode
bit 1: use IPA phoneme names
bit 7: use tie between letters in multi-character phoneme names
bits 8-23 tie or separator character
*/
int ix;
@@ -652,16 +655,12 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
int flags;
int use_ipa;
int use_tie;
int separate_phonemes = 0;
int separate_phonemes;
char phon_buf[30];
char phon_buf2[30];
PHONEME_LIST *plist;
static const char *stress_chars = "==,,''";
static const int char_tie[] = {0x0361, 0x200d}; // combining-double-inverted-breve, zero-width-joiner
use_ipa = phoneme_mode & 0x10;
use_tie = phoneme_mode & 0x0f;
if(phon_out_buf == NULL)
{
@@ -673,10 +672,15 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
}
}
if(use_tie >= 3)
use_ipa = phoneme_mode & espeakPHONEMES_IPA;
if(phoneme_mode & espeakPHONEMES_TIE)
{
// separate individual phonemes with underscores
separate_phonemes = '_';
use_tie = phoneme_mode >> 8;
separate_phonemes = 0;
}
else
{
separate_phonemes = phoneme_mode >> 8;
use_tie = 0;
}
@@ -690,14 +694,15 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
WritePhMnemonic(phon_buf2, plist->ph, plist, use_ipa, &flags);
if(plist->newword)
*buf++ = ' ';
else
if((!plist->newword) || (separate_phonemes == ' '))
{
if((separate_phonemes != 0) && (ix > 1))
{
utf8_in(&c, phon_buf2);
if((c < 0x2b0) || (c > 0x36f)) // not if the phoneme starts with a superscript letter
{
*buf++ = separate_phonemes;
buf += utf8_out(separate_phonemes, buf);
}
}
}
@@ -734,12 +739,12 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
for(p=phon_buf2; *p != 0;)
{
p += utf8_in(&c, p);
if(use_tie > 0)
if(use_tie != 0)
{
// look for non-inital alphabetic character, but not diacritic, superscript etc.
if((count>0) && !(flags & (1 << (count-1))) && ((c < 0x2b0) || (c > 0x36f)) && iswalpha2(c))
{
buf += utf8_out(char_tie[use_tie-1], buf);
buf += utf8_out(use_tie, buf);
}
}
buf += utf8_out(c, buf);
@@ -1193,6 +1198,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
PHONEME_TAB *ph;
int stress;
int max_stress;
int max_stress_input; // any stress specified in the input?
int vowel_count; // num of vowels + 1
int ix;
int v;
@@ -1257,7 +1263,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
unstressed_word = 1;
}
max_stress = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 1);
max_stress = max_stress_input = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 1);
if((max_stress < 0) && dictionary_flags)
{
max_stress = 0;
@@ -1338,40 +1344,33 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
{
stressed_syllable = vowel_count - 2;
if(stressflags & (S_FINAL_SPANISH | S_FINAL_STRESS_C))
if(stressflags & S_FINAL_SPANISH)
{
// LANG=Spanish, stress on last vowel if the word ends in a consonant other than 'n' or 's'
if(phoneme_tab[final_ph]->type != phVOWEL)
{
if(stressflags & S_FINAL_STRESS_C)
mnem = phoneme_tab[final_ph]->mnemonic;
if(tr->translator_name == L('a','n'))
{
stressed_syllable = vowel_count - 1;
if(((mnem != 's') && (mnem !='n')) || phoneme_tab[final_ph2]->type != phVOWEL)
stressed_syllable = vowel_count - 1; // stress on last syllable
}
else
if(tr->translator_name == L('i','a'))
{
if((mnem != 's') || phoneme_tab[final_ph2]->type != phVOWEL)
stressed_syllable = vowel_count - 1; // stress on last syllable
}
else
{
mnem = phoneme_tab[final_ph]->mnemonic;
if(tr->translator_name == L('a','n'))
if((mnem == 's') && (phoneme_tab[final_ph2]->type == phNASAL))
{
if(((mnem != 's') && (mnem !='n')) || phoneme_tab[final_ph2]->type != phVOWEL)
stressed_syllable = vowel_count - 1; // stress on last syllable
// -ns stress remains on penultimate syllable
}
else
if(tr->translator_name == L('i','a'))
else if(((phoneme_tab[final_ph]->type != phNASAL) && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
{
if((mnem != 's') || phoneme_tab[final_ph2]->type != phVOWEL)
stressed_syllable = vowel_count - 1; // stress on last syllable
}
else
{
if((mnem == 's') && (phoneme_tab[final_ph2]->type == phNASAL))
{
// -ns stress remains on penultimate syllable
}
else if(((phoneme_tab[final_ph]->type != phNASAL) && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
{
stressed_syllable = vowel_count - 1;
}
stressed_syllable = vowel_count - 1;
}
}
}
@@ -1578,6 +1577,16 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
break;
}
if((stressflags & S_FINAL_VOWEL_UNSTRESSED) && (vowel_count > 2) && (max_stress_input < 3) && (vowel_stress[vowel_count - 1] == 4))
{
if(phoneme_tab[final_ph]->type == phVOWEL)
{
// don't allow stress on a word-final vowel
vowel_stress[vowel_count - 1] = 1;
vowel_stress[vowel_count - 2] = 4;
}
}
/* now guess the complete stress pattern */
if(max_stress < 4)
stress = 4; /* no primary stress marked, use for 1st syllable */
@@ -2551,7 +2560,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
total_consumed = consumed;
}
if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
if((option_phonemes & espeakPHONEMES_TRACE) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
{
// show each rule that matches, and it's points score
int pts;
@@ -2628,7 +2637,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
word_copy[ix] = 0;
if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
if((option_phonemes & espeakPHONEMES_TRACE) && ((word_flags & FLAG_NO_TRACE)==0))
{
char wordbuf[120];
unsigned int ix;
@@ -2866,7 +2875,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
return(0);
}
if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
if((option_phonemes & espeakPHONEMES_TRACE) && ((word_flags & FLAG_NO_TRACE)==0))
{
fprintf(f_trans,"\n");
}
@@ -3367,7 +3376,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
if(phoneme_len == 0)
{
if(option_phonemes == 2)
if(option_phonemes & espeakPHONEMES_TRACE)
{
print_dictionary_flags(flags, dict_flags_buf, sizeof(dict_flags_buf));
fprintf(f_trans,"Flags: %s %s\n", word1, dict_flags_buf);
@@ -3378,7 +3387,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
if(flags != NULL)
flags[0] |= FLAG_FOUND; // this flag indicates word was found in dictionary
if(option_phonemes == 2)
if(option_phonemes & espeakPHONEMES_TRACE)
{
char ph_decoded[N_WORD_PHONEMES];
int textmode;
@@ -3560,7 +3569,7 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
word1 = *wordptr;
*wordptr = &word_replacement[2];
if(option_phonemes == 2)
if(option_phonemes & espeakPHONEMES_TRACE)
{
len = found - word1;
memcpy(word,word1,len); // include multiple matching words
@@ -3759,7 +3768,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
{
utf8_out(tr->langopts.suffix_add_e, &word_end[1]);
if(option_phonemes == 2)
if(option_phonemes & espeakPHONEMES_TRACE)
{
fprintf(f_trans,"add e\n");
}