Fix: espeak --stdout, set a (large) data size.
espeak --voices.  Include mbrola voices only if a language is specified.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@156 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2008-03-05 13:29:41 +00:00
parent 389f86143e
commit 99e2976c86
53 changed files with 1095 additions and 438 deletions
+218 -48
View File
@@ -37,22 +37,33 @@
#define M_NAME 0
#define M_ACUTE 1
#define M_BREVE 2
#define M_CARON 3
#define M_CEDILLA 4
#define M_CIRCUMFLEX 5
#define M_DIAERESIS 6
#define M_DOUBLE_ACUTE 7
#define M_DOT_ABOVE 8
#define M_GRAVE 9
#define M_MACRON 10
#define M_OGONEK 11
#define M_RING 12
#define M_STROKE 13
#define M_TILDE 14
#define M_SMALLCAP 1
#define M_TURNED 2
#define M_REVERSED 3
#define M_CURL 4
#define M_MIDDLE_DOT 8 // duplicate of M_DOT_ABOVE
#define M_ACUTE 5
#define M_BREVE 6
#define M_CARON 7
#define M_CEDILLA 8
#define M_CIRCUMFLEX 9
#define M_DIAERESIS 10
#define M_DOUBLE_ACUTE 11
#define M_DOT_ABOVE 12
#define M_GRAVE 13
#define M_MACRON 14
#define M_OGONEK 15
#define M_RING 16
#define M_STROKE 17
#define M_TILDE 18
#define M_BAR 19
#define M_RETROFLEX 20
#define M_HOOK 21
#define M_MIDDLE_DOT M_DOT_ABOVE // duplicate of M_DOT_ABOVE
#define M_IMPLOSIVE M_HOOK
typedef struct {
char *name;
@@ -62,6 +73,11 @@ int flags;
// these are tokens to look up in the *_list file.
ACCENTS accents_tab[] = {
{"_lig", 1},
{"_smc", 1}, // smallcap
{"_tur", 1}, // turned
{"_rev", 1}, // reversed
{"_crl", 0}, // curl
{"_acu", 0}, // acute
{"_brv", 0}, // breve
{"_hac", 0}, // caron/hacek
@@ -76,12 +92,38 @@ ACCENTS accents_tab[] = {
{"_rng", 0}, // ring
{"_stk", 0}, // stroke
{"_tld", 0}, // tilde
{"_bar", 0}, // bar
{"_rfx", 0}, // retroflex
{"_hok", 0}, // hook
};
#define CAPITAL 0
#define LETTER(ch,mod1,mod2) ch+(mod1 << 8)
#define LIGATURE(ch1,ch2,mod1) ch1+(ch2 << 8)+0x8000
#define LETTER(ch,mod1,mod2) (ch-59)+(mod1 << 6)+(mod2 << 11)
#define LIGATURE(ch1,ch2,mod1) (ch1-59)+((ch2-59) << 6)+(mod1 << 12)+0x8000
#define L_ALPHA 60 // U+3B1
#define L_SCHWA 61 // U+259
#define L_OPEN_E 62 // U+25B
#define L_GAMMA 63 // U+3B3
#define L_IOTA 64 // U+3B9
#define L_OE 65 // U+153
#define L_OMEGA 66 // U+3C9
#define L_PHI 67 // U+3C6
#define L_ESH 68 // U+283
#define L_UPSILON 69 // U+3C5
#define L_EZH 70 // U+292
#define L_GLOTTAL 71 // U+294
#define L_RTAP 72 // U+27E
static const short non_ascii_tab[] = {
0, 0x3b1, 0x259, 0x25b, 0x3b3, 0x3b9, 0x153, 0x3c9,
0x3c6, 0x283, 0x3c5, 0x292, 0x294, 0x27e };
// characters U+00e0 to U+017f
const short letter_accents_0e0[] = {
@@ -179,11 +221,11 @@ LETTER('l',M_ACUTE,0),
CAPITAL,
LETTER('l',M_CEDILLA,0),
CAPITAL,
LETTER('1',M_CARON,0),
LETTER('l',M_CARON,0),
CAPITAL,
LETTER('1',M_MIDDLE_DOT,0), // U+0140
LETTER('l',M_MIDDLE_DOT,0), // U+0140
CAPITAL,
LETTER('1',M_STROKE,0),
LETTER('l',M_STROKE,0),
CAPITAL,
LETTER('n',M_ACUTE,0),
CAPITAL,
@@ -248,6 +290,98 @@ LETTER('s',M_NAME,0), // long-s // U+17f
};
// characters U+0250 to U+029F
const short letter_accents_250[] = {
LETTER('a',M_TURNED,0), // U+250
LETTER(L_ALPHA,0,0),
LETTER(L_ALPHA,M_TURNED,0),
LETTER('b',M_IMPLOSIVE,0),
0, // open-o
LETTER('c',M_CURL,0),
LETTER('d',M_RETROFLEX,0),
LETTER('d',M_IMPLOSIVE,0),
LETTER('e',M_REVERSED,0), // U+258
0, // schwa
LETTER(L_SCHWA,M_HOOK,0),
0, // open-e
LETTER(L_OPEN_E,M_REVERSED,0),
LETTER(L_OPEN_E,M_HOOK,M_REVERSED),
0,//LETTER(L_OPEN_E,M_CLOSED,M_REVERSED),
LETTER('j',M_BAR,0),
LETTER('g',M_IMPLOSIVE,0), // U+260
LETTER('g',0,0),
LETTER('g',M_SMALLCAP,0),
LETTER(L_GAMMA,0,0),
0, // ramshorn
LETTER('h',M_TURNED,0),
LETTER('h',M_HOOK,0),
0,//LETTER(L_HENG,M_HOOK,0),
LETTER('i',M_BAR,0), // U+268
LETTER(L_IOTA,0,0),
LETTER('i',M_SMALLCAP,0),
LETTER('l',M_TILDE,0),
LETTER('l',M_BAR,0),
LETTER('l',M_RETROFLEX,0),
LIGATURE('l','z',0),
LETTER('m',M_TURNED,0),
0,//LETTER('m',M_TURNED,M_LEG), // U+270
LETTER('m',M_HOOK,0),
0,//LETTER('n',M_LEFTHOOK,0),
LETTER('n',M_RETROFLEX,0),
LETTER('n',M_SMALLCAP,0),
LETTER('o',M_BAR,0),
LIGATURE('o','e',M_SMALLCAP),
0,//LETTER(L_OMEGA,M_CLOSED,0),
LETTER(L_PHI,0,0), // U+278
LETTER('r',M_TURNED,0),
0,//LETTER('r',M_TURNED,M_LEG),
LETTER('r',M_RETROFLEX,M_TURNED),
0,//LETTER('r',M_LEG,0),
LETTER('r',M_RETROFLEX,0),
0, // r-tap
LETTER(L_RTAP,M_REVERSED,0),
LETTER('r',M_SMALLCAP,0), // U+280
LETTER('r',M_TURNED,M_SMALLCAP),
LETTER('s',M_RETROFLEX,0),
0, // esh
0,//LETTER('j',M_BAR,L_IMPLOSIVE),
LETTER(L_ESH,M_REVERSED,0),
LETTER(L_ESH,M_CURL,0),
LETTER('t',M_TURNED,0),
LETTER('t',M_RETROFLEX,0), // U+288
LETTER('u',M_BAR,0),
LETTER(L_UPSILON,0,0),
LETTER('v',M_HOOK,0),
LETTER('v',M_TURNED,0),
LETTER('w',M_TURNED,0),
LETTER('y',M_TURNED,0),
LETTER('y',M_SMALLCAP,0),
LETTER('z',M_RETROFLEX,0), // U+290
LETTER('z',M_CURL,0),
0, // ezh
LETTER(L_EZH,M_CURL,0),
0, // glottal stop
LETTER(L_GLOTTAL,M_REVERSED,0),
LETTER(L_GLOTTAL,M_TURNED,0),
0,//LETTER('c',M_LONG,0),
0, // bilabial click // U+298
LETTER('b',M_SMALLCAP,0),
0,//LETTER(L_OPEN_E,M_CLOSED,0),
LETTER('g',M_IMPLOSIVE,M_SMALLCAP),
LETTER('h',M_SMALLCAP,0),
LETTER('j',M_CURL,0),
LETTER('k',M_TURNED,0),
LETTER('l',M_SMALLCAP,0),
LETTER('q',M_HOOK,0), // U+2a0
LETTER(L_GLOTTAL,M_STROKE,0),
LETTER(L_GLOTTAL,M_STROKE,M_REVERSED),
LIGATURE('d','z',0),
0, // dezh
LIGATURE('d','z',M_CURL),
LIGATURE('t','s',0),
0, // tesh
LIGATURE('t','s',M_CURL),
};
int Translator::LookupLetter2(unsigned int letter, char *ph_buf)
{//=============================================================
@@ -257,14 +391,15 @@ int Translator::LookupLetter2(unsigned int letter, char *ph_buf)
single_letter[0] = 0;
single_letter[1] = '_';
len = utf8_out(letter, &single_letter[2]);
single_letter[2+len] = 0;
single_letter[len+2] = ' ';
single_letter[len+3] = 0;
if(Lookup(&single_letter[1],ph_buf) == 0)
{
single_letter[1] = ' ';
if(Lookup(&single_letter[2],ph_buf) == 0)
{
TranslateRules(&single_letter[2], ph_buf, 20, NULL,0,0);
TranslateRules(&single_letter[2], ph_buf, 20, NULL,0,NULL);
}
}
return(ph_buf[0]);
@@ -274,45 +409,79 @@ int Translator::LookupLetter2(unsigned int letter, char *ph_buf)
void Translator::LookupAccentedLetter(unsigned int letter, char *ph_buf)
{//=====================================================================
// lookup the character in the accents table
int accent_data;
int accent1;
int accent_data = 0;
int accent1 = 0;
int accent2 = 0;
int basic_letter;
int letter2=0;
char ph_letter1[30];
char ph_letter2[30];
char ph_accent1[30];
char ph_accent2[30];
if((letter >= 0xe0) && (letter < 0x17f))
{
accent_data = letter_accents_0e0[letter - 0xe0];
}
else
if((letter >= 0x250) && (letter <= 0x2a8))
{
accent_data = letter_accents_250[letter - 0x250];
}
basic_letter = accent_data & 0x7f;
if((accent1 = (accent_data >> 8) & 0x7f) != 0)
if(accent_data != 0)
{
basic_letter = (accent_data & 0x3f) + 59;
if(basic_letter < 'a')
basic_letter = non_ascii_tab[basic_letter-59];
if(accent_data & 0x8000)
{
if(accent_data & 0x8000)
{
letter2 = accent1;
accent1 = 0;
}
letter2 = (accent_data >> 6) & 0x3f;
letter2 += 59;
accent2 = (accent_data >> 12) & 0x7;
}
else
{
accent1 = (accent_data >> 6) & 0x1f;
accent2 = (accent_data >> 11) & 0xf;
}
if(Lookup(accents_tab[accent1].name, ph_accent1) != 0)
{
if(LookupLetter2(basic_letter, ph_letter1) != 0)
if(Lookup(accents_tab[accent1].name, ph_accent1) != 0)
{
if(LookupLetter2(basic_letter, ph_letter1) != 0)
{
if(accent2 != 0)
{
if(Lookup(accents_tab[accent2].name, ph_accent2) == 0)
{
// break;
}
if(accents_tab[accent2].flags & 1)
{
strcpy(ph_buf,ph_accent2);
ph_buf += strlen(ph_buf);
ph_accent2[0] = 0;
}
}
if(letter2 != 0)
{
//ligature
LookupLetter2(letter2, ph_letter2);
sprintf(ph_buf,"%s%c%s%c%s%s",ph_accent1, phonPAUSE_VSHORT, ph_letter1, phonSTRESS_P, ph_letter2, ph_accent2);
}
else
{
if(accent1 == 0)
{
//ligature
LookupLetter2(letter2, ph_letter2);
sprintf(ph_buf,"%s%c%s%s",ph_accent1, phonPAUSE_VSHORT, ph_letter1, ph_letter2);
}
strcpy(ph_buf, ph_letter1);
else
{
if(langopts.accents & 1)
sprintf(ph_buf,"%s%c%s", ph_accent1, phonPAUSE_VSHORT, ph_letter1);
else
sprintf(ph_buf,"%s%c%s%c", ph_letter1, phonPAUSE_VSHORT, ph_accent1, phonPAUSE_VSHORT);
}
if((langopts.accents & 1) || (accents_tab[accent1].flags & 1))
sprintf(ph_buf,"%s%c%c%s", ph_accent1, phonPAUSE_VSHORT, phonSTRESS_P, ph_letter1);
else
sprintf(ph_buf,"%s%c%s%c", ph_letter1, phonPAUSE_VSHORT, ph_accent1, phonPAUSE_VSHORT);
}
}
}
@@ -379,7 +548,7 @@ void Translator::LookupLetter(unsigned int letter, int next_byte, char *ph_buf1)
single_letter[1] = ' ';
if(Lookup(&single_letter[2],ph_buf3) == 0)
{
TranslateRules(&single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,0,0);
TranslateRules(&single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,0,NULL);
}
}
@@ -451,7 +620,8 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control, int wor
return(0);
}
if((ph_buf[0] == 0) && (word_length == 1) && (translator_name != L('e','n')))
if((ph_buf[0] == 0) && (translator_name != L('e','n')))
// if((ph_buf[0] == 0) && (word_length == 1) && (translator_name != L('e','n')))
{
// speak as English, check whether there is a translation for this character
SetTranslator2("en");
@@ -473,7 +643,7 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control, int wor
if((ph_buf[0]==0) && !iswspace(letter))
Lookup("_??",ph_buf);
if((control==4) && (ph_buf[0] != 0))
if(ph_buf[0] != 0)
{
// speak the hexadecimal number of the character code
sprintf(hexbuf,"%x",letter);