[1.46.45]

Indian languages, rename aspirated phonemes with # instead of h (eg. [t#] not [th]).


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@311 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2013-03-10 13:58:09 +00:00
parent ad8798cf22
commit 6691b67f02
35 changed files with 2174 additions and 2172 deletions
+96 -106
View File
@@ -67,7 +67,8 @@ MNEM_TAB mnem_rules[] = {
{"p_alt5", 0x25},
{"p_alt6", 0x26},
{"p_alt", 0x21},
{NULL, -1} };
{NULL, -1}
};
MNEM_TAB mnem_flags[] = {
// these in the first group put a value in bits0-3 of dictionary_flags
@@ -182,13 +183,13 @@ const char *LookupMnemName(MNEM_TAB *table, const int value)
//==========================================================
/* Lookup a mnemonic string in a table, return its name */
{
while(table->mnem != NULL)
{
if(table->value==value)
return(table->mnem);
table++;
}
return(""); /* not found */
while(table->mnem != NULL)
{
if(table->value==value)
return(table->mnem);
table++;
}
return(""); /* not found */
} /* end of LookupMnemValue */
@@ -200,27 +201,27 @@ void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len)
int len;
int total = 0;
buf[0] = 0;
buf[0] = 0;
if((stress = flags[0] & 0xf) != 0)
{
sprintf(buf, "%s", LookupMnemName(mnem_flags, stress + 0x40));
total = strlen(buf);
buf += total;
sprintf(buf, "%s", LookupMnemName(mnem_flags, stress + 0x40));
total = strlen(buf);
buf += total;
}
for(ix=8; ix<64; ix++)
{
if(((ix < 30) && (flags[0] & (1 << ix))) || ((ix >= 0x20) && (flags[1] & (1 << (ix-0x20)))))
{
name = LookupMnemName(mnem_flags, ix);
len = strlen(name) + 1;
total += len;
if(total >= buf_len)
continue;
sprintf(buf, " %s", name);
buf += len;
}
}
for(ix=8; ix<64; ix++)
{
if(((ix < 30) && (flags[0] & (1 << ix))) || ((ix >= 0x20) && (flags[1] & (1 << (ix-0x20)))))
{
name = LookupMnemName(mnem_flags, ix);
len = strlen(name) + 1;
total += len;
if(total >= buf_len)
continue;
sprintf(buf, " %s", name);
buf += len;
}
}
}
@@ -228,12 +229,12 @@ void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len)
char *DecodeRule(const char *group_chars, int group_length, char *rule, int control)
{//=================================================================================
/* Convert compiled match template to ascii */
/* Convert compiled match template to ascii */
unsigned char rb;
unsigned char rb;
unsigned char c;
char *p;
int ix;
int ix;
int match_type;
int finished=0;
int value;
@@ -243,18 +244,20 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
int condition_num=0;
int at_start = 0;
const char *name;
char buf[60];
char buf_pre[60];
char buf[60];
char buf_pre[60];
char suffix[20];
static char output[60];
static char symbols[] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
'&','%','+','#','S','D','Z','A','L','!',' ','@','?','J','N','K','V','?','T','X','?','W'};
static char symbols[] =
{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
'&','%','+','#','S','D','Z','A','L','!',' ','@','?','J','N','K','V','?','T','X','?','W'
};
static char symbols_lg[] = {'A','B','C','H','F','G','Y'};
match_type = 0;
buf_pre[0] = 0;
buf_pre[0] = 0;
for(ix=0; ix<group_length; ix++)
{
@@ -263,8 +266,8 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
buf[ix] = 0;
p = &buf[strlen(buf)];
while(!finished)
{
while(!finished)
{
rb = *rule++;
if(rb <= RULE_LINENUM)
@@ -315,8 +318,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
}
c = ' ';
}
else
if(rb == RULE_ENDING)
else if(rb == RULE_ENDING)
{
static const char *flag_chars = "eipvdfq tba ";
flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f);
@@ -325,7 +327,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
suffix_char = 'P';
sprintf(suffix,"%c%d",suffix_char,rule[2] & 0x7f);
rule += 3;
for(ix=0;ix<9;ix++)
for(ix=0; ix<9; ix++)
{
if(flags & 1)
sprintf(&suffix[strlen(suffix)],"%c",flag_chars[ix]);
@@ -335,13 +337,11 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
p += strlen(suffix);
c = ' ';
}
else
if(rb == RULE_LETTERGP)
else if(rb == RULE_LETTERGP)
{
c = symbols_lg[*rule++ - 'A'];
}
else
if(rb == RULE_LETTERGP2)
else if(rb == RULE_LETTERGP2)
{
value = *rule++ - 'A';
p[0] = 'L';
@@ -355,11 +355,9 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
}
p+=2;
}
else
if(rb <= RULE_LAST_RULE)
else if(rb <= RULE_LAST_RULE)
c = symbols[rb];
else
if(rb == RULE_SPACE)
else if(rb == RULE_SPACE)
c = '_';
else
c = rb;
@@ -393,7 +391,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
while(ix < 8)
output[ix++]=' ';
output[ix]=0;
return(output);
return(output);
} /* end of DecodeRule */
@@ -427,7 +425,7 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
unsigned char flag_codes[100];
char encoded_ph[200];
unsigned char bad_phoneme[4];
static char nullstring[] = {0};
static char nullstring[] = {0};
text_not_phonemes = 0;
phonetic = word = nullstring;
@@ -500,13 +498,11 @@ static char nullstring[] = {0};
{
text_mode = 1;
}
else
if(flagnum == 201)
else if(flagnum == 201)
{
text_mode = 0;
}
else
if(flagnum == BITNUM_FLAG_TEXTMODE)
else if(flagnum == BITNUM_FLAG_TEXTMODE)
{
text_not_phonemes = 1;
}
@@ -536,8 +532,7 @@ static char nullstring[] = {0};
word = p+1;
step = 1;
}
else
if(!isspace2(c))
else if(!isspace2(c))
{
word = p;
step = 1;
@@ -571,8 +566,7 @@ static char nullstring[] = {0};
step = 3;
}
}
else
if(c == ')')
else if(c == ')')
{
if(multiple_words)
{
@@ -580,8 +574,7 @@ static char nullstring[] = {0};
multiple_words = 0;
step = 3;
}
else
if(word[0] != '_')
else if(word[0] != '_')
{
fprintf(f_log, "%5d: Missing '('\n", linenum);
error_count++;
@@ -595,8 +588,7 @@ static char nullstring[] = {0};
{
multiple_words++;
}
else
if(c == ')')
else if(c == ')')
{
p[0] = ' '; // terminate extra string
multiple_string_end = p+1;
@@ -641,8 +633,8 @@ static char nullstring[] = {0};
// This is a special word, used by eSpeak. Translate this into phonemes now
strcat(phonetic, " "); // need a space to indicate word-boundary
// PROBLEM vowel reductions are not applied to the translated phonemes
// condition rules are not applied
// PROBLEM vowel reductions are not applied to the translated phonemes
// condition rules are not applied
TranslateWord(translator,phonetic,0,NULL,NULL);
text_not_phonemes = 0;
strncpy0(encoded_ph, word_phonemes, N_WORD_BYTES-4);
@@ -653,11 +645,11 @@ static char nullstring[] = {0};
error_need_dictionary++;
fprintf(f_log,"%5d: Need to compile dictionary again\n",linenum);
}
{
{
//char decoded_phonemes[128];
//DecodePhonemes(word_phonemes,decoded_phonemes);
//printf("Translator %x %s [%s] [%s]\n",translator->translator_name,word,phonetic,decoded_phonemes);
}
}
}
else
{
@@ -694,8 +686,7 @@ static char nullstring[] = {0};
ix = utf8_out(wc, word);
word[ix] = 0;
}
else
if(word[0] != '_')
else if(word[0] != '_')
{
// convert to lower case, and note if the word is all-capitals
int c2;
@@ -1082,8 +1073,7 @@ static void copy_rule_string(char *string, int &state)
fprintf(f_log,"%5d: Expected 2 digits after 'L'\n",linenum);
error_count++;
}
else
if((c <= 0) || (c >= N_LETTER_GROUPS) || (letterGroupsDefined[(int)c] == 0))
else if((c <= 0) || (c >= N_LETTER_GROUPS) || (letterGroupsDefined[(int)c] == 0))
{
fprintf(f_log,"%5d: Letter group L%.2d not defined\n",linenum,c);
error_count++;
@@ -1162,9 +1152,9 @@ static void copy_rule_string(char *string, int &state)
case 'a':
sxflags |= SUFX_A;
break;
case 'm':
sxflags |= SUFX_M;
break;
case 'm':
sxflags |= SUFX_M;
break;
default:
if(isdigit(c))
value = (value*10) + (c - '0');
@@ -1376,11 +1366,11 @@ int __cdecl string_sorter(char **a, char **b)
char *pa, *pb;
int ix;
if((ix = strcmp(pa = *a,pb = *b)) != 0)
return(ix);
if((ix = strcmp(pa = *a,pb = *b)) != 0)
return(ix);
pa += (strlen(pa)+1);
pb += (strlen(pb)+1);
return(strcmp(pa,pb));
return(strcmp(pa,pb));
} /* end of string_sorter */
@@ -1471,12 +1461,12 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
if(rule_pre[0] != 0)
{
p = buf;
for(ix=strlen(rule_pre)-1;ix>=0;ix--)
for(ix=strlen(rule_pre)-1; ix>=0; ix--)
*p++ = rule_pre[ix];
sprintf(p,") ");
spaces -= strlen(buf);
for(ix=0; ix<spaces; ix++)
fputc(' ',f_out);
fputc(' ',f_out);
fprintf(f_out,"%s",buf);
spaces = 0;
}
@@ -1580,7 +1570,7 @@ static int compile_lettergroup(char *input, FILE *f_out)
int length;
int max_length = 0;
#define N_LETTERGP_ITEMS 200
#define N_LETTERGP_ITEMS 200
char *items[N_LETTERGP_ITEMS];
char item_length[N_LETTERGP_ITEMS];
@@ -1797,37 +1787,37 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
break;
case 2: // .replace
{
int replace1;
int replace2;
char *p;
{
int replace1;
int replace2;
char *p;
p = buf;
replace1 = 0;
replace2 = 0;
while(isspace2(*p)) p++;
ix = 0;
while((unsigned char)(*p) > 0x20) // not space or zero-byte
{
p += utf8_in(&c,p);
replace1 += (c << ix);
ix += 16;
}
while(isspace2(*p)) p++;
ix = 0;
while((unsigned char)(*p) > 0x20)
{
p += utf8_in(&c,p);
replace2 += (c << ix);
ix += 16;
}
if(replace1 != 0)
{
Write4Bytes(f_out,replace1); // write as little-endian
Write4Bytes(f_out,replace2); // if big-endian, reverse the bytes in LoadDictionary()
}
p = buf;
replace1 = 0;
replace2 = 0;
while(isspace2(*p)) p++;
ix = 0;
while((unsigned char)(*p) > 0x20) // not space or zero-byte
{
p += utf8_in(&c,p);
replace1 += (c << ix);
ix += 16;
}
break;
while(isspace2(*p)) p++;
ix = 0;
while((unsigned char)(*p) > 0x20)
{
p += utf8_in(&c,p);
replace2 += (c << ix);
ix += 16;
}
if(replace1 != 0)
{
Write4Bytes(f_out,replace1); // write as little-endian
Write4Bytes(f_out,replace2); // if big-endian, reverse the bytes in LoadDictionary()
}
}
break;
}
}
fclose(f_temp);