[1.31.18]

Indicate unrecognized letters within a word by clicks.
lang-tr: Non-standard lower case conversion for "I".
Tone languages: indicate emphasis by increasing the pitch range.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@151 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2008-02-25 21:59:24 +00:00
parent bf8ee6362e
commit 16fba5a1c1
20 changed files with 179 additions and 54 deletions
+14 -2
View File
@@ -1201,7 +1201,7 @@ void Translator::SetWordStress(char *output, unsigned int dictionary_flags, int
if(stressed_syllable == 0)
{
stressed_syllable = vowel_count - 1;
for(ix=2; ix < vowel_count; ix++)
for(ix=1; ix < vowel_count; ix++)
{
if(vowel_stress[ix] == 1)
{
@@ -2303,7 +2303,7 @@ int Translator::TranslateRules(char *p_start, char *phonemes, int ph_size, char
while(((c = *p) != ' ') && (c != 0))
{
if(IsAlpha(wc))
any_alpha = wc;
any_alpha++;
wc_prev = wc;
wc_bytes = utf8_in(&wc,p,0);
@@ -2420,6 +2420,18 @@ int Translator::TranslateRules(char *p_start, char *phonemes, int ph_size, char
}
}
}
if(match1.points == 0)
{
static const char str_unknown[4] = {phonCAPITAL,phonCAPITAL,phonCAPITAL,0};
if(((any_alpha > 0) || (p[wc_bytes-1] > ' ')) && !iswpunct(wc))
{
// an unrecognised character in a word, indicate with clicks
match1.phonemes = str_unknown;
match1.points = 1;
}
p += (wc_bytes-1);
}
}
}
+4 -11
View File
@@ -99,15 +99,12 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control)
int n_bytes;
int letter;
int len;
int phoneme_tab_en;
char *p2;
char *pbuf;
char capital[20];
char ph_buf[60];
char ph_buf2[60];
char ph_buf_en[60];
char hexbuf[6];
static char single_letter[10] = {0,0};
ph_buf[0] = 0;
capital[0] = 0;
@@ -127,7 +124,7 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control)
Lookup("_cap",capital);
}
}
letter = towlower(letter);
letter = towlower2(letter);
LookupLetter(letter, word[n_bytes], ph_buf);
@@ -139,13 +136,9 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control)
if(ph_buf[0] == 0)
{
phoneme_tab_en = SetTranslator2("en");
translator2->LookupLetter(letter, word[n_bytes], ph_buf_en);
if(ph_buf_en[0] != 0)
{
sprintf(ph_buf,"%c%c%s%c%c",phonSWITCH2, phoneme_tab_en + phonTOP, ph_buf_en, phonSWITCH2, voice->phoneme_tab_ix + phonTOP);
}
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
// ?? speak as English ??
sprintf(phonemes,"%c",phonSWITCH);
return(0);
}
if(ph_buf[0] == 0)
-2
View File
@@ -87,8 +87,6 @@
#define phonT_REDUCED 25
#define phonSTRESS_TONIC 26
#define phonPAUSE_CLAUSE 27
#define phonSWITCH2 28
#define phonTOP 28 // highest pre-defined phoneme number
extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
+25 -1
View File
@@ -299,6 +299,18 @@ float wcstod(const wchar_t *str, wchar_t **tailptr)
}
#endif
int towlower2(unsigned int c)
{
// check for non-standard upper to lower case conversions
if(c == 'I')
{
if(translator->translator_name == L('t','r'))
{
c = 0x131; // I -> ı
}
}
return(towlower(c));
}
static void GetC_unget(int c)
{//==========================
@@ -1456,7 +1468,19 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
{
value = attrlookup(attr1,mnem_emphasis);
}
sp->parameter[espeakEMPHASIS] = value;
if(translator->langopts.tone_language == 1)
{
static unsigned char emphasis_to_pitch_range[] = {50,50,40,70,90,90};
static unsigned char emphasis_to_volume[] = {100,100,70,110,140,140};
// tone language (eg.Chinese) do emphasis by increasing the pitch range.
sp->parameter[espeakRANGE] = emphasis_to_pitch_range[value];
sp->parameter[espeakVOLUME] = emphasis_to_volume[value];
}
else
{
sp->parameter[espeakEMPHASIS] = value;
}
ProcessParamStack(outbuf, outix);
break;
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.31.17 24.Feb.08";
const char *version_string = "1.31.18 25.Feb.08";
const int version_phdata = 0x013105;
int option_device_number = -1;
+13 -5
View File
@@ -71,9 +71,10 @@ int Translator_English::Unpronouncable(char *word)
This function is language specific.
*/
unsigned char c;
int c;
int vowel_posn=9;
int index;
int count;
int ix;
int apostrophe=0;
@@ -92,19 +93,26 @@ int Translator_English::Unpronouncable(char *word)
}
index=0;
while(((c = word[index++]) != 0) && !isspace(c))
count=0;
for(;;)
{
index += utf8_in(&c,&word[index],0);
count++;
if((c==0) || (c==' '))
break;
if(IsVowel(c) || (c == 'y'))
{
vowel_posn = index;
vowel_posn = count;
break;
}
if(c == '\'')
apostrophe = 1;
else
if((c < 'a') || (c > 'z'))
return(0); // letter (not vowel) outside a-z range or apostrophe, abort test
if((c < 'a') || (c > 0x241))
return(0); // letter (not vowel) outside Latin character range or apostrophe, abort test
}
if((vowel_posn > 5) || ((word[0]!='s') && (vowel_posn > 4)))
return(1); // no vowel, or no vowel in first four letters
+9
View File
@@ -575,6 +575,15 @@ SetLengthMods(tr,3); // all equal
tr = new Translator_Russian();
break;
case L('r','w'): // Kiryarwanda
{
tr = new Translator();
tr->langopts.stress_rule = 2;
tr->langopts.stress_flags = 0x16;
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
}
break;
case L('s','k'): // Slovak
case L('c','s'): // Czech
{
+37 -17
View File
@@ -788,7 +788,7 @@ if((wmark > 0) && (wmark < 8))
return(0);
}
p = &wordx[word_length-3];
p = &wordx[word_length-3]; // this looks wrong. Doesn't consider multi-byte chars.
if(memcmp(p,"'s ",3) == 0)
{
// remove a 's suffix and pronounce this separately (not as an individual letter)
@@ -819,6 +819,30 @@ if((wmark > 0) && (wmark < 8))
return(0);
}
if((phonemes[0] == 0) && (end_phonemes[0] == 0))
{
int wc;
// characters not recognised, speak them individually
utf8_in(&wc, wordx, 0);
if(!iswpunct(wc))
{
posn = 0;
while(*wordx != ' ')
{
wordx += TranslateLetter(wordx, phonemes, 4);
posn++;
if(phonemes[0] == phonSWITCH)
{
// change to another language in order to translate this word
strcpy(word_phonemes,phonemes);
return(0);
}
}
SetSpellingStress(phonemes,spell_word,posn);
}
}
c_temp = wordx[-1];
found = 0;
@@ -871,7 +895,7 @@ if((wmark > 0) && (wmark < 8))
prefix_chars[0] = 0;
n_chars = prefix_type & 0x3f;
for(ix=0; ix < n_chars; ix++) // num. of characters to remove
for(ix=0; ix < n_chars; ix++) // num. of bytes to remove
{
prefix_chars[pfix++] = *wordx++;
@@ -879,11 +903,6 @@ if((wmark > 0) && (wmark < 8))
{
prefix_chars[pfix-1] = 0; // discard the last character of the prefix, this is the separator character
}
while((*wordx & 0xc0) == 0x80)
{
prefix_chars[pfix++] = *wordx++; // for multibyte characters
}
}
prefix_chars[pfix] = 0;
c_temp = wordx[-1];
@@ -894,15 +913,22 @@ if((wmark > 0) && (wmark < 8))
{
// retranslate the prefix part
char *wordpf;
char prefix_phonemes2[12];
strncpy0(prefix_phonemes2,end_phonemes,sizeof(prefix_phonemes2));
wordpf = &prefix_chars[1];
found = LookupDictList(&wordpf, phonemes, dictionary_flags, SUFX_P, wtab); // without prefix
if(found == 0)
{
end_type = TranslateRules(wordpf, phonemes, N_WORD_PHONEMES, end_phonemes, 0, dictionary_flags[0]);
strcat(prefix_phonemes, phonemes);
sprintf(prefix_phonemes,"%s%s%s",phonemes,end_phonemes,prefix_phonemes2);
}
prefix_flags = 1;
}
else
{
strcat(prefix_phonemes,end_phonemes);
}
strcat(prefix_phonemes,end_phonemes);
end_phonemes[0] = 0;
end_type = 0;
@@ -1539,12 +1565,6 @@ int Translator::TranslateWord2(char *word, WORD_TAB *wtab, int pre_pause, int ne
srcix = source_ix+1;
}
else
if(ph_code == phonSWITCH2)
{
SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
ph_list2[n_ph_list2++].tone_number = *p++ - phonTOP; // phoneme table number (phonTOP is added to avoid confusion with special phoneme numbers)
}
else
if(ph_code == phonX1)
{
// a language specific action
@@ -1971,7 +1991,7 @@ void *Translator::TranslateClause(FILE *f_text, const void *vp_input, int *tone_
{
c = ' ';
}
c = towlower(c);
c = towlower2(c);
}
if(phoneme_mode)
@@ -2109,7 +2129,7 @@ if((c == '/') && (langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(prev_ou
if(iswupper(c))
{
c = towlower(c);
c = towlower2(c);
if(langopts.param[LOPT_SYLLABLE_CAPS])
{
+1
View File
@@ -580,6 +580,7 @@ void InitText2(void);
int IsDigit(unsigned int c);
int IsAlpha(unsigned int c);
int isspace2(unsigned int c);
int towlower2(unsigned int c);
void SetVoiceStack(espeak_VOICE *v);
extern FILE *f_trans; // for logging