Merge branch 'master' into android

This commit is contained in:
Reece H. Dunn
2013-03-14 17:08:01 +00:00
186 changed files with 16197 additions and 10825 deletions
+50 -11
View File
@@ -44,6 +44,7 @@
extern void FindPhonemesUsed(void);
extern void DisplayErrorFile(const char *fname);
extern int utf8_in(int *c, const char *buf);
extern int utf8_out(unsigned int c, char *buf);
extern void DrawEnvelopes();
extern void ReadPhondataManifest();
@@ -157,6 +158,7 @@ static keywtab_t k_properties[] = {
enum {
kPHONEMESTART = 1,
kUTF8_BOM,
kPROCEDURE,
kENDPHONEME,
kENDPROCEDURE,
@@ -210,6 +212,8 @@ enum {
kTUNE_SPLIT,
};
static const char utf8_bom[] = {0xef,0xbb,0xbf,0};
static keywtab_t k_intonation[] = {
{"tune", 0, kTUNE},
{"endtune", 0, kENDTUNE},
@@ -250,6 +254,7 @@ static keywtab_t keywords[] = {
{"phonemenumber",tSTATEMENT, kPHONEMENUMBER},
{"phonemetable",tSTATEMENT, kPHONEMETABLE},
{"include", tSTATEMENT, kINCLUDE},
{utf8_bom, tSTATEMENT, kUTF8_BOM},
{"phoneme", tSTATEMENT, kPHONEMESTART},
{"procedure", tSTATEMENT, kPROCEDURE},
@@ -2720,11 +2725,14 @@ int CompilePhoneme(int compile_phoneme)
int keyword;
int value;
int phcode = 0;
int flags;
int ix;
unsigned int c;
int start;
int count;
int c;
char *p;
char number_buf[12];
char ipa_buf[N_ITEM_STRING];
char ipa_buf[N_ITEM_STRING+1];
PHONEME_TAB phoneme_out2;
PHONEME_PROG_LOG phoneme_prog_log;
@@ -2852,32 +2860,58 @@ int CompilePhoneme(int compile_phoneme)
strcpy(item_string," ");
// copy the string, recognize characters in the form U+9999
p = item_string;
ix = 0;
while((c = *p++) != 0)
flags = 0;
count = 0;
ix = 1;
for(p=item_string; *p != 0;)
{
p += utf8_in(&c, p);
if((c == '|') && (count > 0))
{
// '|' means don't allow a tie or joiner before this letter
flags |= (1 << (count -1));
}
else
if((c=='U') && (p[0]=='+'))
{
int j;
// U+9999
memcpy(number_buf,&p[1],4); // U+ should be followed by 4 hex digits
p++;
memcpy(number_buf,p,4); // U+ should be followed by 4 hex digits
number_buf[4] = 0;
c = 0;
c = '#';
sscanf(number_buf,"%x",&c);
p += 5;
// move past the 4 hexdecimal digits
for(j=0; j<4; j++)
{
if(!isalnum(*p))
break;
p++;
}
ix += utf8_out(c, &ipa_buf[ix]);
count++;
}
else
{
ipa_buf[ix++] = c;
ix += utf8_out(c, &ipa_buf[ix]);
count++;
}
}
ipa_buf[0] = flags;
ipa_buf[ix] = 0;
value = strlen(ipa_buf); // number of UTF-8 bytes
start = 1;
if(flags != 0)
start = 0; // only include the flags byte if bits are set
value = strlen(&ipa_buf[start]); // number of UTF-8 bytes
*prog_out++ = (i_IPA_NAME << 8) + value;
for(ix=0; ix < value; ix += 2)
{
*prog_out++ = (ipa_buf[ix] << 8) + (ipa_buf[ix+1] & 0xff);
*prog_out++ = (ipa_buf[ix+start] << 8) + (ipa_buf[ix+start+1] & 0xff);
}
break;
}
@@ -3400,6 +3434,9 @@ static void CompilePhonemeFiles()
switch(item)
{
case kUTF8_BOM:
break; // ignore bytes 0xef 0xbb 0xbf
case kINCLUDE:
NextItem(tSTRING);
sprintf(buf,"%s%s",path_source,item_string);
@@ -3606,7 +3643,9 @@ fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references
CompileReport();
report_dict = CompileAllDictionaries();
#ifdef MAKE_ENVELOPES
DrawEnvelopes();
#endif
if(gui_flag)
+145 -123
View File
@@ -51,17 +51,24 @@ static char letterGroupsDefined[N_LETTER_GROUPS];
MNEM_TAB mnem_rules[] = {
{"unpr", 0x01},
{"w_alt1", 0x11},
{"w_alt2", 0x12},
{"w_alt3", 0x13},
// {"w_alt4", 0x14},
{"w_alt4", 0x14},
{"w_alt5", 0x15},
{"w_alt6", 0x16},
{"w_alt", 0x11}, // note: put longer names before their sub-strings
{"p_alt1", 0x21},
{"p_alt2", 0x22},
{"p_alt3", 0x23},
// {"p_alt4", 0x24},
{"p_alt4", 0x24},
{"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
@@ -83,24 +90,22 @@ MNEM_TAB mnem_flags[] = {
// these set the corresponding numbered bit if dictionary_flags
{"$pause", 8}, /* ensure pause before this word */
{"$only", 9}, /* only match on this word without suffix */
{"$onlys", 10}, /* only match with none, or with 's' suffix */
{"$strend", 11}, /* full stress if at end of clause */
{"$strend2", 12}, /* full stress if at end of clause, or only followed by unstressed */
{"$unstressend",13}, /* reduce stress at end of clause */
{"$atend", 14}, /* use this pronunciation if at end of clause */
{"$atstart", 15}, // use this pronunciation at start of clause
{"$abbrev", 17}, /* use this pronuciation rather than split into letters */
{"$stem", 18}, // must have a suffix
{"$pause", 8}, // ensure pause before this word
{"$strend", 9}, // full stress if at end of clause
{"$strend2", 10}, // full stress if at end of clause, or only followed by unstressed
{"$unstressend",11}, // reduce stress at end of clause
{"$abbrev", 13}, // use this pronuciation rather than split into letters
// language specific
{"$double", 19}, // IT double the initial consonant of next word
{"$alt", 20}, // use alternative pronunciation
{"$alt1", 20}, // synonym for $alt
{"$alt2", 21},
{"$alt3", 22},
{"$double", 14}, // IT double the initial consonant of next word
{"$alt", 15}, // use alternative pronunciation
{"$alt1", 15}, // synonym for $alt
{"$alt2", 16},
{"$alt3", 17},
{"$alt4", 18},
{"$alt5", 19},
{"$alt6", 20},
{"$combine", 23}, // Combine with the next word
{"$dot", 24}, // ignore '.' after this word (abbreviation)
@@ -111,18 +116,23 @@ MNEM_TAB mnem_flags[] = {
{"$text", 29}, // word translates to replcement text, not phonemes
// flags in dictionary word 2
{"$verbf", 0x20}, /* verb follows */
{"$verbsf", 0x21}, /* verb follows, allow -s suffix */
{"$nounf", 0x22}, /* noun follows */
{"$pastf", 0x23}, /* past tense follows */
{"$verb", 0x24}, /* use this pronunciation when its a verb */
{"$noun", 0x25}, /* use this pronunciation when its a noun */
{"$past", 0x26}, /* use this pronunciation when its past tense */
{"$verbextend",0x28}, /* extend influence of 'verb follows' */
{"$capital", 0x29}, /* use this pronunciation if initial letter is upper case */
{"$allcaps", 0x2a}, /* use this pronunciation if initial letter is upper case */
{"$verbf", 0x20}, // verb follows
{"$verbsf", 0x21}, // verb follows, allow -s suffix
{"$nounf", 0x22}, // noun follows
{"$pastf", 0x23}, // past tense follows
{"$verb", 0x24}, // use this pronunciation when its a verb
{"$noun", 0x25}, // use this pronunciation when its a noun
{"$past", 0x26}, // use this pronunciation when its past tense
{"$verbextend",0x28}, // extend influence of 'verb follows'
{"$capital", 0x29}, // use this pronunciation if initial letter is upper case
{"$allcaps", 0x2a}, // use this pronunciation if initial letter is upper case
{"$accent", 0x2b}, // character name is base-character name + accent name
{"$sentence",0x2d}, // only if this clause is a sentence (i.e. terminator is {. ? !} not {, ; :}
{"$only", 0x2e}, // only match on this word without suffix
{"$onlys", 0x2f}, // only match with none, or with 's' suffix
{"$stem", 0x30}, // must have a suffix
{"$atend", 0x31}, // use this pronunciation if at end of clause
{"$atstart", 0x32}, // use this pronunciation at start of clause
// doesn't set dictionary_flags
{"$?", 100}, // conditional rule, followed by byte giving the condition number
@@ -173,22 +183,45 @@ 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 */
char *print_dictionary_flags(unsigned int *flags)
{//==============================================
static char buf[20];
void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len)
{//========================================================================
int stress;
int ix;
const char *name;
int len;
int total = 0;
sprintf(buf,"%s 0x%x/%x",LookupMnemName(mnem_flags,(flags[0] & 0xf)+0x40), flags[0], flags[1]);
return(buf);
buf[0] = 0;
if((stress = flags[0] & 0xf) != 0)
{
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;
}
}
}
@@ -196,12 +229,12 @@ char *print_dictionary_flags(unsigned int *flags)
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;
@@ -211,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++)
{
@@ -231,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)
@@ -283,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);
@@ -293,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]);
@@ -303,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';
@@ -323,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;
@@ -361,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 */
@@ -395,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;
@@ -468,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;
}
@@ -504,8 +532,7 @@ static char nullstring[] = {0};
word = p+1;
step = 1;
}
else
if(!isspace2(c))
else if(!isspace2(c))
{
word = p;
step = 1;
@@ -539,8 +566,7 @@ static char nullstring[] = {0};
step = 3;
}
}
else
if(c == ')')
else if(c == ')')
{
if(multiple_words)
{
@@ -548,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++;
@@ -563,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;
@@ -609,9 +633,9 @@ 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
TranslateWord(translator,phonetic,0,NULL);
// 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);
@@ -621,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
{
@@ -662,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;
@@ -1050,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++;
@@ -1130,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');
@@ -1344,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 */
@@ -1439,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;
}
@@ -1548,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];
@@ -1765,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);
+321 -341
View File
File diff suppressed because it is too large Load Diff
+13 -1
View File
@@ -67,6 +67,7 @@ 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\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"
@@ -362,7 +363,7 @@ int main (int argc, char **argv)
{"path", required_argument, 0, 0x107},
{"phonout", required_argument, 0, 0x108},
{"pho", no_argument, 0, 0x109},
{"ipa", no_argument, 0, 0x10a},
{"ipa", optional_argument, 0, 0x10a},
{"version", no_argument, 0, 0x10b},
{0, 0, 0, 0}
};
@@ -604,6 +605,17 @@ int main (int argc, char **argv)
case 0x10a: // --ipa
option_phonemes = 3;
if(optarg2 != NULL)
{
value = -1;
sscanf(optarg2,"%d",&value);
if((value<0) || (value>2))
{
fprintf(stderr,"Bad value for -ipa=\n");
value = 0;
}
option_phonemes += value;
}
break;
case 0x10b: // -version
+23 -23
View File
@@ -46,14 +46,14 @@ t_espeak_command* create_espeak_text(const void *text, size_t size, unsigned int
{
goto text_error;
}
a_text = malloc( size );
a_text = malloc( size+1 );
if (!a_text)
{
goto text_error;
}
memcpy(a_text, text, size);
a_command->type = ET_TEXT;
a_command->state = CS_UNDEFINED;
data = &(a_command->u.my_text);
@@ -102,7 +102,7 @@ t_espeak_command* create_espeak_terminated_msg(unsigned int unique_identifier, v
{
goto msg_error;
}
a_command->type = ET_TERMINATED_MSG;
a_command->state = CS_UNDEFINED;
data = &(a_command->u.my_terminated_msg);
@@ -234,7 +234,7 @@ t_espeak_command* create_espeak_char(wchar_t character, void* user_data)
{
goto char_error;
}
a_command->type = ET_CHAR;
a_command->state = CS_UNDEFINED;
a_command->u.my_char.user_data = user_data;
@@ -270,11 +270,11 @@ t_espeak_command* create_espeak_parameter(espeak_PARAMETER parameter, int value,
{
goto param_error;
}
a_command->type = ET_PARAMETER;
a_command->state = CS_UNDEFINED;
data = &(a_command->u.my_param);
data->parameter = parameter;
data->parameter = parameter;
data->value = value;
data->relative = relative;
a_error=0;
@@ -308,7 +308,7 @@ t_espeak_command* create_espeak_punctuation_list(const wchar_t *punctlist)
{
goto list_error;
}
a_command->type = ET_PUNCTUATION_LIST;
a_command->state = CS_UNDEFINED;
@@ -350,7 +350,7 @@ t_espeak_command* create_espeak_voice_name(const char *name)
{
goto name_error;
}
a_command->type = ET_VOICE_NAME;
a_command->state = CS_UNDEFINED;
a_command->u.my_voice_name = strdup( name);
@@ -381,7 +381,7 @@ t_espeak_command* create_espeak_voice_spec(espeak_VOICE *voice)
{
goto spec_error;
}
a_command->type = ET_VOICE_SPEC;
a_command->state = CS_UNDEFINED;
{
@@ -451,11 +451,11 @@ int delete_espeak_command( t_espeak_command* the_command)
break;
case ET_TERMINATED_MSG:
{
{
// if the terminated msg is pending,
// it must be processed here for informing the calling program
// it must be processed here for informing the calling program
// that its message is finished.
// This can be important for cleaning the related user data.
// This can be important for cleaning the related user data.
t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
if (the_command->state == CS_PENDING)
{
@@ -491,7 +491,7 @@ int delete_espeak_command( t_espeak_command* the_command)
free((void*)(the_command->u.my_voice_name));
}
break;
case ET_VOICE_SPEC:
{
espeak_VOICE* data = &(the_command->u.my_voice_spec);
@@ -542,23 +542,23 @@ void process_espeak_command( t_espeak_command* the_command)
case ET_TEXT:
{
t_espeak_text* data = &(the_command->u.my_text);
sync_espeak_Synth( data->unique_identifier, data->text, data->size,
data->position, data->position_type,
data->end_position, data->flags, data->user_data);
sync_espeak_Synth( data->unique_identifier, data->text, data->size,
data->position, data->position_type,
data->end_position, data->flags, data->user_data);
}
break;
case ET_MARK:
{
t_espeak_mark* data = &(the_command->u.my_mark);
sync_espeak_Synth_Mark( data->unique_identifier, data->text, data->size,
data->index_mark, data->end_position, data->flags,
sync_espeak_Synth_Mark( data->unique_identifier, data->text, data->size,
data->index_mark, data->end_position, data->flags,
data->user_data);
}
break;
case ET_TERMINATED_MSG:
{
{
t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
sync_espeak_terminated_msg( data->unique_identifier, data->user_data);
}
@@ -654,8 +654,8 @@ void display_espeak_command( t_espeak_command* the_command)
{
t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
SHOW("display_espeak_command > (0x%x) TERMINATED_MSG uid=%d, user_data=0x%x, state=%d\n",
the_command, data->unique_identifier, data->user_data,
SHOW("display_espeak_command > (0x%x) TERMINATED_MSG uid=%d, user_data=0x%x, state=%d\n",
the_command, data->unique_identifier, data->user_data,
the_command->state);
}
break;
@@ -670,7 +670,7 @@ void display_espeak_command( t_espeak_command* the_command)
case ET_PARAMETER:
{
t_espeak_parameter* data = &(the_command->u.my_param);
SHOW("display_espeak_command > (0x%x) PARAMETER=%d, value=%d, relative=%d\n",
SHOW("display_espeak_command > (0x%x) PARAMETER=%d, value=%d, relative=%d\n",
the_command, data->parameter, data->value, data->relative);
}
break;
+5 -5
View File
@@ -464,7 +464,7 @@ void Lexicon_It(int pass)
}
// translate
TranslateWord(translator,&word1[1],0, NULL);
TranslateWord(translator,&word1[1],0, NULL, NULL);
DecodePhonemes(word_phonemes,phonemes);
stress_posn1 = 0;
@@ -487,7 +487,7 @@ void Lexicon_It(int pass)
vowel_ix++;
}
TranslateWord(translator,&word2[1],0, NULL);
TranslateWord(translator,&word2[1],0, NULL, NULL);
DecodePhonemes(word_phonemes,phonemes2);
vowel_ix = 1;
@@ -802,7 +802,7 @@ void Lexicon_De()
}
// translate
TranslateWord(translator,&word2[1],0, NULL);
TranslateWord(translator,&word2[1],0, NULL, NULL);
DecodePhonemes2(word_phonemes,phonemes); // also need to change some phoneme names
@@ -1042,7 +1042,7 @@ void Lexicon_Bg()
*pw1 = 0;
// translate
TranslateWord(translator, &word[2],0, NULL);
TranslateWord(translator, &word[2],0, NULL, NULL);
DecodePhonemes(word_phonemes,phonemes);
// find the stress position in the translation
@@ -1300,7 +1300,7 @@ void Lexicon_Ru()
}
// translate
TranslateWord(translator, &word2[1],0, NULL);
TranslateWord(translator, &word2[1],0, NULL, NULL);
DecodePhonemes(word_phonemes,phonemes);
// find the stress position in the translation
+2 -2
View File
@@ -89,10 +89,10 @@ wxMenuBar *MakeMenu(int type, const char *dict_name)
// DATA MENU
data_menu = new wxMenu;
data_menu->Append(MENU_COMPILE_PH, _("Compile &phoneme data"));
data_menu->Append(MENU_COMPILE_PH2, _("Change sample &rate"));
data_menu->Append(MENU_COMPILE_DICT, _("Compile &dictionary"));
data_menu->Append(MENU_COMPILE_DICT_DEBUG, _("Compile dictionary (debu&g)"));
data_menu->Append(MENU_COMPILE_PH, _("Compile &phoneme data"));
data_menu->Append(MENU_COMPILE_PH2, _("Change sample &rate"));
data_menu->AppendSeparator();
data_menu->Append(MENU_COMPILE_MBROLA, _("Compile &mbrola phonemes list..."));
data_menu->Append(MENU_COMPILE_INTONATION, _("Compile &intonation data"));
+442 -419
View File
File diff suppressed because it is too large Load Diff
+44 -27
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2011 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -47,7 +47,6 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
int replace_flags;
int n_plist_out = 0;
int word_end;
int switched_language = 0;
PHONEME_LIST2 *plist2;
PHONEME_TAB *next=NULL;
@@ -55,11 +54,8 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
{
plist2 = &ph_list2[ix];
if(plist2->phcode == phonSWITCH)
switched_language ^= 1;
// don't do any substitution if the language has been temporarily changed
if(switched_language == 0)
if(!(plist2->synthflags & SFLAG_SWITCHED_LANG))
{
if(ix < (n_ph_list2 -1))
next = phoneme_tab[ph_list2[ix+1].phcode];
@@ -81,6 +77,9 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
if((replace_flags & 2) && ((plist2->stresslevel & 0x7) > 3))
continue; // this replacement doesn't occur in stressed syllables
if((replace_flags & 4) && (plist2->sourceix == 0))
continue; // this replacement only occurs at the start of a word
// substitute the replacement phoneme
plist2->phcode = replace_phonemes[k].new_ph;
if((plist2->stresslevel > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
@@ -117,7 +116,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
PHONEME_TAB *next, *next2;
int unstress_count = 0;
int word_stress = 0;
int switched_language = 0;
int current_phoneme_tab;
int max_stress;
int voicing;
int regression;
@@ -133,7 +132,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
PHONEME_LIST2 *plist2;
WORD_PH_DATA worddata;
memset(&worddata, 0, sizeof(worddata));
memset(&worddata, 0, sizeof(worddata));
plist2 = ph_list2;
phlist = phoneme_list;
end_sourceix = plist2[n_ph_list2-1].sourceix;
@@ -142,7 +141,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
max_stress = 0;
for(j = n_ph_list2-3; j>=0; j--)
{
// start with the last phoneme (before the terminating pauses) and move forwards
// start with the last phoneme (before the terminating pauses) and move backwards
if((plist2[j].stresslevel & 0x7f) > max_stress)
max_stress = plist2[j].stresslevel & 0x7f;
if(plist2[j].sourceix != 0)
@@ -166,6 +165,20 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
}
}
// look for switch of phoneme tables
current_phoneme_tab = tr->phoneme_tab_ix;
for(j = 0; j < n_ph_list2; j++)
{
if(plist2[j].phcode == phonSWITCH)
{
current_phoneme_tab = plist2[j].tone_ph;
}
if(current_phoneme_tab != tr->phoneme_tab_ix)
{
plist2[j].synthflags |= SFLAG_SWITCHED_LANG;
}
}
if((regression = tr->langopts.param[LOPT_REGRESSIVE_VOICING]) != 0)
{
// set consonant clusters to all voiced or all unvoiced
@@ -180,10 +193,14 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(ph == NULL)
continue;
if(ph->code == phonSWITCH)
switched_language ^= 1;
if(switched_language)
if(plist2[j].synthflags & SFLAG_SWITCHED_LANG)
{
stop_propagation = 0;
voicing = 0;
if(regression & 0x100)
voicing = 1; // word-end devoicing
continue;
}
type = ph->type;
@@ -204,21 +221,18 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
{
voicing = 1;
}
else
if((voicing==2) && (ph->end_type != 0)) // use end_type field for voicing_switch for consonants
else if((voicing==2) && (ph->end_type != 0)) // use end_type field for voicing_switch for consonants
{
plist2[j].phcode = ph->end_type; // change to voiced equivalent
}
}
else
if((type==phVSTOP) || type==(phVFRICATIVE))
else if((type==phVSTOP) || type==(phVFRICATIVE))
{
if((voicing==0) && (regression & 0xf))
{
voicing = 2;
}
else
if((voicing==1) && (ph->end_type != 0))
else if((voicing==1) && (ph->end_type != 0))
{
plist2[j].phcode = ph->end_type; // change to unvoiced equivalent
}
@@ -298,8 +312,6 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
ph = phoneme_tab[phonPAUSE];
ph_list3[0].ph = ph;
switched_language = 0;
for(j=0; insert_ph || ((j < n_ph_list3) && (ix < N_PHONEME_LIST-3)); j++)
{
plist3 = &ph_list3[j];
@@ -331,9 +343,14 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(plist3->phcode == phonSWITCH)
{
if(!(plist3->synthflags & SFLAG_EMBEDDED)) // ?? phonSWITCH can't have SFLAG_EMBEDDED ??
{
if((plist3[1].phcode == phonSWITCH) || ((plist3[1].type == phPAUSE) && (plist3[2].phcode == phonSWITCH)))
continue; // next phoneme is also a phonSWITCH, so ignore
}
// change phoneme table
SelectPhonemeTable(plist3->tone_ph);
switched_language ^= SFLAG_SWITCHED_LANG;
}
next = phoneme_tab[plist3[1].phcode]; // the phoneme after this one
plist3[1].ph = next;
@@ -428,7 +445,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
{
// in a sequence of unstressed syllables, reduce alternate syllables to 'diminished'
// stress. But not for the last phoneme of a stressed word
if((tr->langopts.stress_flags & 0x2) || ((word_stress > 3) && ((plist3+1)->sourceix!=0)))
if((tr->langopts.stress_flags & S_NO_DIM) || ((word_stress > 3) && ((plist3+1)->sourceix!=0)))
{
// An unstressed final vowel of a stressed word
unstress_count=1; // try again for next syllable
@@ -534,7 +551,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
phlist[ix].ph = ph;
phlist[ix].type = ph->type;
phlist[ix].env = PITCHfall; // default, can be changed in the "intonation" module
phlist[ix].synthflags = plist3->synthflags | switched_language;
phlist[ix].synthflags = plist3->synthflags;
phlist[ix].stresslevel = plist3->stresslevel & 0xf;
phlist[ix].wordstress = plist3->wordstress;
phlist[ix].tone_ph = plist3->tone_ph;
@@ -580,18 +597,18 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
phlist[ix].newword = 2; // end of clause
phlist[ix].phcode = phonPAUSE;
phlist[ix].type = phPAUSE; // terminate with 2 Pause phonemes
phlist[ix].type = phPAUSE; // terminate with 2 Pause phonemes
phlist[ix].length = post_pause; // length of the pause, depends on the punctuation
phlist[ix].sourceix = end_sourceix;
phlist[ix].synthflags = 0;
phlist[ix++].ph = phoneme_tab[phonPAUSE];
phlist[ix++].ph = phoneme_tab[phonPAUSE];
phlist[ix].phcode = phonPAUSE;
phlist[ix].type = phPAUSE;
phlist[ix].type = phPAUSE;
phlist[ix].length = 0;
phlist[ix].sourceix=0;
phlist[ix].synthflags = 0;
phlist[ix++].ph = phoneme_tab[phonPAUSE_SHORT];
phlist[ix++].ph = phoneme_tab[phonPAUSE_SHORT];
n_phoneme_list = ix;
} // end of MakePhonemeList
+6 -2
View File
@@ -224,6 +224,7 @@ void ProsodyDisplay::SelectPh(int index)
const char *name = "?";
char buf[120];
char len_string[20];
char param_string[20];
if(index < 0) return;
@@ -245,11 +246,14 @@ void ProsodyDisplay::SelectPh(int index)
y1 = p->pitch1;
y2 = p->pitch2;
len_string[0] = 0;
param_string[0] = 0;
if(p->std_length > 0)
sprintf(len_string," Length %d", p->std_length*2);
if(p->sound_param != 0)
sprintf(param_string,", %d", p->sound_param);
sprintf(buf,"Stress %s%d Amp %2d LengthMod %2d Pitch %3d %3d %s PhFlags %.2x [%s%s]",
emphasized,p->stresslevel&0x7,p->amp, p->length,y1,y2,name,p->ph->phflags, LookupManifest(p->phontab_addr), len_string);
sprintf(buf,"Stress %s%d Amp %2d LengthMod %2d Pitch %3d %3d %s PhFlags %.2x (%s%s)%s",
emphasized,p->stresslevel&0x7,p->amp, p->length,y1,y2,name,p->ph->phflags, LookupManifest(p->phontab_addr), param_string, len_string);
wxLogStatus(wxString(buf,wxConvLocal));
}
+19 -10
View File
@@ -648,7 +648,7 @@ static const char *LookupCharName(Translator *tr, int c, int only)
}
}
if((only==0) && (phonemes[0] == 0) && (tr->translator_name != L('e','n')))
if((only==0) && ((phonemes[0] == 0) || (phonemes[0] == phonSWITCH)) && (tr->translator_name != L('e','n')))
{
// not found, try English
SetTranslator2("en");
@@ -847,14 +847,13 @@ static int LoadSoundFile2(const char *fname)
static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output, int *bufix, int end_clause)
{//==========================================================================================================
{//=============================================================================================================
// announce punctuation names
// c1: the punctuation character
// c2: the following character
int punct_count;
const char *punctname;
int found = 0;
const char *punctname = NULL;
int soundicon;
int attributes;
int short_pause;
@@ -863,6 +862,7 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
int bufix1;
char buf[200];
char buf2[80];
char ph_buf[30];
c2 = *c2_ptr;
buf[0] = 0;
@@ -872,12 +872,24 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
// add an embedded command to play the soundicon
sprintf(buf,"\001%dI ",soundicon);
UngetC(c2);
found = 1;
}
else
if((punctname = LookupCharName(tr, c1, 0)) != NULL)
{
found = 1;
if((c1 == '.') && (end_clause) && (c2 != '.'))
{
if(LookupSpecial(tr, "_.p", ph_buf))
{
punctname = ph_buf; // use word for 'period' instead of 'dot'
}
}
if(punctname == NULL)
{
punctname = LookupCharName(tr, c1, 0);
}
if(punctname == NULL)
return(-1);
if((*bufix==0) || (end_clause ==0) || (tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2))
{
punct_count=1;
@@ -937,9 +949,6 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
}
}
if(found == 0)
return(-1);
bufix1 = *bufix;
len = strlen(buf);
strcpy(&output[*bufix],buf);
+1 -1
View File
@@ -892,7 +892,7 @@ if(stress <= 1)
{
// this is the last syllable in the clause, lengthen it - more for short vowels
len = (p->ph->std_length * 2);
if(tr->langopts.stress_flags & 0x40000)
if(tr->langopts.stress_flags & S_EO_CLAUSE1)
len=200; // don't lengthen short vowels more than long vowels at end-of-clause
length_mod = length_mod * (256 + (280 - len)/3)/256;
}
+13 -1
View File
@@ -101,6 +101,7 @@ 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\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"
@@ -485,7 +486,7 @@ int main (int argc, char **argv)
{"path", required_argument, 0, 0x107},
{"phonout", required_argument, 0, 0x108},
{"pho", no_argument, 0, 0x109},
{"ipa", no_argument, 0, 0x10a},
{"ipa", optional_argument, 0, 0x10a},
{"version", no_argument, 0, 0x10b},
{0, 0, 0, 0}
};
@@ -723,6 +724,17 @@ int main (int argc, char **argv)
case 0x10a: // --ipa
option_phonemes = 3;
if(optarg2 != NULL)
{
value = -1;
sscanf(optarg2,"%d",&value);
if((value<0) || (value>2))
{
fprintf(stderr,"Bad value for -ipa=\n");
value = 0;
}
option_phonemes += value;
}
break;
case 0x10b: // --version
+62 -62
View File
@@ -82,12 +82,12 @@ void WVoiceChanged(voice_t *wvoice)
static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
{//======================================================================
ENTER("dispatch_audio");
int a_wave_can_be_played = fifo_is_command_enabled();
#ifdef DEBUG_ENABLED
SHOW("*** dispatch_audio > uid=%d, [write=%p (%d bytes)], sample=%d, a_wave_can_be_played = %d\n",
(event) ? event->unique_identifier : 0, wave_test_get_write_buffer(), 2*length,
SHOW("*** dispatch_audio > uid=%d, [write=%p (%d bytes)], sample=%d, a_wave_can_be_played = %d\n",
(event) ? event->unique_identifier : 0, wave_test_get_write_buffer(), 2*length,
(event) ? event->sample : 0,
a_wave_can_be_played);
#endif
@@ -134,8 +134,8 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
while(a_wave_can_be_played) {
// TBD: some event are filtered here but some insight might be given
// TBD: in synthesise.cpp for avoiding to create WORDs with size=0.
// TBD: For example sentence "or ALT)." returns three words
// "or", "ALT" and "".
// TBD: For example sentence "or ALT)." returns three words
// "or", "ALT" and "".
// TBD: the last one has its size=0.
if (event && (event->type == espeakEVENT_WORD) && (event->length==0))
{
@@ -171,7 +171,7 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
}
SHOW_TIME("LEAVE dispatch_audio\n");
return (a_wave_can_be_played==0); // 1 = stop synthesis, -1 = error
}
@@ -183,12 +183,12 @@ static int create_events(short* outbuf, int length, espeak_EVENT* event, uint32_
int i=0;
// The audio data are written to the output device.
// The list of events in event_list (index: event_list_ix) is read:
// The list of events in event_list (index: event_list_ix) is read:
// Each event is declared to the "event" object which stores them internally.
// The event object is responsible of calling the external callback
// as soon as the relevant audio sample is played.
do
do
{ // for each event
espeak_EVENT* event;
if (event_list_ix == 0)
@@ -231,7 +231,7 @@ int sync_espeak_terminated_msg( uint32_t unique_identifier, void* user_data)
if (my_mode==AUDIO_OUTPUT_PLAYBACK)
{
while(1)
while(1)
{
espeak_ERROR a_error = event_declare(event_list);
if (a_error != EE_BUFFER_FULL)
@@ -290,14 +290,14 @@ static void select_output(espeak_AUDIO_OUTPUT output_type)
int GetFileLength(const char *filename)
{//====================================
struct stat statbuf;
if(stat(filename,&statbuf) != 0)
return(0);
if((statbuf.st_mode & S_IFMT) == S_IFDIR)
// if(S_ISDIR(statbuf.st_mode))
return(-2); // a directory
return(statbuf.st_size);
} // end of GetFileLength
@@ -337,7 +337,7 @@ static void init_path(const char *path)
{
sprintf(path_home,"%s/espeak-data",env);
if(GetFileLength(path_home) == -2)
return; // an espeak-data directory exists
return; // an espeak-data directory exists
}
buf[0] = 0;
@@ -362,7 +362,7 @@ static void init_path(const char *path)
{
snprintf(path_home,sizeof(path_home),"%s/espeak-data",env);
if(GetFileLength(path_home) == -2)
return; // an espeak-data directory exists
return; // an espeak-data directory exists
}
snprintf(path_home,sizeof(path_home),"%s/espeak-data",getenv("HOME"));
@@ -561,21 +561,21 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un
ENTER("MarkerEvent");
espeak_EVENT *ep;
double time;
if((event_list == NULL) || (event_list_ix >= (n_event_list-2)))
return;
ep = &event_list[event_list_ix++];
ep->type = (espeak_EVENT_TYPE)type;
ep->unique_identifier = my_unique_identifier;
ep->user_data = my_user_data;
ep->text_position = char_position & 0xffffff;
ep->length = char_position >> 24;
time = (double(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate;
ep->audio_position = int(time);
ep->sample = (count_samples + mbrola_delay + (out_ptr - out_start)/2);
#ifdef DEBUG_ENABLED
SHOW("MarkerEvent > count_samples=%d, out_ptr=%x, out_start=0x%x\n",count_samples, out_ptr, out_start);
SHOW("*** MarkerEvent > type=%s, uid=%d, text_pos=%d, length=%d, audio_position=%d, sample=%d\n",
@@ -605,22 +605,22 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un
espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
unsigned int position, espeak_POSITION_TYPE position_type,
espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
unsigned int position, espeak_POSITION_TYPE position_type,
unsigned int end_position, unsigned int flags, void* user_data)
{//===========================================================================
#ifdef DEBUG_ENABLED
ENTER("sync_espeak_Synth");
SHOW("sync_espeak_Synth > position=%d, position_type=%d, end_position=%d, flags=%d, user_data=0x%x, text=%s\n", position, position_type, end_position, flags, user_data, text);
#endif
espeak_ERROR aStatus;
InitText(flags);
my_unique_identifier = unique_identifier;
my_user_data = user_data;
for (int i=0; i < N_SPEECH_PARAM; i++)
saved_parameters[i] = param_stack[0].parameter[i];
@@ -629,26 +629,26 @@ espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text,
case POS_CHARACTER:
skip_characters = position;
break;
case POS_WORD:
skip_words = position;
break;
case POS_SENTENCE:
skip_sentences = position;
break;
}
if(skip_characters || skip_words || skip_sentences)
skipping_text = 1;
end_character_position = end_position;
aStatus = Synthesize(unique_identifier, text, flags);
#ifdef USE_ASYNC
wave_flush(my_audio);
#endif
SHOW_TIME("LEAVE sync_espeak_Synth");
return aStatus;
} // end of sync_espeak_Synth
@@ -656,29 +656,29 @@ espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text,
espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
const char *index_mark, unsigned int end_position,
espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
const char *index_mark, unsigned int end_position,
unsigned int flags, void* user_data)
{//=========================================================================
espeak_ERROR aStatus;
InitText(flags);
my_unique_identifier = unique_identifier;
my_user_data = user_data;
if(index_mark != NULL)
{
strncpy0(skip_marker, index_mark, sizeof(skip_marker));
skipping_text = 1;
}
end_character_position = end_position;
aStatus = Synthesize(unique_identifier, text, flags | espeakSSML);
SHOW_TIME("LEAVE sync_espeak_Synth_Mark");
return (aStatus);
} // end of sync_espeak_Synth_Mark
@@ -710,7 +710,7 @@ void sync_espeak_Char(wchar_t character)
char buf[80];
my_unique_identifier = 0;
my_user_data = NULL;
sprintf(buf,"<say-as interpret-as=\"tts:char\">&#%d;</say-as>",character);
Synthesize(0, buf,espeakSSML);
}
@@ -722,7 +722,7 @@ void sync_espeak_SetPunctuationList(const wchar_t *punctlist)
// Set the list of punctuation which are spoken for "some".
my_unique_identifier = 0;
my_user_data = NULL;
wcsncpy(option_punctlist, punctlist, N_PUNCTLIST);
option_punctlist[N_PUNCTLIST-1] = 0;
} // end of sync_espeak_SetPunctuationList
@@ -771,7 +771,7 @@ ENTER("espeak_Initialize");
setlocale(LC_CTYPE,"");
}
#endif
init_path(path);
initialise(options);
select_output(output_type);
@@ -788,30 +788,30 @@ ENTER("espeak_Initialize");
outbuf = (unsigned char*)realloc(outbuf,outbuf_size);
if((out_start = outbuf) == NULL)
return(EE_INTERNAL_ERROR);
// allocate space for event list. Allow 200 events per second.
// Add a constant to allow for very small buf_length
n_event_list = (buf_length*200)/1000 + 20;
if((event_list = (espeak_EVENT *)realloc(event_list,sizeof(espeak_EVENT) * n_event_list)) == NULL)
return(EE_INTERNAL_ERROR);
option_phonemes = 0;
option_mbrola_phonemes = 0;
option_phoneme_events = (options & (espeakINITIALIZE_PHONEME_EVENTS | espeakINITIALIZE_PHONEME_IPA));
VoiceReset(0);
// SetVoiceByName("default");
for(param=0; param<N_SPEECH_PARAM; param++)
param_stack[0].parameter[param] = saved_parameters[param] = param_defaults[param];
SetParameter(espeakRATE,175,0);
SetParameter(espeakVOLUME,100,0);
SetParameter(espeakCAPITALS,option_capitals,0);
SetParameter(espeakPUNCTUATION,option_punctuation,0);
SetParameter(espeakWORDGAP,0,0);
// DoVoiceChange(voice);
#ifdef USE_ASYNC
fifo_init();
#endif
@@ -821,10 +821,10 @@ ENTER("espeak_Initialize");
ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
unsigned int position,
ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
unsigned int position,
espeak_POSITION_TYPE position_type,
unsigned int end_position, unsigned int flags,
unsigned int end_position, unsigned int flags,
unsigned int* unique_identifier, void* user_data)
{//=====================================================================================
#ifdef DEBUG_ENABLED
@@ -885,10 +885,10 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
const char *index_mark,
unsigned int end_position,
unsigned int flags,
ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
const char *index_mark,
unsigned int end_position,
unsigned int flags,
unsigned int* unique_identifier,
void* user_data)
{//=========================================================================
@@ -919,15 +919,15 @@ ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
#ifdef USE_ASYNC
// Create the mark command
t_espeak_command* c1 = create_espeak_mark(text, size, index_mark, end_position,
t_espeak_command* c1 = create_espeak_mark(text, size, index_mark, end_position,
flags, user_data);
// Retrieve the unique identifier
*unique_identifier = c1->u.my_mark.unique_identifier;
// Create the "terminated msg" command (same uid)
t_espeak_command* c2 = create_espeak_terminated_msg(*unique_identifier, user_data);
// Try to add these 2 commands (single transaction)
if (c1 && c2)
{
@@ -1152,15 +1152,15 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream)
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
value=3 as (1), but produces IPA phoneme names rather than ascii
bit 4: produce mbrola pho data
*/
option_phonemes = value & 3;
option_phonemes = value & 7;
option_mbrola_phonemes = value & 16;
f_trans = stream;
if(stream == NULL)
f_trans = stderr;
} // end of espeak_SetPhonemes
@@ -1269,4 +1269,4 @@ ESPEAK_API const char *espeak_Info(const char **ptr)
#pragma GCC visibility pop
+3 -3
View File
@@ -51,7 +51,7 @@
#endif
#ifdef _ESPEAKEDIT
// USE_PORTAUDIO or USE_PULSEAUDIO are now defined in the makefile
#define USE_PORTAUDIO
#define USE_ASYNC
#define LOG_FRAMES // write keyframe info to log-espeakedit
#endif
@@ -76,9 +76,9 @@ int LookupMnem(MNEM_TAB *table, const char *string);
#ifdef PLATFORM_WINDOWS
#define N_PATH_HOME 220
#define N_PATH_HOME 230
#else
#define N_PATH_HOME 150
#define N_PATH_HOME 160
#endif
extern char path_home[N_PATH_HOME]; // this is the espeak-data directory
+2 -2
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -490,7 +490,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
if(ph->code != phonEND_WORD)
{
char phoneme_name[16];
WritePhMnemonic(phoneme_name, p->ph, p, option_phoneme_events & espeakINITIALIZE_PHONEME_IPA);
WritePhMnemonic(phoneme_name, p->ph, p, option_phoneme_events & espeakINITIALIZE_PHONEME_IPA, NULL);
DoPhonemeMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, phoneme_name);
}
+8 -2
View File
@@ -35,8 +35,8 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.46.38 27.Feb.13";
const int version_phdata = 0x014636;
const char *version_string = "1.46.48 13.Mar.13";
const int version_phdata = 0x014640;
int option_device_number = -1;
FILE *f_logespeak = NULL;
@@ -1225,9 +1225,15 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
#ifdef _ESPEAKEDIT
plist->std_length = phdata->pd_param[i_SET_LENGTH];
if(phdata->sound_addr[0] != 0)
{
plist->phontab_addr = phdata->sound_addr[0]; // FMT address
plist->sound_param = phdata->sound_param[0];
}
else
{
plist->phontab_addr = phdata->sound_addr[1]; // WAV address
plist->sound_param = phdata->sound_param[1];
}
#endif
} // end of InterpretPhoneme
+4 -5
View File
@@ -1438,7 +1438,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
}
else
{
WritePhMnemonic(phoneme_name, p->ph, p, use_ipa);
WritePhMnemonic(phoneme_name, p->ph, p, use_ipa, NULL);
DoPhonemeMarker(espeakEVENT_PHONEME, sourceix, 0, phoneme_name);
done_phoneme_marker = 1;
}
@@ -1751,7 +1751,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
if((option_phoneme_events) && (done_phoneme_marker == 0))
{
WritePhMnemonic(phoneme_name, p->ph, p, use_ipa);
WritePhMnemonic(phoneme_name, p->ph, p, use_ipa, NULL);
DoPhonemeMarker(espeakEVENT_PHONEME, sourceix, 0, phoneme_name);
}
@@ -1869,7 +1869,6 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
n_phoneme_list = 0;
WcmdqStop();
embedded_value[EMBED_T] = 0;
return(0);
}
@@ -1937,8 +1936,8 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
if((option_phonemes > 0) || (phoneme_callback != NULL))
{
int use_ipa = 0;
if(option_phonemes == 3)
use_ipa = 1;
if(option_phonemes >= 3)
use_ipa = option_phonemes-2; // 1=ipa, 2=ipa with tie, 3=ipa with ZWJ
GetTranslatedPhonemeString(translator->phon_out, sizeof(translator->phon_out), use_ipa);
if(option_phonemes > 0)
+2 -1
View File
@@ -56,7 +56,7 @@
#define EMBED_A 3 // amplitude/volume
#define EMBED_R 4 // pitch range/expression
#define EMBED_H 5 // echo/reverberation
#define EMBED_T 6 // different tone for announcing punctuation
#define EMBED_T 6 // different tone for announcing punctuation (not used)
#define EMBED_I 7 // sound icon
#define EMBED_S2 8 // speed (used in synthesize)
#define EMBED_Y 9 // say-as commands
@@ -223,6 +223,7 @@ typedef struct {
#ifdef _ESPEAKEDIT
unsigned char std_length;
unsigned int phontab_addr;
int sound_param;
#endif
} PHONEME_LIST;
+104 -66
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2011 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -70,48 +70,56 @@
#define OFFSET_ETHIOPIC 0x1200
// character ranges must be listed in ascending order
ALPHABET alphabets [] = {
{"_el", OFFSET_GREEK, 0x380, 0x3ff, L('e','l'), AL_DONT_NAME | AL_NOT_LETTERS},
{"_cyr", OFFSET_CYRILLIC, 0x400, 0x52f, 0, 0},
{"_hy", OFFSET_ARMENIAN, 0x530, 0x58f, L('h','y'), 0},
{"_hy", OFFSET_ARMENIAN, 0x530, 0x58f, L('h','y'), AL_WORDS},
{"_he", OFFSET_HEBREW, 0x590, 0x5ff, 0, 0},
{"_ar", OFFSET_ARABIC, 0x600, 0x6ff, 0, 0},
{"_dv", OFFSET_THAANA, 0x780, 0x7bf, 0, 0},
{"_hi", OFFSET_DEVANAGARI, 0x900, 0x97f,L('h','i'), 0},
{"_hi", OFFSET_DEVANAGARI, 0x900, 0x97f,L('h','i'), AL_WORDS},
{"_bn", OFFSET_BENGALI, 0x0980, 0x9ff, 0, 0},
{"_gur", OFFSET_GURMUKHI, 0xa00, 0xa7f, 0, 0},
{"_gur", OFFSET_GURMUKHI, 0xa00, 0xa7f, L('p','a'), AL_WORDS},
{"_gu", OFFSET_GUJARATI, 0xa80, 0xaff, 0, 0},
{"_or", OFFSET_ORIYA, 0xb00, 0xb7f, 0, 0},
{"_ta", OFFSET_TAMIL, 0xb80, 0xbff, L('t','a'), 0},
{"_te", OFFSET_TELUGU, 0xc00, 0xc7f, 0, 0},
{"_kn", OFFSET_KANNADA, 0xc80, 0xcff, L('k','n'), 0},
{"_ml", OFFSET_MALAYALAM,0xd00, 0xd7f, L('m','l'), 0},
{"_ta", OFFSET_TAMIL, 0xb80, 0xbff, L('t','a'), AL_WORDS},
{"_te", OFFSET_TELUGU, 0xc00, 0xc7f, L('t','e'), 0},
{"_kn", OFFSET_KANNADA, 0xc80, 0xcff, L('k','n'), AL_WORDS},
{"_ml", OFFSET_MALAYALAM,0xd00, 0xd7f, L('m','l'), AL_WORDS},
{"_si", OFFSET_SINHALA, 0xd80, 0xdff, 0, 0},
{"_th", OFFSET_THAI, 0xe00, 0xe7f, 0, 0},
{"_lo", OFFSET_LAO, 0xe80, 0xeff, 0, 0},
{"_ti", OFFSET_TIBET, 0xf00, 0xfff, 0, 0},
{"_my", OFFSET_MYANMAR, 0x1000,0x109f, 0, 0},
{"_ka", OFFSET_GEORGIAN, 0x10a0,0x10ff, L('k','a'), 0},
{"_ka", OFFSET_GEORGIAN, 0x10a0,0x10ff, L('k','a'), AL_WORDS},
{"_ko", OFFSET_KOREAN, 0x1100,0x11ff, 0, 0},
{"_eth", OFFSET_ETHIOPIC, 0x1200,0x139f, 0, 0},
{"_braille", 0x2800, 0x2800,0x28ff, 0, AL_NO_SYMBOL},
{"_ja", 0x3040, 0x3040,0x30ff, 0, AL_NOT_CODE},
{"_zh", 0x3100, 0x3100,0x9fff, 0, AL_NOT_CODE},
{"_ko", 0xa700, 0xa700,0xd7ff, 0, AL_NOT_CODE},
{NULL, 0, 0, 0, 0, 0}
};
ALPHABET *AlphabetFromChar(int c)
{//===============================
// Find the alphabet from a character.
ALPHABET *alphabet = alphabets;
// Find the alphabet from a character.
ALPHABET *alphabet = alphabets;
while(alphabet->name != NULL)
{
if((c >= alphabet->range_min) && (c <= alphabet->range_max))
{
return(alphabet);
}
alphabet++;
}
return(NULL);
while(alphabet->name != NULL)
{
if(c <= alphabet->range_max)
{
if(c >= alphabet->range_min)
return(alphabet);
else
break;
}
alphabet++;
}
return(NULL);
}
@@ -163,7 +171,7 @@ static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
// ignore these characters
static const unsigned short chars_ignore_default[] = {
0xad, 1, // soft hyphtn
0xad, 1, // soft hyphen
0x200c, 1, // zero width non-joiner
0x200d, 1, // zero width joiner
0, 0 };
@@ -217,6 +225,7 @@ static const char transpose_map_latin[] = {
tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8
dictionary_name[0] = 0;
tr->dict_condition=0;
tr->dict_min_size = 0;
tr->data_dictrules = NULL; // language_1 translation rules file
tr->data_dictlist = NULL; // language_2 dictionary lookup file
@@ -436,6 +445,9 @@ Translator *SelectTranslator(const char *name)
int name2 = 0;
Translator *tr;
static const short stress_lengths_equal[8] = {230, 230, 230, 230, 0, 0, 230, 230};
static const unsigned char stress_amps_equal[8] = {18,18, 18,18, 18,18, 18,18 };
static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 190, 240};
static const unsigned char stress_amps_fr[8] = {18,16, 18,18, 18,18, 18,18 };
@@ -474,7 +486,7 @@ Translator *SelectTranslator(const char *name)
SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
tr->letter_bits_offset = OFFSET_ETHIOPIC;
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x0024; // don't use secondary stress
tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
@@ -510,7 +522,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
tr->letter_bits_offset = OFFSET_BENGALI;
SetIndicLetters(tr); // call this after setting OFFSET_BENGALI
SetLetterBitsRange(tr,LETTERGP_F,0x3e,0x4c); // vowel signs, but not virama
@@ -546,7 +558,7 @@ Translator *SelectTranslator(const char *name)
// tr->langopts.intonation_group = 4;
// 'diminished' is an unstressed final syllable
tr->langopts.stress_flags = 0x6 | 0x10;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
@@ -597,7 +609,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->letter_bits_offset = OFFSET_THAANA;
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
SetLetterBitsRange(tr,LETTERGP_B,0x26,0x30); // vowel signs, and virama
tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
tr->langopts.numbers = 1;
@@ -647,7 +659,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
tr->langopts.stress_flags = S_FINAL_DIM_ONLY; // mark unstressed final syllables as diminished
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
@@ -677,7 +689,7 @@ Translator *SelectTranslator(const char *name)
// tr->langopts.word_gap = 1;
tr->langopts.vowel_pause = 2;
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x6 | 0x10;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
// tr->langopts.unstressed_wd1 = 3;
tr->langopts.unstressed_wd2 = 2;
@@ -701,7 +713,7 @@ Translator *SelectTranslator(const char *name)
// stress last syllable if it doesn't end in vowel or "s" or "n"
// 'diminished' is an unstressed final syllable
tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
@@ -711,18 +723,20 @@ Translator *SelectTranslator(const char *name)
if(name2 == L('c','a'))
{
// stress last syllable unless word ends with a vowel
tr->punct_within_word = ca_punct_within_word;
tr->langopts.stress_flags = 0x200 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
}
else
if(name2 == L('a','n'))
{
tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
}
else
if(name2 == L_pap)
{
tr->langopts.stress_flags = 0x100 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
// 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;
}
else
{
@@ -782,7 +796,7 @@ Translator *SelectTranslator(const char *name)
SetupTranslator(tr,stress_lengths_fi,stress_amps_fi);
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x56; // move secondary stress from light to a following heavy syllable
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_2_TO_HEAVY; // move secondary stress from light to a following heavy syllable
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
tr->langopts.long_stop = 130;
@@ -798,7 +812,7 @@ Translator *SelectTranslator(const char *name)
{
SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
tr->langopts.stress_flags = 0x0024; // don't use secondary stress
tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.accents = 2; // Say "Capital" after the letter.
@@ -808,9 +822,17 @@ Translator *SelectTranslator(const char *name)
}
break;
case L('g','a'): // irish
{
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.numbers = 1;
}
break;
case L('h','i'): // Hindi
case L('n','e'): // Nepali
case L('p','a'): // Punjabi
case L('g','u'): // Gujarati
{
static const short stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250};
static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,22, 22,21 };
@@ -820,7 +842,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
tr->langopts.numbers = NUM_SWAP_TENS;
tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
tr->letter_bits_offset = OFFSET_DEVANAGARI;
@@ -829,8 +851,17 @@ Translator *SelectTranslator(const char *name)
{
tr->letter_bits_offset = OFFSET_GURMUKHI;
}
else
if(name2 == L('g','u'))
{
SetupTranslator(tr,stress_lengths_equal,stress_amps_equal);
tr->letter_bits_offset = OFFSET_GUJARATI;
tr->langopts.stress_rule = STRESSPOSN_2R;
}
else
if(name2 == L('n','e'))
{
SetupTranslator(tr,stress_lengths_equal,stress_amps_equal);
tr->langopts.break_numbers = 0x2aaaa8;
tr->langopts.max_digits = 22;
tr->langopts.numbers2 |= NUM2_ENGLISH_NUMERALS;
@@ -855,7 +886,7 @@ Translator *SelectTranslator(const char *name)
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x10;
tr->langopts.stress_flags = S_FINAL_NO_2;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
tr->langopts.max_initial_consonants = 5;
tr->langopts.spelling_stress = 1;
@@ -874,7 +905,7 @@ Translator *SelectTranslator(const char *name)
case L('h','t'): // Haitian Creole
// memcpy(tr->stress_lengths,stress_lengths_fr,sizeof(tr->stress_lengths));
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
tr->langopts.stress_flags = 0x0024; // don't use secondary stress
tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL | NUM_DFRACTION_4;
break;
@@ -889,7 +920,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.vowel_pause = 0x20;
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x8036 | S_HYPEN_UNSTRESS;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2 | 0x8000 | S_HYPEN_UNSTRESS;
tr->langopts.unstressed_wd1 = 2;
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
tr->langopts.param[LOPT_ANNOUNCE_PUNCT] = 2; // don't break clause before announcing . ? !
@@ -922,7 +953,7 @@ SetLengthMods(tr,3); // all equal
SetLetterBits(tr,LETTERGP_C,hy_consonants);
tr->langopts.max_initial_consonants = 6;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
}
break;
@@ -934,7 +965,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_id,stress_amps_id);
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_ROMAN;
tr->langopts.stress_flags = 0x6 | 0x10;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.accents = 2; // "capital" after letter name
}
break;
@@ -946,7 +977,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_is,NULL);
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x10;
tr->langopts.stress_flags = S_FINAL_NO_2;
tr->langopts.param[LOPT_IT_LENGTHEN] = 0x11; // remove lengthen indicator from unstressed vowels
tr->langopts.param[LOPT_REDUCE] = 2;
@@ -969,7 +1000,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x10 | 0x20000;
tr->langopts.stress_flags = S_FINAL_NO_2 | S_PRIORITY_STRESS;
tr->langopts.vowel_pause = 1;
tr->langopts.unstressed_wd1 = 2;
tr->langopts.unstressed_wd2 = 2;
@@ -1003,8 +1034,10 @@ SetLengthMods(tr,3); // all equal
case L('k','a'): // Georgian
{
// character codes offset by 0x1080
static const char ka_vowels[] = {0x50,0x54,0x58,0x5d,0x63,0x75,0x77,0};
static const char ka_consonants[] = {0x51,0x52,0x53,0x55,0x56,0x57,0x59,0x5a,0x5b,0x5c,0x5e,0x5f,0x60,0x61,0x62,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x76,0};
static const char ka_vowels[] = {0x30,0x34,0x38,0x3d,0x43,0x55,0x57,0};
static const char ka_consonants[] =
{0x31,0x32,0x33,0x35,0x36,0x37,0x39,0x3a,0x3b,0x3c,0x3e,0x3f,0x40,0x41,0x42,0x44,
0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBits(tr,LETTERGP_A,ka_vowels);
@@ -1017,6 +1050,9 @@ SetLengthMods(tr,3); // all equal
// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
tr->langopts.max_initial_consonants = 7;
tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5 | NUM_ROMAN;
tr->langopts.alt_alphabet = OFFSET_CYRILLIC;
tr->langopts.alt_alphabet_lang = "ru";
}
break;
@@ -1091,7 +1127,7 @@ SetLengthMods(tr,3); // all equal
{
tr->charset_a0 = charsets[4]; // ISO-8859-4, includes a,e,i,o,u-macron
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x20;
tr->langopts.stress_flags = S_NO_AUTO_2;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_DIERESES] = 1;
@@ -1104,7 +1140,7 @@ SetLengthMods(tr,3); // all equal
{
tr->charset_a0 = charsets[4]; // ISO-8859-4
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x20;
tr->langopts.stress_flags = S_NO_AUTO_2;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_DIERESES] = 1;
@@ -1125,7 +1161,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.spelling_stress = 1;
tr->charset_a0 = charsets[4]; // ISO-8859-4
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
tr->langopts.stress_flags = 0x16 + 0x40000;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_EO_CLAUSE1;
}
break;
@@ -1191,7 +1227,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_om,stress_amps_om);
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x16 + 0x80000;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | 0x80000;
}
break;
@@ -1204,7 +1240,7 @@ SetLengthMods(tr,3); // all equal
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
tr->langopts.stress_flags = S_FINAL_DIM_ONLY; // mark unstressed final syllables as diminished
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
@@ -1223,7 +1259,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
tr->langopts.stress_flags = 0x6 | 0x10 | 0x2000 | 0x20000;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_INITIAL_2 | S_PRIORITY_STRESS;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN;
tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS;
SetLetterVowel(tr,'y');
@@ -1241,7 +1277,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_ro,stress_amps_ro);
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x100 + 0x6;
tr->langopts.stress_flags = S_FINAL_STRESS_C + 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;
@@ -1256,7 +1292,7 @@ SetLengthMods(tr,3); // all equal
case L('r','w'): // Kiryarwanda
{
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x16;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_2 | NUM_AND_HUNDRED;
@@ -1273,7 +1309,7 @@ SetLengthMods(tr,3); // all equal
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x16;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
tr->langopts.max_initial_consonants = 5;
tr->langopts.spelling_stress = 1;
@@ -1302,7 +1338,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = S_FINAL_DIM | S_NO_AUTO_DIM | S_FINAL_NO_2;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.spelling_stress = 1;
tr->letter_bits_offset = OFFSET_SINHALA;
@@ -1325,7 +1361,7 @@ SetLengthMods(tr,3); // all equal
case L('s','l'): // Slovenian
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.stress_rule = STRESSPOSN_2R; // Temporary
tr->langopts.stress_flags = 0x20;
tr->langopts.stress_flags = S_NO_AUTO_2;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x103;
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x76; // [v] don't count this character at start of word
tr->letter_bits['r'] |= 0x80; // add 'r' to letter group 7, vowels for Unpronouncable test
@@ -1342,7 +1378,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_sq,stress_amps_sq);
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x16 + 0x100;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_FINAL_STRESS_C;
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
@@ -1374,7 +1410,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.vowel_pause = 1;
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x6 | 0x10;
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_OMIT_1_HUNDRED;
tr->langopts.break_numbers = 0x49249268; // for languages which have numbers for 100,000 and 1,000,000
@@ -1391,7 +1427,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->langopts.stress_flags = S_FINAL_DIM_ONLY; // use 'diminished' for unstressed final syllable
tr->langopts.spelling_stress = 1;
tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
@@ -1437,7 +1473,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_th,stress_amps_th);
tr->langopts.stress_rule = 0; // stress on final syllable of a "word"
tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
tr->langopts.stress_flags = S_NO_DIM; // don't automatically set diminished stress (may be set in the intonation module)
tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
// tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
@@ -1456,7 +1492,7 @@ SetLengthMods(tr,3); // all equal
tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
tr->langopts.stress_flags = 0x20; //no automatic secondary stress
tr->langopts.stress_flags = S_NO_AUTO_2; //no automatic secondary stress
tr->langopts.param[LOPT_SUFFIX] = 1;
if(name2 == L('a','z'))
@@ -1472,14 +1508,14 @@ SetLengthMods(tr,3); // all equal
break;
case L('t','t'): // Tatar
{
{
SetCyrillicLetters(tr);
SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
tr->langopts.stress_flags = 0x20; //no automatic secondary stress
tr->langopts.stress_flags = S_NO_AUTO_2; //no automatic secondary stress
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_4;
}
break;
}
break;
case L('u','k'): // Ukrainian
{
@@ -1489,10 +1525,12 @@ SetLengthMods(tr,3); // all equal
break;
case L('u','r'): // Urdu
{
tr->letter_bits_offset = OFFSET_ARABIC;
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
tr->langopts.numbers = NUM_SWAP_TENS;
tr->langopts.break_numbers = 0x52a8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
}
break;
case L('v','i'): // Vietnamese
@@ -1511,7 +1549,7 @@ SetLengthMods(tr,3); // all equal
0x1a1, 0x1edd, 0x1edb, 0x1edf, 0x1ee1, 0x1ee3, // ơ
0x75, 0xf9, 0xfa, 0x1ee7, 0x169, 0x1ee5, // u
0x1b0, 0x1eeb, 0x1ee9, 0x1eed, 0x1eef, 0x1ef1, // ư
0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1e, 0 }; // y
0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1ef5, 0 }; // y
SetupTranslator(tr,stress_lengths_vi,stress_amps_vi);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
@@ -1541,7 +1579,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_zh,stress_amps_zh);
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable of a "word"
tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
tr->langopts.stress_flags = S_NO_DIM; // don't automatically set diminished stress (may be set in the intonation module)
tr->langopts.vowel_pause = 0;
tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
@@ -1598,7 +1636,7 @@ static void Translator_Russian(Translator *tr)
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 1;
tr->langopts.param[LOPT_REDUCE] = 2;
tr->langopts.stress_rule = 5;
tr->langopts.stress_flags = 0x0020; // waas 0x1010
tr->langopts.stress_flags = S_NO_AUTO_2;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
tr->langopts.numbers2 = 0x2 + NUM2_THOUSANDS_VAR1; // variant numbers before thousands
+477 -434
View File
File diff suppressed because it is too large Load Diff
+68 -38
View File
@@ -23,7 +23,7 @@
#define CTRL_EMBEDDED 0x01 // control character at the start of an embedded command
#define REPLACED_E 'E' // 'e' replaced by silent e
#define N_WORD_PHONEMES 160 // max phonemes in a word
#define N_WORD_PHONEMES 200 // max phonemes in a word
#define N_WORD_BYTES 160 // max bytes for the UTF8 characters in a word
#define N_CLAUSE_WORDS 300 // max words in a clause
#define N_RULE_GROUP2 120 // max num of two-letter rule chains
@@ -37,27 +37,22 @@
#define FLAG_SKIPWORDS 0x80
#define FLAG_PREPAUSE 0x100
#define FLAG_ONLY 0x200
#define FLAG_ONLY_S 0x400
#define BITNUM_FLAG_ONLY 9 // bit 9 is set
#define BITNUM_FLAG_ONLY_S 10 // bit 10 is set
#define FLAG_STRESS_END 0x200 // full stress if at end of clause
#define FLAG_STRESS_END2 0x400 // full stress if at end of clause, or only followed by unstressed
#define FLAG_UNSTRESS_END 0x800 // reduce stress at end of clause
#define FLAG_SPELLWORD 0x1000 // re-translate the word as individual letters, separated by spaces
#define FLAG_ABBREV 0x2000 // spell as letters, even with a vowel, OR use specified pronunciation rather than split into letters
#define FLAG_DOUBLING 0x4000 // doubles the following consonant
#define FLAG_STRESS_END 0x800 /* full stress if at end of clause */
#define FLAG_STRESS_END2 0x1000 /* full stress if at end of clause, or only followed by unstressed */
#define FLAG_UNSTRESS_END 0x2000 /* reduce stress at end of clause */
#define FLAG_ATEND 0x4000 /* use this pronunciation if at end of clause */
#define FLAG_ATSTART 0x8000 // use this pronunciation if at start of clause
#define FLAG_SPELLWORD 0x10000 // re-translate the word as individual letters, separated by spaces
#define FLAG_ABBREV 0x20000 // spell as letters, even with a vowel, OR use specified pronunciation rather than split into letters
#define FLAG_STEM 0x40000 // must have a suffix
#define BITNUM_FLAG_ALT 14 // bit number of FLAG_ALT_TRANS - 1
#define FLAG_ALT_TRANS 0x8000 // language specific
#define FLAG_ALT2_TRANS 0x10000 // language specific
#define FLAG_ALT3_TRANS 0x20000 // language specific
#define FLAG_ALT4_TRANS 0x40000 // language specific
#define FLAG_ALT5_TRANS 0x80000 // language specific
#define FLAG_ALT6_TRANS 0x100000 // language specific
#define FLAG_DOUBLING 0x80000 // doubles the following consonant
#define BITNUM_FLAG_ALT 19 // bit number of FLAG_ALT_TRANS - 1
#define FLAG_ALT_TRANS 0x100000 // language specific
#define FLAG_ALT2_TRANS 0x200000 // language specific
#define FLAG_ALT3_TRANS 0x400000 // language specific
#define FLAG_COMBINE 0x800000 // combine with the next word
#define FLAG_ALLOW_DOT 0x01000000 // ignore '.' after word (abbreviation)
#define FLAG_NEEDS_DOT 0x02000000 // only if the word is followed by a dot
#define FLAG_WAS_UNPRONOUNCABLE 0x04000000 // the unpronounceable routine was used
@@ -83,8 +78,16 @@
#define FLAG_ACCENT 0x800 // character name is base-character name + accent name
#define FLAG_HYPHENATED 0x1000 // multiple-words, but needs hyphen between parts 1 and 2
#define FLAG_SENTENCE 0x2000 // only if the clause is a sentence
#define FLAG_ONLY 0x4000
#define FLAG_ONLY_S 0x8000
#define FLAG_STEM 0x10000 // must have a suffix
#define FLAG_ATEND 0x20000 /* use this pronunciation if at end of clause */
#define FLAG_ATSTART 0x40000 // use this pronunciation if at start of clause
#define BITNUM_FLAG_ALLCAPS 0x2a
#define BITNUM_FLAG_HYPHENATED 0x2c
#define BITNUM_FLAG_ONLY 0x2e
#define BITNUM_FLAG_ONLY_S 0x2f
// wordflags, flags in source word
@@ -272,7 +275,9 @@ extern ALPHABET *current_alphabet;
// alphabet flags
#define AL_DONT_NAME 0x01 // don't speak the alphabet name
#define AL_NOT_LETTERS 0x02 // don't use the language for speaking letters
#define AL_NOT_WORDS 0x04 // don't use the language to speak words
#define AL_WORDS 0x04 // use the language to speak words
#define AL_NOT_CODE 0x08 // don't speak the character code
#define AL_NO_SYMBOL 0x10 // don't repeat "symbol" or "character"
#define N_LOPTS 21
@@ -369,35 +374,58 @@ typedef struct {
#define S_NO_DIM 0x02
#define S_FINAL_DIM 0x04
#define S_FINAL_NO_2 0x10
#define S_NO_AUTO_2 0x20
#define S_2_TO_HEAVY 0x40
#define S_FIRST_PRIMARY 0x80
#define S_2_SYL_2 0x1000
#define S_INITIAL_2 0x2000
#define S_NO_AUTO_DIM 0x10000
#define S_HYPEN_UNSTRESS 0x100000
#define S_NO_EOC_LENGTHEN 0x200000
// bit0=don't stress monosyllables, except at end of clause
#define S_FINAL_DIM_ONLY 0x06
// bit1=don't set diminished stress,
// bit2=mark unstressed final syllables as diminished
// bit3=set consecutive unstressed syllables in unstressed words to diminished, but not in stressed words
#define S_FINAL_NO_2 0x10
// bit4=don't allow secondary stress on last syllable
#define S_NO_AUTO_2 0x20
// bit5-don't use automatic secondary stress
#define S_2_TO_HEAVY 0x40
// bit6=light syllable followed by heavy, move secondary stress to the heavy syllable. LANG=Finnish
#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_SPANISH 0x200
// bit9=stress last syllable if it doesn't end in vowel or "s" or "n" LANG=Spanish
#define S_2_SYL_2 0x1000
// bit12= In a 2-syllable word, if one has primary stress then give the other secondary stress
#define S_INITIAL_2 0x2000
// bit13= If there is only one syllable before the primary stress, give it a secondary stress
// bit15= Give stress to the first unstressed syllable
// bit16= Don't diminish consecutive syllables within a word.
#define S_MID_DIM 0x10000
// bit 16= Set (not first or last) syllables to diminished stress
#define S_PRIORITY_STRESS 0x20000
// bit17= "priority" stress reduces other primary stress to "unstressed" not "secondary"
#define S_EO_CLAUSE1 0x40000
// bit18= don't lengthen short vowels more than long vowels at end-of-clause
#define S_FINAL_LONG 0x80000
// bit19=stress on final syllable if it has a long vowel, but previous syllable has a short vowel
#define S_HYPEN_UNSTRESS 0x100000
// bit20= hyphenated words, 2nd part is unstressed
#define S_NO_EOC_LENGTHEN 0x200000
// bit21= don't lengthen vowels at end-of-clause
// bit15= Give stress to the first unstressed syllable
int stress_flags;
int unstressed_wd1; // stress for $u word of 1 syllable
int unstressed_wd2; // stress for $u word of >1 syllable
@@ -515,6 +543,8 @@ typedef struct {
int listx; // compile *_listx after *list
const unsigned int *replace_chars; // characters to be substitutes
const char *ascii_language; // switch to this language for Latin characters
int alt_alphabet; // offset for another language to recognize
const char *alt_alphabet_lang; // language for the alt_alphabet
int max_lengthmod;
int lengthen_tonic; // lengthen the tonic syllable
int suffix_add_e; // replace a suffix (which has the SUFX_E flag) with this character
@@ -543,7 +573,7 @@ typedef struct
const char *transpose_map;
char dictionary_name[40];
char phon_out[400];
char phon_out[500];
char phonemes_repeat[20];
int phonemes_repeat_count;
int phoneme_tab_ix;
@@ -552,6 +582,7 @@ typedef struct
unsigned char stress_amps_r[8];
short stress_lengths[8];
int dict_condition; // conditional apply some pronunciation rules and dict.lookups
int dict_min_size;
const unsigned short *charset_a0; // unicodes for characters 0xa0 to oxff
const wchar_t *char_plus_apostrophe; // single chars + apostrophe treated as words
const wchar_t *punct_within_word; // allow these punctuation characters within words
@@ -585,7 +616,6 @@ typedef struct
unsigned char groups2_start[256]; // index into groups2
const short *frequent_pairs; // list of frequent pairs of letters, for use in compressed *_list
int expect_verb;
int expect_past; // expect past tense
int expect_verb_s;
@@ -601,7 +631,7 @@ typedef struct
int prepause_timeout;
int end_stressed_vowel; // word ends with stressed vowel
int prev_dict_flags; // dictionary flags from previous word
int prev_dict_flags[2]; // dictionary flags from previous word
int clause_terminator;
} Translator;
@@ -677,6 +707,7 @@ void InitText(int flags);
void InitText2(void);
int IsDigit(unsigned int c);
int IsAlpha(unsigned int c);
int IsVowel(Translator *tr, int c);
int isspace2(unsigned int c);
int towlower2(unsigned int c);
void GetTranslatedPhonemeString(char *phon_out, int n_phon_out, int use_ipa);
@@ -703,7 +734,6 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
void MakePhonemeList(Translator *tr, int post_pause, int new_sentence);
int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch);
void ApplySpecialAttribute(Translator *tr, char *phonemes, int dict_flags);
void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags);
void AppendPhonemes(Translator *tr, char *string, int size, const char *ph);
@@ -714,14 +744,14 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy);
int Unpronouncable(Translator *tr, char *word, int posn);
void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress);
int TranslateRules(Translator *tr, char *p, char *phonemes, int size, char *end_phonemes, int end_flags, unsigned int *dict_flags);
int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab);
int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab, char *word_out);
void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *tone, char **voice_change);
int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change);
void SetVoiceStack(espeak_VOICE *v, const char *variant_name);
void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata, WORD_PH_DATA *worddata);
void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata);
char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa);
char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa, int *flags);
extern FILE *f_trans; // for logging
extern FILE *f_logespeak;
+1 -1
View File
@@ -354,7 +354,7 @@ void TranslDlg::ReadVoice(int variant)
wxString filename;
char *p;
char vname[40];
char fname[sizeof(path_home)+10];
char fname[sizeof(path_home)+30];
if(variant)
{
+1 -1
View File
@@ -25,7 +25,7 @@ typedef struct {
int phoneme_tab_ix; // phoneme table number
int pitch_base; // Hz<<12
int pitch_range; // standard = 0x1000
int speedf1;
int speedf2;
int speedf3;
+219 -161
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -48,7 +48,8 @@ MNEM_TAB genders [] = {
{"unknown", 0},
{"male", 1},
{"female", 2},
{NULL, 0 }};
{NULL, 0 }
};
int tone_points[12] = {600,170, 1200,135, 2000,110, 3000,110, -1,0};
//int tone_points[12] = {250,200, 400,170, 600,170, 1200,135, 2000,110, -1,0};
@@ -62,7 +63,7 @@ int formant_rate[9]; // values adjusted for actual sample rate
#define DEFAULT_LANGUAGE_PRIORITY 5
#define N_VOICES_LIST 200
#define N_VOICES_LIST 250
static int n_voices_list = 0;
static espeak_VOICE *voices_list[N_VOICES_LIST];
static int len_path_voices;
@@ -99,6 +100,7 @@ enum {
V_STRESSADD,
V_DICTRULES,
V_STRESSRULE,
V_STRESSOPT,
V_CHARSET,
V_NUMBERS,
V_OPTION,
@@ -107,6 +109,7 @@ enum {
V_KLATT,
V_FAST,
V_SPEED,
V_DICTMIN,
// these need a phoneme table to have been specified
V_REPLACE,
@@ -118,7 +121,8 @@ enum {
static MNEM_TAB options_tab[] = {
{"reduce_t", LOPT_REDUCE_T},
{"bracket", LOPT_BRACKET_PAUSE},
{NULL, -1} };
{NULL, -1}
};
static MNEM_TAB keyword_tab[] = {
{"name", V_NAME},
@@ -128,7 +132,7 @@ static MNEM_TAB keyword_tab[] = {
{"formant", V_FORMANT},
{"pitch", V_PITCH},
{"phonemes", V_PHONEMES},
{"translator", V_TRANSLATOR},
{"translator", V_TRANSLATOR},
{"dictionary", V_DICTIONARY},
{"stressLength", V_STRESSLENGTH},
{"stressAmp", V_STRESSAMP},
@@ -137,6 +141,7 @@ static MNEM_TAB keyword_tab[] = {
{"tunes", V_TUNES},
{"dictrules", V_DICTRULES},
{"stressrule", V_STRESSRULE},
{"stressopt", V_STRESSOPT},
{"charset", V_CHARSET},
{"replace", V_REPLACE},
{"words", V_WORDGAP},
@@ -155,6 +160,7 @@ static MNEM_TAB keyword_tab[] = {
{"klatt", V_KLATT},
{"fast_test2", V_FAST},
{"speed", V_SPEED},
{"dict_min", V_DICTMIN},
// these just set a value in langopts.param[]
{"l_dieresis", 0x100+LOPT_DIERESES},
@@ -165,7 +171,8 @@ static MNEM_TAB keyword_tab[] = {
{"l_sonorant_min", 0x100+LOPT_SONORANT_MIN},
{"l_length_mods", 0x100+LOPT_LENGTH_MODS},
{"apostrophe", 0x100+LOPT_APOSTROPHE},
{NULL, 0} };
{NULL, 0}
};
#define N_VOICE_VARIANTS 12
const char variants_either[N_VOICE_VARIANTS] = {1,2,12,3,13,4,14,5,11,0};
@@ -186,6 +193,12 @@ static char *fgets_strip(char *buf, int size, FILE *f_in)
if(fgets(buf,size,f_in) == NULL)
return(NULL);
if(buf[0] == '#')
{
buf[0] = 0;
return(buf);
}
len = strlen(buf);
while((--len > 0) && isspace(buf[len]))
buf[len] = 0;
@@ -259,9 +272,9 @@ void ReadTonePoints(char *string, int *tone_pts)
tone_pts[ix] = -1;
sscanf(string,"%d %d %d %d %d %d %d %d %d %d",
&tone_pts[0],&tone_pts[1],&tone_pts[2],&tone_pts[3],
&tone_pts[4],&tone_pts[5],&tone_pts[6],&tone_pts[7],
&tone_pts[8],&tone_pts[9]);
&tone_pts[0],&tone_pts[1],&tone_pts[2],&tone_pts[3],
&tone_pts[4],&tone_pts[5],&tone_pts[6],&tone_pts[7],
&tone_pts[8],&tone_pts[9]);
}
@@ -315,8 +328,7 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea
while(isspace(*p)) p++;
strncpy0(vname,p,sizeof(vname));
}
else
if(memcmp(linebuf,"language",8)==0)
else if(memcmp(linebuf,"language",8)==0)
{
priority = DEFAULT_LANGUAGE_PRIORITY;
vlanguage[0] = 0;
@@ -333,13 +345,11 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea
n_languages++;
}
}
else
if(memcmp(linebuf,"gender",6)==0)
else if(memcmp(linebuf,"gender",6)==0)
{
sscanf(&linebuf[6],"%s %d",vgender,&age);
}
else
if(memcmp(linebuf,"variants",8)==0)
else if(memcmp(linebuf,"variants",8)==0)
{
sscanf(&linebuf[8],"%d",&n_variants);
}
@@ -386,8 +396,10 @@ void VoiceReset(int tone_only)
// Set voice to the default values
int pk;
static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128};
static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
// static unsigned char default_heights[N_PEAKS] = {140,128,120,110,90,90,128,128,128}; // changed for v.1.47
// static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128}; // previous version
static unsigned char default_widths[N_PEAKS] = {140,128,128,160,171,171,128,128,128};
static int breath_widths[N_PEAKS] = {0,200,200,400,400,400,600,600,600};
@@ -408,7 +420,7 @@ void VoiceReset(int tone_only)
voice->n_harmonic_peaks = 5;
voice->peak_shape = 0;
voice->voicing = 64;
voice->consonant_amp = 100;
voice->consonant_amp = 85; // change to 85 for v.1.47 was 100
voice->consonant_ampv = 100;
voice->samplerate = samplerate_native;
memset(voice->klattv,0,sizeof(voice->klattv));
@@ -442,7 +454,7 @@ void VoiceReset(int tone_only)
// Adjustment of harmonic amplitudes, steps of 8Hz
// value of 128 means no change
// memset(voice->tone_adjust,128,sizeof(voice->tone_adjust));
SetToneAdjust(voice,tone_points);
SetToneAdjust(voice,tone_points);
// default values of speed factors
voice->speedf1 = 256;
@@ -516,7 +528,7 @@ static int Read8Numbers(char *data_in,int *data)
// Read 8 integer numbers
memset(data, 0, 8+sizeof(int));
return(sscanf(data_in,"%d %d %d %d %d %d %d %d",
&data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7]));
&data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7]));
}
@@ -553,14 +565,16 @@ voice_t *LoadVoice(const char *vname, int control)
char phonemes_name[40];
char option_name[40];
const char *language_type;
char buf[200];
char buf[sizeof(path_home)+30];
char path_voices[sizeof(path_home)+12];
char langname[4];
int dict_min = 0;
int stress_amps[8];
int stress_lengths[8];
int stress_add[8];
char names[8][40];
char name2[80];
const char *voice_dir;
int pitch1;
int pitch2;
@@ -569,10 +583,14 @@ voice_t *LoadVoice(const char *vname, int control)
static char voice_name[40]; // voice name for current_voice_selected
static char voice_languages[100]; // list of languages and priorities for current_voice_selected
strcpy(voicename,vname);
if(voicename[0]==0)
strcpy(voicename,"default");
// which directory to look for a named voice
static const char *voices_asia =
"fa fa-pin hi hy hy-west id ka kn ku ml ne pa ta tr vi vi-hue zh zh-yue ";
static const char *voices_europe =
"bg bs ca cs cy da el es et fi fr-be hr hu is it lt lv mk nl no pl pt-pt ro ru sk sq sr sv ";
strncpy0(voicename, vname, sizeof(voicename));
if(control & 0x10)
{
strcpy(buf,vname);
@@ -581,25 +599,34 @@ voice_t *LoadVoice(const char *vname, int control)
}
else
{
if(voicename[0]==0)
strcpy(voicename,"default");
sprintf(path_voices,"%s%cvoices%c",path_home,PATHSEP,PATHSEP);
sprintf(buf,"%s%s",path_voices,voicename);
sprintf(buf,"%s%s",path_voices,voicename); // first, look in the main voices directory
if(GetFileLength(buf) <= 0)
{
// look for the voice in a sub-directory of the language name
langname[0] = voicename[0];
langname[1] = voicename[1];
langname[2] = 0;
sprintf(buf,"%s%s%c%s",path_voices,langname,PATHSEP,voicename);
if(GetFileLength(buf) <= 0)
// then look in the appropriate subdirectory
if((voicename[0]=='m') && (voicename[1]=='b'))
{
// look in "extra" sub-directory
sprintf(buf,"%sextra%c%s",path_voices,PATHSEP,voicename);
voice_dir = "mb"; // mbrola voices
}
else
{
sprintf(name2, "%s ", voicename);
if(strstr(voices_europe, voicename) != NULL)
voice_dir = "europe";
else if(strstr(voices_asia, voicename) != NULL)
voice_dir = "asia";
else
voice_dir = "other";
sprintf(buf,"%s%s%c%s", path_voices,voice_dir,PATHSEP,voicename);
if(GetFileLength(buf) <= 0)
{
// look in "test" sub-directory
// if not found, look in "test" sub-directory
sprintf(buf,"%stest%c%s",path_voices,PATHSEP,voicename);
}
}
@@ -668,48 +695,48 @@ voice_t *LoadVoice(const char *vname, int control)
switch(key)
{
case V_LANGUAGE:
{
unsigned int len;
int priority;
if(tone_only)
break;
priority = DEFAULT_LANGUAGE_PRIORITY;
language_name[0] = 0;
sscanf(p,"%s %d",language_name,&priority);
if(strcmp(language_name,"variant") == 0)
break;
len = strlen(language_name) + 2;
// check for space in languages[]
if(len < (sizeof(voice_languages)-langix-1))
{
unsigned int len;
int priority;
voice_languages[langix] = priority;
if(tone_only)
break;
priority = DEFAULT_LANGUAGE_PRIORITY;
language_name[0] = 0;
sscanf(p,"%s %d",language_name,&priority);
if(strcmp(language_name,"variant") == 0)
break;
len = strlen(language_name) + 2;
// check for space in languages[]
if(len < (sizeof(voice_languages)-langix-1))
{
voice_languages[langix] = priority;
strcpy(&voice_languages[langix+1],language_name);
langix += len;
}
// only act on the first language line
if(language_set == 0)
{
language_type = strtok(language_name,"-");
language_set = 1;
strcpy(translator_name,language_type);
strcpy(new_dictionary,language_type);
strcpy(phonemes_name,language_type);
SelectPhonemeTableName(phonemes_name);
if(new_translator != NULL)
DeleteTranslator(new_translator);
new_translator = SelectTranslator(translator_name);
langopts = &new_translator->langopts;
}
strcpy(&voice_languages[langix+1],language_name);
langix += len;
}
break;
// only act on the first language line
if(language_set == 0)
{
language_type = strtok(language_name,"-");
language_set = 1;
strcpy(translator_name,language_type);
strcpy(new_dictionary,language_type);
strcpy(phonemes_name,language_type);
SelectPhonemeTableName(phonemes_name);
if(new_translator != NULL)
DeleteTranslator(new_translator);
new_translator = SelectTranslator(translator_name);
langopts = &new_translator->langopts;
}
}
break;
case V_NAME:
if(tone_only == 0)
@@ -720,14 +747,14 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_GENDER:
{
int age = 0;
char vgender[80];
sscanf(p,"%s %d",vgender,&age);
current_voice_selected.gender = LookupMnem(genders,vgender);
current_voice_selected.age = age;
}
break;
{
int age = 0;
char vgender[80];
sscanf(p,"%s %d",vgender,&age);
current_voice_selected.gender = LookupMnem(genders,vgender);
current_voice_selected.age = age;
}
break;
case V_TRANSLATOR:
if(tone_only) break;
@@ -735,7 +762,7 @@ voice_t *LoadVoice(const char *vname, int control)
sscanf(p,"%s",translator_name);
if(new_translator != NULL)
DeleteTranslator(new_translator);
DeleteTranslator(new_translator);
new_translator = SelectTranslator(translator_name);
langopts = &new_translator->langopts;
@@ -754,16 +781,16 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_PITCH:
{
double factor;
// default is pitch 82 118
n = sscanf(p,"%d %d",&pitch1,&pitch2);
voice->pitch_base = (pitch1 - 9) << 12;
voice->pitch_range = (pitch2 - pitch1) * 108;
factor = double(pitch1 - 82)/82;
voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch
}
break;
{
double factor;
// default is pitch 82 118
n = sscanf(p,"%d %d",&pitch1,&pitch2);
voice->pitch_base = (pitch1 - 9) << 12;
voice->pitch_range = (pitch2 - pitch1) * 108;
factor = double(pitch1 - 82)/82;
voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch
}
break;
case V_STRESSLENGTH: // stressLength
stress_lengths_set = Read8Numbers(p,stress_lengths);
@@ -799,14 +826,32 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_DICTRULES: // conditional dictionary rules and list entries
case V_NUMBERS:
case V_STRESSOPT:
// expect a list of numbers
while(*p != 0)
{
while(isspace(*p)) p++;
n = -1;
if(((n = atoi(p)) > 0) && (n < 32))
if((n = atoi(p)) > 0)
{
p++;
conditional_rules |= (1 << n);
if(n < 32)
{
if(key==V_DICTRULES)
conditional_rules |= (1 << n);
else if(key==V_NUMBERS)
langopts->numbers |= (1 << n);
else if(key==V_STRESSOPT)
langopts->stress_flags |= (1 << n);
}
else
{
if((key==V_NUMBERS) && (n < 64))
langopts->numbers |= (1 << (n-32));
else
fprintf(stderr,"Bad option number %d\n", n);
}
}
while(isalnum(*p)) p++;
}
@@ -828,9 +873,9 @@ voice_t *LoadVoice(const char *vname, int control)
case V_STRESSRULE:
sscanf(p,"%d %d %d %d",&langopts->stress_rule,
&langopts->stress_flags,
&langopts->unstressed_wd1,
&langopts->unstressed_wd2);
&langopts->stress_flags,
&langopts->unstressed_wd1,
&langopts->unstressed_wd2);
break;
case V_CHARSET:
@@ -838,10 +883,6 @@ voice_t *LoadVoice(const char *vname, int control)
new_translator->charset_a0 = charsets[value];
break;
case V_NUMBERS:
sscanf(p,"%d %d",&langopts->numbers,&langopts->numbers2);
break;
case V_OPTION:
value2 = 0;
if((sscanf(p,"%s %d %d",option_name,&value,&value2) >= 2) && ((ix = LookupMnem(options_tab, option_name)) >= 0))
@@ -885,12 +926,12 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_TONE:
{
int tone_data[12];
ReadTonePoints(p,tone_data);
SetToneAdjust(voice,tone_data);
}
break;
{
int tone_data[12];
ReadTonePoints(p,tone_data);
SetToneAdjust(voice,tone_data);
}
break;
case V_VOICING:
if(sscanf(p,"%d",&value)==1)
@@ -898,16 +939,16 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_BREATH:
voice->breath[0] = Read8Numbers(p,&voice->breath[1]);
for(ix=1; ix<8; ix++)
{
if(ix % 2)
voice->breath[ix] = -voice->breath[ix];
}
voice->breath[0] = Read8Numbers(p,&voice->breath[1]);
for(ix=1; ix<8; ix++)
{
if(ix % 2)
voice->breath[ix] = -voice->breath[ix];
}
break;
case V_BREATHW:
voice->breathw[0] = Read8Numbers(p,&voice->breathw[1]);
voice->breathw[0] = Read8Numbers(p,&voice->breathw[1]);
break;
case V_CONSONANTS:
@@ -919,20 +960,20 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_MBROLA:
{
int srate = 16000;
char name[40];
char phtrans[40];
{
int srate = 16000;
char name[40];
char phtrans[40];
phtrans[0] = 0;
sscanf(p,"%s %s %d",name,phtrans,&srate);
if(LoadMbrolaTable(name,phtrans,srate) != EE_OK)
{
fprintf(stderr,"mbrola voice not found\n");
}
voice->samplerate = srate;
phtrans[0] = 0;
sscanf(p,"%s %s %d",name,phtrans,&srate);
if(LoadMbrolaTable(name,phtrans,srate) != EE_OK)
{
fprintf(stderr,"mbrola voice not found\n");
}
break;
voice->samplerate = srate;
}
break;
case V_KLATT:
voice->klattv[0] = 1; // default source: IMPULSIVE
@@ -945,6 +986,10 @@ voice_t *LoadVoice(const char *vname, int control)
SetSpeed(3);
break;
case V_DICTMIN:
sscanf(p,"%d",&dict_min);
break;
default:
if((key & 0xff00) == 0x100)
{
@@ -987,6 +1032,7 @@ voice_t *LoadVoice(const char *vname, int control)
}
voice->phoneme_tab_ix = ix;
new_translator->phoneme_tab_ix = ix;
new_translator->dict_min_size = dict_min;
LoadDictionary(new_translator, new_dictionary, control & 4);
if(dictionary_name[0]==0)
return(NULL); // no dictionary loaded
@@ -1011,6 +1057,7 @@ voice_t *LoadVoice(const char *vname, int control)
translator = new_translator;
}
// relative lengths of different stress syllables
for(ix=0; ix<stress_lengths_set; ix++)
{
@@ -1225,15 +1272,14 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
// match on voice name
score += 500;
}
else
if(strcmp(voice_spec->name,voice->identifier)==0)
else if(strcmp(voice_spec->name,voice->identifier)==0)
{
score += 400;
}
}
if(((voice_spec->gender == 1) || (voice_spec->gender == 2)) &&
((voice->gender == 1) || (voice->gender == 2)))
((voice->gender == 1) || (voice->gender == 2)))
{
if(voice_spec->gender == voice->gender)
score += 50;
@@ -1365,8 +1411,7 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name2)
{
match_fname = ix; // matching identifier, use this if no matching name
}
else
if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
else if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
{
match_fname2 = ix;
}
@@ -1463,8 +1508,7 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
gender = 0;
if((voice_select2.gender == 2) || ((voice_select2.age > 0) && (voice_select2.age < 13)))
gender = 2;
else
if(voice_select2.gender == 1)
else if(voice_select2.gender == 1)
gender = 1;
#define AGE_OLD 60
@@ -1595,8 +1639,8 @@ static void GetVoices(const char *path)
}
#else
#ifdef PLATFORM_WINDOWS
WIN32_FIND_DATAA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATAA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
#undef UNICODE // we need FindFirstFileA() which takes an 8-bit c-string
sprintf(fname,"%s\\*",path);
@@ -1605,29 +1649,33 @@ static void GetVoices(const char *path)
return;
do {
sprintf(fname,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
if(n_voices_list >= (N_VOICES_LIST-2))
break; // voices list is full
ftype = GetFileLength(fname);
if((ftype == -2) && (FindFileData.cFileName[0] != '.'))
if(FindFileData.cFileName[0] != '.')
{
// a sub-sirectory
GetVoices(fname);
}
else
if(ftype > 0)
{
// a regular line, add it to the voices list
if((f_voice = fopen(fname,"r")) == NULL)
continue;
sprintf(fname,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
ftype = GetFileLength(fname);
// pass voice file name within the voices directory
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName);
fclose(f_voice);
if(voice_data != NULL)
if(ftype == -2)
{
voices_list[n_voices_list++] = voice_data;
// a sub-sirectory
GetVoices(fname);
}
else if(ftype > 0)
{
// a regular line, add it to the voices list
if((f_voice = fopen(fname,"r")) == NULL)
continue;
// pass voice file name within the voices directory
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName);
fclose(f_voice);
if(voice_data != NULL)
{
voices_list[n_voices_list++] = voice_data;
}
}
}
} while(FindNextFileA(hFind, &FindFileData) != 0);
@@ -1648,17 +1696,19 @@ static void GetVoices(const char *path)
break; // voices list is full
}
if(ent->d_name[0] == '.')
continue;
sprintf(fname,"%s%c%s",path,PATHSEP,ent->d_name);
ftype = GetFileLength(fname);
if((ftype == -2) && (ent->d_name[0] != '.'))
if(ftype == -2)
{
// a sub-sirectory
GetVoices(fname);
}
else
if(ftype > 0)
else if(ftype > 0)
{
// a regular line, add it to the voices list
if((f_voice = fopen(fname,"r")) == NULL)
@@ -1691,15 +1741,23 @@ static void GetVoices(const char *path)
espeak_ERROR SetVoiceByName(const char *name)
{//=========================================
espeak_VOICE *v;
int ix;
espeak_VOICE voice_selector;
char *variant_name;
static char buf[60];
strncpy0(buf,name,sizeof(buf));
variant_name = ExtractVoiceVariantName(buf, 0, 1);
for(ix=0; ; ix++)
{
// convert voice name to lower case (ascii)
if((buf[ix] = tolower(buf[ix])) == 0)
break;
}
memset(&voice_selector,0,sizeof(voice_selector));
// voice_selector.name = buf;
voice_selector.name = (char *)name; // include variant name in voice stack ??
// first check for a voice with this filename
@@ -1798,7 +1856,7 @@ ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
// sort the voices list
qsort(voices_list,n_voices_list,sizeof(espeak_VOICE *),
(int (__cdecl *)(const void *,const void *))VoiceNameSorter);
(int (__cdecl *)(const void *,const void *))VoiceNameSorter);
if(voice_spec)
+1 -1
View File
@@ -1195,7 +1195,7 @@ void *wave_test_get_write_buffer()
// notdef USE_PORTAUDIO
int wave_init(int srate) {}
int wave_init(int srate) {return 1;}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
+1 -1
View File
@@ -870,7 +870,7 @@ void *wave_test_get_write_buffer()
// notdef USE_PULSEAUDIO
int wave_init() {}
int wave_init(return 1;) {}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
+1 -1
View File
@@ -535,7 +535,7 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
#else
// notdef USE_SADA
void wave_init() {}
init wave_init() {return 1;}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
+13 -20
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -244,7 +244,7 @@ static unsigned char wavemult[N_WAVEMULT] = {
105, 98, 90, 83, 76, 69, 62, 55, 49, 43, 37, 32, 27, 22, 18, 14,
11, 8, 5, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// set from y = pow(2,x) * 128, x=-1 to 1
unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = {
@@ -592,7 +592,7 @@ static PaError Pa_OpenDefaultStream2( PaStream** stream,
hostApiOutputParameters.device = Pa_GetDefaultOutputDevice();
if( hostApiOutputParameters.device == paNoDevice )
return paDeviceUnavailable;
return paDeviceUnavailable;
hostApiOutputParameters.channelCount = outputChannelCount;
hostApiOutputParameters.sampleFormat = sampleFormat;
@@ -834,15 +834,6 @@ static void WavegenSetEcho(void)
amp = embedded_value[EMBED_H];
delay = 130;
}
#ifdef deleted
if(embedded_value[EMBED_T] > 0)
{
// announcing punctuation, add a small echo
// This seems unpopular
amp = embedded_value[EMBED_T] * 8;
delay = 60;
}
#endif
if(delay == 0)
amp = 0;
@@ -854,7 +845,7 @@ static void WavegenSetEcho(void)
if(amp > 20)
echo_length = echo_head * 2; // perhaps allow 2 echo periods if the echo is loud.
// echo_amp units are 1/256ths of the amplitude of the original sound.
// echo_amp units are 1/256ths of the amplitude of the original sound.
echo_amp = amp;
// compensate (partially) for increase in amplitude due to echo
general_amplitude = GetAmplitude();
@@ -1559,7 +1550,7 @@ static int SetWithRange0(int value, int max)
static void SetPitchFormants()
{//===========================
int ix;
int factor;
int factor = 256;
int pitch_value;
// adjust formants to give better results for a different voice pitch
@@ -1570,11 +1561,13 @@ static void SetPitchFormants()
{
// only adjust if the pitch is higher than normal
factor = 256 + (25 * (pitch_value - 50))/50;
for(ix=0; ix<=5; ix++)
{
wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
}
}
for(ix=0; ix<=5; ix++)
{
wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
}
factor = embedded_value[EMBED_T]*3;
wvoice->height[0] = (wvoice->height2[0] * (256 - factor*2))/256;
wvoice->height[1] = (wvoice->height2[1] * (256 - factor))/256;
@@ -1755,7 +1748,7 @@ if(option_log_frames)
fprintf(f_log,"%3dmS %3d %3d %4d %4d (%3d %3d %3d %3d) to %3d %3d %4d %4d (%3d %3d %3d %3d)\n",length*1000/samplerate,
fr1->ffreq[0],fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3], fr1->fheight[0],fr1->fheight[1],fr1->fheight[2],fr1->fheight[3],
fr2->ffreq[0],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3], fr2->fheight[0],fr2->fheight[1],fr2->fheight[2],fr2->fheight[3] );
fclose(f_log);
f_log=NULL;
}
@@ -2036,7 +2029,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text
{
sonicSetSpeed(sonicSpeedupStream, sonicSpeed);
}
sonicWriteShortToStream(sonicSpeedupStream, outbuf, length_in);
}