[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");
}
+86 -17
View File
@@ -53,7 +53,7 @@ static const char *help_text =
"-p <integer>\n"
"\t Pitch adjustment, 0 to 99, default is 50\n"
"-s <integer>\n"
"\t Speed in words per minute, 80 to 450, default is 175\n"
"\t Speed in approximate words per minute. The default is 175\n"
"-v <voice name>\n"
"\t Use voice file of this name from espeak-data/voices\n"
"-w <wave file name>\n"
@@ -68,7 +68,6 @@ static const char *help_text =
"\t Compile pronunciation rules and dictionary from the current\n"
"\t directory. <voice name> specifies the language\n"
"--ipa Write phonemes to stdout using International Phonetic Alphabet\n"
"\t --ipa=1 Use ties, --ipa=2 Use ZWJ, --ipa=3 Separate with _\n"
"--path=\"<path>\"\n"
"\t Specifies the directory containing the espeak-data directory\n"
"--pho Write mbrola phoneme data (.pho) to stdout or to the file in --phonout\n"
@@ -77,9 +76,15 @@ static const char *help_text =
"--punct=\"<characters>\"\n"
"\t Speak the names of punctuation characters during speaking. If\n"
"\t =<characters> is omitted, all punctuation is spoken.\n"
"--split=\"<minutes>\"\n"
"--sep=<character>\n"
"\t Separate phonemes (from -x --ipa) with <character>.\n"
"\t Default is space, z means ZWJN character.\n"
"--split=<minutes>\n"
"\t Starts a new WAV file every <minutes>. Used with -w\n"
"--stdout Write speech output to stdout\n"
"--tie=<character>\n"
"\t Use a tie character within multi-letter phoneme names.\n"
"\t Default is U+361, z means ZWJ character.\n"
"--version Shows version number and date, and location of espeak-data\n"
"--voices=<language>\n"
"\t List the available voices for the specified language.\n"
@@ -123,6 +128,37 @@ void strncpy0(char *dest, const char *source, int size)
}
}
int utf8_in(int *c, const char *buf)
{//=================================
// Read a unicode characater from a UTF8 string
// Returns the number of UTF8 bytes used.
// backwards: set if we are moving backwards through the UTF8 string
int c1;
int n_bytes;
int ix;
static const unsigned char mask[4] = {0xff,0x1f,0x0f,0x07};
n_bytes = 0;
if((c1 = *buf++) & 0x80)
{
if((c1 & 0xe0) == 0xc0)
n_bytes = 1;
else if((c1 & 0xf0) == 0xe0)
n_bytes = 2;
else if((c1 & 0xf8) == 0xf0)
n_bytes = 3;
c1 &= mask[n_bytes];
for(ix=0; ix<n_bytes; ix++)
{
c1 = (c1 << 6) + (*buf++ & 0x3f);
}
}
*c = c1;
return(n_bytes+1);
}
void DisplayVoices(FILE *f_out, char *language)
{//============================================
@@ -381,6 +417,8 @@ int main (int argc, char **argv)
{"pho", no_argument, 0, 0x109},
{"ipa", optional_argument, 0, 0x10a},
{"version", no_argument, 0, 0x10b},
{"sep", optional_argument, 0, 0x10c},
{"tie", optional_argument, 0, 0x10d},
{0, 0, 0, 0}
};
@@ -408,8 +446,8 @@ int main (int argc, char **argv)
int wordgap = -1;
int option_capitals = -1;
int option_punctuation = -1;
int option_phonemes = 0;
int option_mbrola_phonemes = 0;
int phonemes_separator = 0;
int phoneme_options = 0;
int option_linelength = 0;
int option_waveout = 0;
@@ -513,11 +551,11 @@ int main (int argc, char **argv)
break;
case 'x':
option_phonemes = 1;
phoneme_options |= espeakPHONEMES_SHOW;
break;
case 'X':
option_phonemes = 2;
phoneme_options |= espeakPHONEMES_TRACE;
break;
case 'm':
@@ -616,27 +654,56 @@ int main (int argc, char **argv)
break;
case 0x109: // --pho
option_mbrola_phonemes = 16;
phoneme_options |= espeakPHONEMES_MBROLA;
break;
case 0x10a: // --ipa
option_phonemes = 3;
phoneme_options |= espeakPHONEMES_IPA;
if(optarg2 != NULL)
{
value = -1;
sscanf(optarg2,"%d",&value);
if((value<0) || (value>3))
// deprecated and obsolete
switch(atoi(optarg2))
{
fprintf(stderr,"Bad value for -ipa=\n");
value = 0;
case 1:
phonemes_separator = '_';
break;
case 2:
phonemes_separator = 0x0361;
phoneme_options |= espeakPHONEMES_TIE;
break;
case 3:
phonemes_separator = 0x200d; // ZWJ
phoneme_options |= espeakPHONEMES_TIE;
break;
}
option_phonemes += value;
}
break;
case 0x10b: // -version
case 0x10b: // --version
PrintVersion();
exit(0);
case 0x10c: // --sep
phoneme_options |= espeakPHONEMES_SHOW;
if(optarg2 == 0)
phonemes_separator = ' ';
else
utf8_in(&phonemes_separator, optarg2);
if(phonemes_separator == 'z')
phonemes_separator = 0x200c; // ZWNJ
break;
case 0x10d: // --tie
phoneme_options |= (espeakPHONEMES_SHOW | espeakPHONEMES_TIE);
if(optarg2 == 0)
phonemes_separator = 0x0361; // default: combining-double-inverted-breve
else
utf8_in(&phonemes_separator, optarg2);
if(phonemes_separator == 'z')
phonemes_separator = 0x200d; // ZWJ
break;
default:
exit(0);
@@ -707,7 +774,9 @@ int main (int argc, char **argv)
espeak_SetParameter(espeakLINELENGTH,option_linelength,0);
if(option_punctuation == 2)
espeak_SetPunctuationList(option_punctlist);
espeak_SetPhonemeTrace(option_phonemes | option_mbrola_phonemes,f_phonemes_out);
espeak_SetPhonemeTrace(phoneme_options | (phonemes_separator << 8), f_phonemes_out);
if(filename[0]==0)
{
+52 -13
View File
@@ -87,7 +87,7 @@ static const char *help_text =
"-p <integer>\n"
"\t Pitch adjustment, 0 to 99, default is 50\n"
"-s <integer>\n"
"\t Speed in words per minute, 80 to 450, default is 175\n"
"\t Speed in approximate words per minute. The default is 175\n"
"-v <voice name>\n"
"\t Use voice file of this name from espeak-data/voices\n"
"-w <wave file name>\n"
@@ -102,7 +102,6 @@ static const char *help_text =
"\t Compile pronunciation rules and dictionary from the current\n"
"\t directory. <voice name> specifies the language\n"
"--ipa Write phonemes to stdout using International Phonetic Alphabet\n"
"\t --ipa=1 Use ties, --ipa=2 Use ZWJ, --ipa=3 Separate with _\n"
"--path=\"<path>\"\n"
"\t Specifies the directory containing the espeak-data directory\n"
"--pho Write mbrola phoneme data (.pho) to stdout or to the file in --phonout\n"
@@ -111,9 +110,15 @@ static const char *help_text =
"--punct=\"<characters>\"\n"
"\t Speak the names of punctuation characters during speaking. If\n"
"\t =<characters> is omitted, all punctuation is spoken.\n"
"--split=\"<minutes>\"\n"
"--sep=<character>\n"
"\t Separate phonemes (from -x --ipa) with <character>.\n"
"\t Default is space, z means ZWJN character.\n"
"--split=<minutes>\n"
"\t Starts a new WAV file every <minutes>. Used with -w\n"
"--stdout Write speech output to stdout\n"
"--tie=<character>\n"
"\t Use a tie character within multi-letter phoneme names.\n"
"\t Default is U+361, z means ZWJ character.\n"
"--version Shows version number and date, and location of espeak-data\n"
"--voices=<language>\n"
"\t List the available voices for the specified language.\n"
@@ -496,6 +501,8 @@ int main (int argc, char **argv)
{"pho", no_argument, 0, 0x109},
{"ipa", optional_argument, 0, 0x10a},
{"version", no_argument, 0, 0x10b},
{"sep", optional_argument, 0, 0x10c},
{"tie", optional_argument, 0, 0x10d},
{0, 0, 0, 0}
};
@@ -516,6 +523,8 @@ int main (int argc, char **argv)
int flag_stdin = 0;
int flag_compile = 0;
int pitch_adjustment = 50;
int phoneme_options = 0;
int phonemes_separator = 0;
espeak_VOICE voice_select;
char filename[200];
char voicename[40];
@@ -622,11 +631,11 @@ int main (int argc, char **argv)
break;
case 'x':
option_phonemes = 1;
phoneme_options |= espeakPHONEMES_SHOW;
break;
case 'X':
option_phonemes = 2;
phoneme_options |= espeakPHONEMES_TRACE;
break;
case 'm':
@@ -729,21 +738,29 @@ int main (int argc, char **argv)
break;
case 0x109: // --pho
option_mbrola_phonemes = 16;
phoneme_options |= espeakPHONEMES_MBROLA;
break;
case 0x10a: // --ipa
option_phonemes = 3;
phoneme_options |= espeakPHONEMES_IPA;
if(optarg2 != NULL)
{
value = -1;
sscanf(optarg2,"%d",&value);
if((value<0) || (value>3))
// deprecated and obsolete
switch(atoi(optarg2))
{
fprintf(stderr,"Bad value for -ipa=\n");
value = 0;
case 1:
phonemes_separator = '_';
break;
case 2:
phonemes_separator = 0x0361;
phoneme_options |= espeakPHONEMES_TIE;
break;
case 3:
phonemes_separator = 0x200d; // ZWJ
phoneme_options |= espeakPHONEMES_TIE;
break;
}
option_phonemes += value;
}
break;
@@ -751,6 +768,26 @@ int main (int argc, char **argv)
init_path(argv[0],data_path);
printf("speak text-to-speech: %s Data at: %s\n",version_string,path_home);
exit(0);
case 0x10c: // --sep
phoneme_options |= espeakPHONEMES_SHOW;
if(optarg2 == 0)
phonemes_separator = ' ';
else
utf8_in(&phonemes_separator, optarg2);
if(phonemes_separator == 'z')
phonemes_separator = 0x200c; // ZWNJ
break;
case 0x10d: // --tie
phoneme_options |= (espeakPHONEMES_SHOW | espeakPHONEMES_TIE);
if(optarg2 == 0)
phonemes_separator = 0x0361; // default: combining-double-inverted-breve
else
utf8_in(&phonemes_separator, optarg2);
if(phonemes_separator == 'z')
phonemes_separator = 0x200d; // ZWJ
break;
default:
exit(0);
@@ -803,6 +840,8 @@ int main (int argc, char **argv)
SetParameter(espeakPUNCTUATION,option_punctuation,0);
SetParameter(espeakWORDGAP,wordgap,0);
option_phonemes = phoneme_options | (phonemes_separator << 8);
if(pitch_adjustment != 50)
{
SetParameter(espeakPITCH,pitch_adjustment,0);
+19 -15
View File
@@ -811,7 +811,6 @@ ENTER("espeak_Initialize");
return(EE_INTERNAL_ERROR);
option_phonemes = 0;
option_mbrola_phonemes = 0;
option_phoneme_events = (options & (espeakINITIALIZE_PHONEME_EVENTS | espeakINITIALIZE_PHONEME_IPA));
VoiceReset(0);
@@ -1159,19 +1158,22 @@ ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist)
} // end of espeak_SetPunctuationList
ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream)
{//============================================================
ESPEAK_API void espeak_SetPhonemeTrace(int phonememode, FILE *stream)
{//===================================================================
ENTER("espeak_SetPhonemes");
/* Controls the output of phoneme symbols for the text
bits 0-3:
value=0 No phoneme output (default)
value=1 Output the translated phoneme symbols for the text
value=2 as (1), but also output a trace of how the translation was done (matching rules and list entries)
value=3 as (1), but produces IPA phoneme names rather than ascii
bit 4: produce mbrola pho data
*/
option_phonemes = value & 7;
option_mbrola_phonemes = value & 16;
/* phonememode: Controls the output of phoneme symbols for the text
bits 0-2:
value=0 No phoneme output (default)
value=1 Output the translated phoneme symbols for the text
value=2 as (1), but produces IPA phoneme names rather than ascii
bit 3: output a trace of how the translation was done (showing the matching rules and list entries)
bit 4: produce pho data for mbrola
bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
bits 8-23: separator character, between phoneme names
stream output stream for the phoneme symbols (and trace). If stream=NULL then it uses stdout.
*/
option_phonemes = phonememode;
f_trans = stream;
if(stream == NULL)
f_trans = stderr;
@@ -1181,8 +1183,10 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream)
ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode)
{//=================================================================================================
/* phoneme_mode bits 0-3: 0=only phoneme names, 1=ties, 2=ZWJ, 3=underscore separator
bits 4-7: 0=eSpeak phoneme names, 1=IPA
/* phoneme_mode
bit 1: 0=eSpeak's ascii phoneme names, 1= International Phonetic Alphabet (as UTF-8 characters).
bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
bits 8-23: separator character, between phoneme names
*/
option_multibyte = textmode & 7;
+24 -15
View File
@@ -34,7 +34,7 @@
#define ESPEAK_API
#endif
#define ESPEAK_API_REVISION 9
#define ESPEAK_API_REVISION 10
/*
Revision 2
Added parameter "options" to eSpeakInitialize()
@@ -61,6 +61,9 @@ Revision 8 26.Apr.2013
Revision 9 30.May.2013
Changed function espeak_TextToPhonemes().
Revision 10 29.Aug.2014
Changed phonememode parameter to espeak_TextToPhonemes() and espeak_SetPhonemeTrace
*/
/********************/
/* Initialization */
@@ -473,15 +476,25 @@ ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist);
EE_INTERNAL_ERROR.
*/
#define espeakPHONEMES_SHOW 0x01
#define espeakPHONEMES_IPA 0x02
#define espeakPHONEMES_TRACE 0x08
#define espeakPHONEMES_MBROLA 0x10
#define espeakPHONEMES_TIE 0x80
#ifdef __cplusplus
extern "C"
#endif
ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream);
/* Controls the output of phoneme symbols for the text
value=0 No phoneme output (default)
value=1 Output the translated phoneme symbols for the text
value=2 as (1), but also output a trace of how the translation was done (matching rules and list entries)
value=3 as (1), but produces IPA rather than ascii phoneme names
ESPEAK_API void espeak_SetPhonemeTrace(int phonememode, FILE *stream);
/* phonememode: Controls the output of phoneme symbols for the text
bits 0-2:
value=0 No phoneme output (default)
value=1 Output the translated phoneme symbols for the text
value=2 as (1), but produces IPA phoneme names rather than ascii
bit 3: output a trace of how the translation was done (showing the matching rules and list entries)
bit 4: produce pho data for mbrola
bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
bits 8-23: separator character, between phoneme names
stream output stream for the phoneme symbols (and trace). If stream=NULL then it uses stdout.
*/
@@ -506,15 +519,11 @@ ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode,
espeakCHARS_WCHAR Wide characters (wchar_t)
espeakCHARS_16BIT 16 bit characters.
phonememode: bits0-3:
0= just phonemes.
1= include ties (U+361) for phoneme names of more than one letter.
2= include zero-width-joiner for phoneme names of more than one letter.
3= separate phonemes with underscore characters.
phoneme_mode
bit 1: 0=eSpeak's ascii phoneme names, 1= International Phonetic Alphabet (as UTF-8 characters).
bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
bits 8-23: separator character, between phoneme names
bits 4-7:
0= eSpeak's ascii phoneme names.
1= International Phonetic Alphabet (as UTF-8 characters).
*/
#ifdef __cplusplus
+1 -2
View File
@@ -35,7 +35,6 @@
#include "translate.h"
#include "voice.h"
int option_mbrola_phonemes;
#ifdef INCLUDE_MBROLA
@@ -646,7 +645,7 @@ int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
if(*n_ph == 0)
return(0);
if(option_mbrola_phonemes)
if(option_phonemes & espeakPHONEMES_MBROLA)
{
// send mbrola data to a file, not to the mbrola library
f_mbrola = f_trans;
+8 -2
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.48.10 09.Aug.14";
const char *version_string = "1.48.11 31.Aug.14";
const int version_phdata = 0x014801;
int option_device_number = -1;
@@ -620,6 +620,7 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
int instn;
int instn2;
int count;
int check_endtype = 0;
PHONEME_TAB *ph;
PHONEME_LIST *plist_this;
@@ -672,6 +673,7 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
case 0: // prevPh
case 5: // prevPhW
plist--;
check_endtype = 1;
break;
case 1: // thisPh
@@ -705,6 +707,7 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
if((worddata==NULL) || (worddata->prev_vowel.ph == NULL))
return(false); // no previous vowel
plist = &(worddata->prev_vowel);
check_endtype = 1;
break;
case 9: // next3PhW
@@ -720,6 +723,7 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
if((plist[0].sourceix) || (plist[-1].sourceix))
return(false);
plist-=2;
check_endtype = 1;
break;
}
@@ -744,7 +748,9 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
// 'data' is a phoneme number
if((phoneme_tab[data]->mnemonic == ph->mnemonic) == true)
return(true);
if((which == 0) && (ph->type == phVOWEL))
// not an exact match, check for a vowel type (eg. #i )
if((check_endtype) && (ph->type == phVOWEL))
return(data == ph->end_type); // prevPh() match on end_type
return(data == ph->start_type); // thisPh() or nextPh(), match on start_type
}
+3 -7
View File
@@ -1980,14 +1980,10 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
CalcPitches(translator, clause_tone);
CalcLengths(translator);
if((option_phonemes > 0) || (phoneme_callback != NULL))
if((option_phonemes & 0xf) || (phoneme_callback != NULL))
{
int phoneme_mode = 0;
if(option_phonemes >= 3)
phoneme_mode = 0x10 + option_phonemes-3; // 0x10=ipa, 0x11=ipa with tie, 0x12=ipa with ZWJ, 0x13=ipa with separators
phon_out = GetTranslatedPhonemeString(phoneme_mode);
if(option_phonemes > 0)
phon_out = GetTranslatedPhonemeString(option_phonemes);
if(option_phonemes & 0xf)
{
fprintf(f_trans,"%s\n",phon_out);
}
+8 -6
View File
@@ -779,7 +779,8 @@ Translator *SelectTranslator(const char *name)
if(name2 == L_pap)
{
// stress last syllable unless word ends with a vowel
tr->langopts.stress_flags = S_FINAL_STRESS_C | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
tr->langopts.stress_rule = STRESSPOSN_1R;
tr->langopts.stress_flags = S_FINAL_VOWEL_UNSTRESSED | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
}
else
{
@@ -793,7 +794,8 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_eu[8] = {200, 200, 200, 200, 0, 0, 210, 230}; // very weak stress
static const unsigned char stress_amps_eu[8] = {16,16, 18,18, 18,18, 18,18 };
SetupTranslator(tr,stress_lengths_eu,stress_amps_eu);
tr->langopts.stress_rule = STRESSPOSN_2L; // ?? second syllable ??
tr->langopts.stress_rule = STRESSPOSN_2L; // ?? second syllable, but not on a word-final vowel
tr->langopts.stress_flags = S_FINAL_VOWEL_UNSTRESSED;
tr->langopts.param[LOPT_SUFFIX] = 1;
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_VIGESIMAL;
}
@@ -1345,8 +1347,8 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_ro,stress_amps_ro);
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = S_FINAL_STRESS_C + S_FINAL_DIM_ONLY;
tr->langopts.stress_rule = STRESSPOSN_1R;
tr->langopts.stress_flags = S_FINAL_VOWEL_UNSTRESSED | S_FINAL_DIM_ONLY;
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_3 | NUM_AND_UNITS | NUM_ROMAN;
@@ -1449,8 +1451,8 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_sq,stress_amps_sq);
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_FINAL_STRESS_C;
tr->langopts.stress_rule = STRESSPOSN_1R;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_FINAL_VOWEL_UNSTRESSED;
SetLetterVowel(tr,'y');
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_4;
tr->langopts.accents = 2; // "capital" after letter name
+3 -3
View File
@@ -763,7 +763,7 @@ int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes)
}
remove_stress = pb[1];
if(option_phonemes == 2)
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);
@@ -806,7 +806,7 @@ int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes)
strcpy(phonemes, phonbuf);
if(option_phonemes == 2)
if(option_phonemes & espeakPHONEMES_TRACE)
{
SelectPhonemeTable(tr->phoneme_tab_ix);
DecodePhonemes(phonemes, phonbuf);
@@ -1220,7 +1220,7 @@ if(end_type & SUFX_UNPRON)
end_type = end2;
strcpy(phonemes,phonemes2);
strcpy(end_phonemes,end_phonemes2);
if(option_phonemes == 2)
if(option_phonemes & espeakPHONEMES_TRACE)
{
DecodePhonemes(end_phonemes,end_phonemes2);
fprintf(f_trans," suffix [%s]\n\n",end_phonemes2);
+2 -3
View File
@@ -408,8 +408,8 @@ typedef struct {
#define S_FIRST_PRIMARY 0x80
// bit7=if more than one primary stress, make the subsequent primaries to secondary stress
#define S_FINAL_STRESS_C 0x100
// bit8=stress last syllable if it doesn't end in a vowel
#define S_FINAL_VOWEL_UNSTRESSED 0x100
// bit8=don't apply default stress to a word-final vowel
#define S_FINAL_SPANISH 0x200
// bit9=stress last syllable if it doesn't end in vowel or "s" or "n" LANG=Spanish
@@ -673,7 +673,6 @@ extern int option_tone_flags;
extern int option_waveout;
extern int option_quiet;
extern int option_phonemes;
extern int option_mbrola_phonemes;
extern int option_phoneme_events;
extern int option_linelength; // treat lines shorter than this as end-of-clause
extern int option_multibyte;
+5 -7
View File
@@ -409,7 +409,6 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
const char *phon_out2;
int clause_tone;
int clause_count;
int use_ipa = 0;
FILE *f;
int fd_temp;
char fname_temp[100];
@@ -447,21 +446,20 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
}
#endif
t_phonetic->SetDefaultStyle(style_phonetic);
translate_text = 2;
translate_text = espeakPHONEMES_TRACE;
break;
case T_TRANSLATE:
case MENU_SPEAK_TRANSLATE:
t_phonetic->SetDefaultStyle(style_phonetic);
translate_text = 1;
translate_text = espeakPHONEMES_SHOW;
break;
case T_TRANSLATE_IPA:
case MENU_SPEAK_IPA:
t_phonetic->SetDefaultStyle(style_phonetic_large);
translate_text = 3;
use_ipa = 0x10;
translate_text = espeakPHONEMES_IPA;
break;
case T_PROCESS:
@@ -496,7 +494,7 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
CalcPitches(translator,clause_tone);
CalcLengths(translator);
phon_out2 = GetTranslatedPhonemeString(use_ipa);
phon_out2 = GetTranslatedPhonemeString(option_phonemes);
if(clause_count++ > 0)
strcat(phon_out," ||");
strcat(phon_out, phon_out2);
@@ -514,7 +512,7 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
ph_list[N_PH_LIST].ph = NULL; // to recognize overrun off list (in Generate() )
t_phonetic->Clear();
if(option_phonemes == 2)
if(option_phonemes & espeakPHONEMES_TRACE)
{
option_phonemes=0;
rewind(f_trans);