espeakedit: Change compile_report file to include the phoneme name as well as phoneme table which uses each data file. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@95 d46cf337-b52f-0410-862d-fd96e6ae7743master
0 3 3: @ @- @2 @5 @L | 0 3 3: @ @- @2 @5 @L | ||||
a a2 A: A@ aa aI aI@ aU | a a2 A: A@ aa aI aI@ aU | ||||
aU@ E e@ eI I i I2 i: | |||||
i@ IR O O: o: O@ o@ OI | |||||
oU O~ U u: U@ V VR | |||||
aU@ E e@ eI I I2 i: i@ | |||||
IR O O: o: O@ o@ OI oU | |||||
O~ U u: U@ V VR | |||||
: ; b C d D dZ f | : ; b C d D dZ f | ||||
g g- h j k l L m | |||||
n N p Q r r- s S | |||||
t T t2 tS v w x z | |||||
Z | |||||
g h j k l m n N | |||||
p Q r r- s S t T | |||||
t2 tS v w x z Z | |||||
Dictionary eo_dict | Dictionary eo_dict | ||||
@- a aI aU e eI eU i | |||||
o OI u uI | |||||
@- a aI aU e i o u | |||||
* b d dZ f g h j | |||||
k l m n p r R s | |||||
S t T tS ts v w x | |||||
z Z | |||||
* b d k l m n p | |||||
r R s t ts v z Z | |||||
Dictionary es_dict | Dictionary es_dict | ||||
k k^ l l^ m n n^ p | k k^ l l^ m n n^ p | ||||
r R s S t tS ts v | r R s S t tS ts v | ||||
x z Z | x z Z | ||||
Dictionary zh_dict | |||||
Dictionary zhh_dict | |||||
&? 0 0? @ @? @r @u A | |||||
A? E E~ i i&? i. i0 i; | |||||
i? i@ i@? i[ iA iA? iE iE~ | |||||
io io? iu i~ o u u&? u? | |||||
u@ u@? uA uA? uE uE~ ui u~ | |||||
y y? y@ y@? ya y~ | |||||
c; f h k kh l m n | |||||
N p ph s s. t tc; tc; | |||||
th ts ts. ts. tsh v z. |
e e: | e e: | ||||
f Ef | f Ef | ||||
g ge: | g ge: | ||||
h hO: | |||||
h ho: | |||||
i i: | i i: | ||||
j ji: | j ji: | ||||
k kO: | |||||
k ko: | |||||
l El | l El | ||||
m Em | m Em | ||||
n En | n En | ||||
_1M3 bIlj'u:n | _1M3 bIlj'u:n | ||||
_dpt p'8Nkt | _dpt p'8Nkt | ||||
(1 : a) f'Ws.ta | |||||
// abbreviations | // abbreviations | ||||
//************** | //************** | ||||
// Ancient Greek - based on base2 | // Ancient Greek - based on base2 | ||||
//==================================================== | //==================================================== | ||||
phoneme : // Lengthen previous vowel by "length" | |||||
virtual | |||||
length 100 | |||||
endphoneme | |||||
phoneme y | phoneme y | ||||
vowel starttype (i) endtype (i) | vowel starttype (i) endtype (i) | ||||
length 160 | length 160 | ||||
formants vowel/yy_4 | formants vowel/yy_4 | ||||
endphoneme | endphoneme | ||||
phoneme e | |||||
vowel starttype (e) endtype (e) | |||||
length 140 | |||||
formants vowel/e | |||||
endphoneme | |||||
phoneme E | |||||
vowel starttype (e) endtype (e) | |||||
length 150 | |||||
formants vowel/ee_1 | |||||
endphoneme | |||||
phoneme o | |||||
vowel starttype (o) endtype (o) | |||||
length 140 | |||||
formants vowel/o | |||||
endphoneme | |||||
phoneme O | |||||
vowel starttype (o) endtype (o) | |||||
length 150 | |||||
formants vowel/0 | |||||
endphoneme | |||||
phoneme EU | phoneme EU | ||||
vowel starttype (e) endtype (u) | vowel starttype (e) endtype (u) | ||||
length 230 | length 230 |
phonemetable zhy base | phonemetable zhy base | ||||
include ph_zh_yue | include ph_zh_yue | ||||
phonemetable zh base | |||||
include ph_zh | |||||
phonemetable zhh zh | |||||
include ph_zh_huai | |||||
phonemetable sw base | phonemetable sw base | ||||
include ph_swahili | include ph_swahili | ||||
static int markers_used[8]; | static int markers_used[8]; | ||||
#define N_USED_BY 12 | |||||
typedef struct { | typedef struct { | ||||
void *link; | void *link; | ||||
int value; | int value; | ||||
short n_uses; | |||||
short n_used_by; | |||||
unsigned char used_by[N_USED_BY]; | |||||
int ph_mnemonic; | |||||
short ph_table; | |||||
char string[1]; | char string[1]; | ||||
} REF_HASH_TAB; | } REF_HASH_TAB; | ||||
FILE *f; | FILE *f; | ||||
int id; | int id; | ||||
int ix; | |||||
int hash; | int hash; | ||||
int addr = 0; | |||||
int type_code=' '; | int type_code=' '; | ||||
REF_HASH_TAB *p, *p2; | REF_HASH_TAB *p, *p2; | ||||
char buf[sizeof(path_source)+120]; | char buf[sizeof(path_source)+120]; | ||||
if(strcmp(path,"NULL")==0) | |||||
return(0); | |||||
if(strcmp(path,"DFT")==0) | |||||
return(1); | |||||
count_references++; | count_references++; | ||||
hash = Hash8(path); | hash = Hash8(path); | ||||
{ | { | ||||
if(strcmp(path,p->string)==0) | if(strcmp(path,p->string)==0) | ||||
{ | { | ||||
int found = 0; | |||||
duplicate_references++; | duplicate_references++; | ||||
p->n_uses++; | |||||
// add the current phoneme table to a list of users of this data file, if not already listed | |||||
for(ix=0; (ix < p->n_used_by) && (ix < N_USED_BY); ix++) | |||||
{ | |||||
if(p->used_by[ix] == n_phoneme_tabs) | |||||
{ | |||||
found = 1; | |||||
break; | |||||
} | |||||
} | |||||
if(found == 0) | |||||
{ | |||||
if(ix < N_USED_BY) | |||||
{ | |||||
p->used_by[ix] = n_phoneme_tabs; | |||||
} | |||||
p->n_used_by++; | |||||
} | |||||
return(p->value); // already loaded this data | |||||
addr = p->value; // already loaded this data | |||||
break; | |||||
} | } | ||||
p = (REF_HASH_TAB *)p->link; | p = (REF_HASH_TAB *)p->link; | ||||
} | } | ||||
sprintf(buf,"%s%s",path_source,path); | |||||
if(strcmp(path,"NULL")==0) | |||||
return(0); | |||||
if(strcmp(path,"DFT")==0) | |||||
return(1); | |||||
if((f = fopen(buf,"rb")) == NULL) | |||||
if(addr == 0) | |||||
{ | { | ||||
sprintf(buf,"%s%s.wav",path_source,path); | |||||
sprintf(buf,"%s%s",path_source,path); | |||||
if((f = fopen(buf,"rb")) == NULL) | if((f = fopen(buf,"rb")) == NULL) | ||||
{ | { | ||||
Error("Can't read file",path); | |||||
return(0); | |||||
sprintf(buf,"%s%s.wav",path_source,path); | |||||
if((f = fopen(buf,"rb")) == NULL) | |||||
{ | |||||
Error("Can't read file",path); | |||||
return(0); | |||||
} | |||||
} | } | ||||
} | |||||
id = Read4Bytes(f); | |||||
// fread(&id,1,4,f); | |||||
rewind(f); | |||||
if(id == 0x43455053) | |||||
{ | |||||
ix = LoadSpect(path, control); | |||||
type_code = 'S'; | |||||
} | |||||
else | |||||
if(id == 0x46464952) | |||||
{ | |||||
ix = LoadWavefile(f,path); | |||||
type_code = 'W'; | |||||
} | |||||
else | |||||
if(id == 0x43544950) | |||||
{ | |||||
ix = LoadEnvelope(f,path); | |||||
type_code = 'E'; | |||||
} | |||||
else | |||||
if(id == 0x45564E45) | |||||
{ | |||||
ix = LoadEnvelope2(f,path); | |||||
type_code = 'E'; | |||||
} | |||||
else | |||||
{ | |||||
Error("File not SPEC or RIFF",path); | |||||
ix = -1; | |||||
id = Read4Bytes(f); | |||||
rewind(f); | |||||
if(id == 0x43455053) | |||||
{ | |||||
addr = LoadSpect(path, control); | |||||
type_code = 'S'; | |||||
} | |||||
else | |||||
if(id == 0x46464952) | |||||
{ | |||||
addr = LoadWavefile(f,path); | |||||
type_code = 'W'; | |||||
} | |||||
else | |||||
if(id == 0x43544950) | |||||
{ | |||||
addr = LoadEnvelope(f,path); | |||||
type_code = 'E'; | |||||
} | |||||
else | |||||
if(id == 0x45564E45) | |||||
{ | |||||
addr = LoadEnvelope2(f,path); | |||||
type_code = 'E'; | |||||
} | |||||
else | |||||
{ | |||||
Error("File not SPEC or RIFF",path); | |||||
addr = -1; | |||||
} | |||||
fclose(f); | |||||
if(addr > 0) | |||||
{ | |||||
fprintf(f_phcontents,"%c 0x%.5x %s\n",type_code,addr & 0x7fffff,path); | |||||
} | |||||
} | } | ||||
fclose(f); | |||||
if(ix > 0) | |||||
// add this item to the hash table | |||||
if(addr > 0) | |||||
{ | { | ||||
fprintf(f_phcontents,"%c 0x%.5x %s\n",type_code,ix & 0x7fffff,path); | |||||
p = ref_hash_tab[hash]; | |||||
p2 = (REF_HASH_TAB *)malloc(sizeof(REF_HASH_TAB)+strlen(path)+1); | |||||
p2->value = addr; | |||||
p2->ph_mnemonic = ph->mnemonic; // phoneme which uses this file | |||||
p2->ph_table = n_phoneme_tabs-1; | |||||
strcpy(p2->string,path); | |||||
p2->link = (char *)p; | |||||
ref_hash_tab[hash] = p2; | |||||
} | } | ||||
// add this item to the hash table | |||||
p = ref_hash_tab[hash]; | |||||
p2 = (REF_HASH_TAB *)malloc(sizeof(REF_HASH_TAB)+strlen(path)+1); | |||||
p2->value = ix; | |||||
p2->n_uses = 1; | |||||
p2->n_used_by = 1; | |||||
strcpy(p2->string,path); | |||||
p2->used_by[0] = n_phoneme_tabs; | |||||
p2->link = (char *)p; | |||||
ref_hash_tab[hash] = p2; | |||||
return(ix); | |||||
return(addr); | |||||
} // end of Compile::LoadDataFile | } // end of Compile::LoadDataFile | ||||
static int ref_sorter(char **a, char **b) | static int ref_sorter(char **a, char **b) | ||||
{//====================================== | {//====================================== | ||||
int ix; | |||||
REF_HASH_TAB *p1 = (REF_HASH_TAB *)(*a); | REF_HASH_TAB *p1 = (REF_HASH_TAB *)(*a); | ||||
REF_HASH_TAB *p2 = (REF_HASH_TAB *)(*b); | |||||
REF_HASH_TAB *p2 = (REF_HASH_TAB *)(*b); | |||||
ix = strcoll(p1->string,p2->string); | |||||
if(ix != 0) | |||||
return ix; | |||||
ix = p1->ph_table - p2->ph_table; | |||||
if(ix != 0) | |||||
return ix; | |||||
return(strcoll(p1->string,p2->string)); | |||||
} /* end of strcmp2 */ | |||||
return(p1->ph_mnemonic - p2->ph_mnemonic); | |||||
} /* end of ref_sorter */ | |||||
REF_HASH_TAB *p; | REF_HASH_TAB *p; | ||||
REF_HASH_TAB **list; | REF_HASH_TAB **list; | ||||
FILE *f_report; | FILE *f_report; | ||||
const char *data_path; | |||||
int prev_table; | |||||
int prev_mnemonic; | |||||
char fname[sizeof(path_source)+20]; | char fname[sizeof(path_source)+20]; | ||||
// make a list of all the references and sort it | // make a list of all the references and sort it | ||||
list = (REF_HASH_TAB **)malloc(count_references * sizeof(REF_HASH_TAB *)); | |||||
list = (REF_HASH_TAB **)malloc((count_references)* sizeof(REF_HASH_TAB *)); | |||||
if(list == NULL) | if(list == NULL) | ||||
return; | return; | ||||
} | } | ||||
fputc('\n',f_report); | fputc('\n',f_report); | ||||
fprintf(f_report,"Data file Used by\n"); | |||||
ix = 0; | ix = 0; | ||||
for(hash=0; (hash < 256) && (ix < count_references); hash++) | for(hash=0; (hash < 256) && (ix < count_references); hash++) | ||||
{ | { | ||||
n = ix; | n = ix; | ||||
qsort((void *)list,n,sizeof(REF_HASH_TAB *),(int (*)(const void *,const void *))ref_sorter); | qsort((void *)list,n,sizeof(REF_HASH_TAB *),(int (*)(const void *,const void *))ref_sorter); | ||||
data_path = ""; | |||||
prev_mnemonic = 0; | |||||
prev_table = 0; | |||||
for(ix=0; ix<n; ix++) | for(ix=0; ix<n; ix++) | ||||
{ | { | ||||
int j, ph_tab_num; | |||||
int j = 0; | |||||
fprintf(f_report,"%3d %s",list[ix]->n_uses, list[ix]->string); | |||||
for(j = strlen(list[ix]->string); j < 14; j++) | |||||
if(strcmp(list[ix]->string, data_path) != 0) | |||||
{ | { | ||||
fputc(' ',f_report); // pad filename with spaces | |||||
data_path = list[ix]->string; | |||||
j = strlen(data_path); | |||||
fprintf(f_report,"%s",data_path); | |||||
} | } | ||||
for(j=0; (j < list[ix]->n_used_by) && (j<N_USED_BY); j++) | |||||
else | |||||
{ | { | ||||
ph_tab_num = list[ix]->used_by[j]; | |||||
fprintf(f_report," %s",phoneme_tab_list2[ph_tab_num-1].name); | |||||
if((list[ix]->ph_table == prev_table) && (list[ix]->ph_mnemonic == prev_mnemonic)) | |||||
continue; // same phoneme, don't list twice | |||||
} | } | ||||
if(j < list[ix]->n_used_by) | |||||
while(j < 14) | |||||
{ | { | ||||
fprintf(f_report," ++"); | |||||
fputc(' ',f_report); // pad filename with spaces | |||||
j++; | |||||
} | } | ||||
fprintf(f_report," [%s] %s",WordToString(prev_mnemonic = list[ix]->ph_mnemonic), phoneme_tab_list2[prev_table = list[ix]->ph_table].name); | |||||
fputc('\n',f_report); | fputc('\n',f_report); | ||||
free(list[ix]); | |||||
} | } | ||||
free(list); | free(list); | ||||
fclose(f_report); | fclose(f_report); |
char *p; | char *p; | ||||
char *word; | char *word; | ||||
char *phonetic; | char *phonetic; | ||||
int ix; | |||||
unsigned int ix; | |||||
int step; | int step; | ||||
int n_flag_codes = 0; | |||||
unsigned int n_flag_codes = 0; | |||||
int flag_offset; | int flag_offset; | ||||
int length; | int length; | ||||
int multiple_words = 0; | int multiple_words = 0; | ||||
unsigned char flag_codes[100]; | unsigned char flag_codes[100]; | ||||
char encoded_ph[200]; | char encoded_ph[200]; | ||||
unsigned char bad_phoneme[4]; | unsigned char bad_phoneme[4]; | ||||
static char nullstring[] = {0}; | |||||
comment = NULL; | comment = NULL; | ||||
text_not_phonemes = 0; | text_not_phonemes = 0; | ||||
phonetic = word = ""; | |||||
phonetic = word = nullstring; | |||||
p = linebuf; | p = linebuf; | ||||
// while(isspace2(*p)) p++; | // while(isspace2(*p)) p++; | ||||
int n_rules=0; | int n_rules=0; | ||||
int count=0; | int count=0; | ||||
int different; | int different; | ||||
char *prev_rgroup_name; | |||||
const char *prev_rgroup_name; | |||||
unsigned int char_code; | unsigned int char_code; | ||||
int compile_mode=0; | int compile_mode=0; | ||||
char *buf; | char *buf; | ||||
if(buf[0] == '\r') buf++; // ignore extra \r in \r\n | if(buf[0] == '\r') buf++; // ignore extra \r in \r\n | ||||
} | } | ||||
if((buf != NULL) && (memcmp(buf,".L",2)==0)) | |||||
{ | |||||
if(compile_lettergroup(&buf[2], f_out) != 0) | |||||
{ | |||||
fprintf(f_log,"%5d: Bad lettergroup\n",linenum); | |||||
error_count++; | |||||
} | |||||
continue; | |||||
} | |||||
if((buf == NULL) || (buf[0] == '.')) | if((buf == NULL) || (buf[0] == '.')) | ||||
{ | { | ||||
// next .group or end of file, write out the previous group | // next .group or end of file, write out the previous group | ||||
{ | { | ||||
// end of the character replacements section | // end of the character replacements section | ||||
fwrite(&n_rules,1,4,f_out); // write a zero word to terminate the replacemenmt list | fwrite(&n_rules,1,4,f_out); // write a zero word to terminate the replacemenmt list | ||||
compile_mode = 0; | |||||
} | } | ||||
if(buf == NULL) break; // end of file | if(buf == NULL) break; // end of file | ||||
if(memcmp(buf,".L",2)==0) | |||||
{ | |||||
if(compile_lettergroup(&buf[2], f_out) != 0) | |||||
{ | |||||
fprintf(f_log,"%5d: Bad lettergroup\n",linenum); | |||||
error_count++; | |||||
} | |||||
continue; | |||||
} | |||||
if(memcmp(buf,".replace",8)==0) | if(memcmp(buf,".replace",8)==0) | ||||
{ | { | ||||
compile_mode = 2; | compile_mode = 2; |
if(p[0] == RULE_REPLACEMENTS) | if(p[0] == RULE_REPLACEMENTS) | ||||
{ | { | ||||
pw = (unsigned int *)(((int)p+4) & ~3); // advance to next word boundary | |||||
pw = (unsigned int *)(((long)p+4) & ~3); // advance to next word boundary | |||||
langopts.replace_chars = pw; | langopts.replace_chars = pw; | ||||
while(pw[0] != 0) | while(pw[0] != 0) | ||||
{ | { | ||||
int Translator::IsLetterGroup(char *word, int group) | |||||
{//================================================= | |||||
int Translator::IsLetterGroup(char *word, int group, int pre) | |||||
{//========================================================== | |||||
// match the word against a list of utf-8 strings | // match the word against a list of utf-8 strings | ||||
char *p; | char *p; | ||||
char *w; | char *w; | ||||
if(rb == RULE_ENDING) | if(rb == RULE_ENDING) | ||||
{ | { | ||||
static char *flag_chars = "ei vtfq t"; | |||||
static const char *flag_chars = "ei vtfq t"; | |||||
flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f); | flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f); | ||||
suffix_char = 'S'; | suffix_char = 'S'; | ||||
if(flags & (SUFX_P >> 8)) | if(flags & (SUFX_P >> 8)) | ||||
failed = 1; | failed = 1; | ||||
break; | break; | ||||
case RULE_LETTERGP2: // match against a list of utf-t strings | |||||
case RULE_LETTERGP2: // match against a list of utf-8 strings | |||||
letter_group = *rule++ - 'A'; | letter_group = *rule++ - 'A'; | ||||
if((n_bytes = IsLetterGroup(post_ptr-1,letter_group)) >0) | |||||
if((n_bytes = IsLetterGroup(post_ptr-1,letter_group,0)) >0) | |||||
{ | { | ||||
match.points += (20-distance_right); | match.points += (20-distance_right); | ||||
post_ptr += (n_bytes-1); | post_ptr += (n_bytes-1); | ||||
failed = 1; | failed = 1; | ||||
break; | break; | ||||
case RULE_LETTERGP2: // match against a list of utf-8 strings | |||||
letter_group = *rule++ - 'A'; | |||||
if((n_bytes = IsLetterGroup(pre_ptr-letter_xbytes,letter_group,1)) >0) | |||||
{ | |||||
match.points += (20-distance_right); | |||||
pre_ptr -= (n_bytes-1); | |||||
} | |||||
else | |||||
failed =1; | |||||
break; | |||||
case RULE_NOTVOWEL: | case RULE_NOTVOWEL: | ||||
if(!IsLetter(letter_w,0)) | if(!IsLetter(letter_w,0)) | ||||
{ | { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if(match1.phonemes == NULL) | if(match1.phonemes == NULL) | ||||
match1.phonemes = ""; | match1.phonemes = ""; | ||||
int Translator::LookupDict2(char *word, char *word2, char *phonetic, unsigned int *flags, int end_flags) | |||||
//====================================================================================================== | |||||
const char *Translator::LookupDict2(const char *word, const char *word2, char *phonetic, unsigned int *flags, int end_flags) | |||||
//==================================================================================================================== | |||||
/* Find an entry in the word_dict file for a specified word. | /* Find an entry in the word_dict file for a specified word. | ||||
Returns 1 if an entry is found | |||||
Returns NULL if no match, else returns 'word_end' | |||||
word zero terminated word to match | word zero terminated word to match | ||||
word2 pointer to next word(s) in the input text (terminated by space) | word2 pointer to next word(s) in the input text (terminated by space) | ||||
int condition_failed=0; | int condition_failed=0; | ||||
int n_chars; | int n_chars; | ||||
int no_phonemes; | int no_phonemes; | ||||
char *word_end; | |||||
char *word1; | |||||
const char *word_end; | |||||
const char *word1; | |||||
char word_buf[N_WORD_BYTES]; | char word_buf[N_WORD_BYTES]; | ||||
word1 = word; | word1 = word; | ||||
fprintf(f_trans,"Found: %s [%s] %s\n",word1,ph_decoded,print_dflags(flags1)); | fprintf(f_trans,"Found: %s [%s] %s\n",word1,ph_decoded,print_dflags(flags1)); | ||||
} | } | ||||
} | } | ||||
return(1); | |||||
return(word_end); | |||||
} | } | ||||
return(0); | return(0); | ||||
*/ | */ | ||||
{ | { | ||||
int length; | int length; | ||||
int found; | |||||
char *word1; | |||||
char *word2; | |||||
const char *found; | |||||
const char *word1; | |||||
const char *word2; | |||||
unsigned char c; | unsigned char c; | ||||
int nbytes; | int nbytes; | ||||
int c2; | int c2; | ||||
int len; | |||||
char word[N_WORD_BYTES]; | char word[N_WORD_BYTES]; | ||||
static char word_replacement[N_WORD_BYTES]; | static char word_replacement[N_WORD_BYTES]; | ||||
word_replacement[0] = 0; | word_replacement[0] = 0; | ||||
word_replacement[1] = ' '; | word_replacement[1] = ' '; | ||||
strcpy(&word_replacement[2],ph_out); // replacement word, preceded by zerochar and space | strcpy(&word_replacement[2],ph_out); // replacement word, preceded by zerochar and space | ||||
word1 = *wordptr; | |||||
*wordptr = &word_replacement[2]; | *wordptr = &word_replacement[2]; | ||||
if(option_phonemes == 2) | if(option_phonemes == 2) | ||||
{ | { | ||||
len = found - word1; | |||||
memcpy(word,word1,len); // include multiple matching words | |||||
fprintf(f_trans,"Replace: %s %s\n",word,*wordptr); | fprintf(f_trans,"Replace: %s %s\n",word,*wordptr); | ||||
} | } | ||||
} | } | ||||
int Translator::Lookup(char *word, char *ph_out) | |||||
{//============================================= | |||||
int Translator::Lookup(const char *word, char *ph_out) | |||||
{//=================================================== | |||||
unsigned int flags; | unsigned int flags; | ||||
return(LookupDictList(&word,ph_out,&flags,0)); | |||||
char *word1 = (char *)word; | |||||
return(LookupDictList(&word1,ph_out,&flags,0)); | |||||
} | } | ||||
case ET_VOICE_SPEC: | case ET_VOICE_SPEC: | ||||
{ | { | ||||
espeak_VOICE* data = &(the_command->u.my_voice_spec); | |||||
if (data->name) | |||||
{ | |||||
free(data->name); | |||||
} | |||||
if (data->languages) | |||||
{ | |||||
free(data->languages); | |||||
} | |||||
if (data->identifier) | |||||
{ | |||||
free(data->identifier); | |||||
} | |||||
espeak_VOICE* data = &(the_command->u.my_voice_spec); | |||||
if (data->name) | |||||
{ | |||||
free((void *)data->name); | |||||
} | |||||
if (data->languages) | |||||
{ | |||||
free((void *)data->languages); | |||||
} | |||||
if (data->identifier) | |||||
{ | |||||
free((void *)data->identifier); | |||||
} | |||||
} | } | ||||
break; | break; | ||||
#include "prosodydisplay.h" | #include "prosodydisplay.h" | ||||
static char *about_string = "espeakedit: %s\nAuthor: Jonathan Duddington (c) 2007\n\n" | |||||
static const char *about_string = "espeakedit: %s\nAuthor: Jonathan Duddington (c) 2007\n\n" | |||||
"Licensed under GNU General Public License version 3\n" | "Licensed under GNU General Public License version 3\n" | ||||
"http://espeak.sourceforge.net/"; | "http://espeak.sourceforge.net/"; | ||||
char phonemes2[80]; | char phonemes2[80]; | ||||
WORD_TAB winfo; | WORD_TAB winfo; | ||||
static char *vowels = "aeiouyAEIOUY29@"; | |||||
static const char *vowels = "aeiouyAEIOUY29@"; | |||||
wxString fname = wxFileSelector(_T("German Lexicon"),path_dir1,_T(""),_T(""),_T("*"),wxOPEN); | wxString fname = wxFileSelector(_T("German Lexicon"),path_dir1,_T(""),_T(""),_T("*"),wxOPEN); | ||||
int input_length; | int input_length; | ||||
int sfx; | int sfx; | ||||
char *suffix; | |||||
const char *suffix; | |||||
int wlen; | int wlen; | ||||
int len; | int len; | ||||
int check_root; | int check_root; | ||||
static char vowels[] = {0xa3,0xc0,0xc1,0xc5,0xc9,0xcf,0xd1,0xd5,0xd9,0xdc,0}; | static char vowels[] = {0xa3,0xc0,0xc1,0xc5,0xc9,0xcf,0xd1,0xd5,0xd9,0xdc,0}; | ||||
typedef struct { | typedef struct { | ||||
char *suffix; | |||||
const char *suffix; | |||||
int syllables; | int syllables; | ||||
} SUFFIX; | } SUFFIX; | ||||
#define TEXT "Hello world." | #define TEXT "Hello world." | ||||
#define TEXT_SSML ("<speak>" TEXT "</speak>") | #define TEXT_SSML ("<speak>" TEXT "</speak>") | ||||
static void | static void | ||||
speak(char *text) | |||||
speak(const char *text) | |||||
{ | { | ||||
int result; | int result; | ||||
result = espeak_Synth(text, strlen(text) + 1, 0, POS_CHARACTER, 0, espeakSSML, NULL, NULL); | result = espeak_Synth(text, strlen(text) + 1, 0, POS_CHARACTER, 0, espeakSSML, NULL, NULL); | ||||
} | } | ||||
char* text1 = "Hello World2. <audio src=\"here\"> Some text</audio> This is the second sentence"; | |||||
const char* text1 = "Hello World2. <audio src=\"here\"> Some text</audio> This is the second sentence"; | |||||
void TestTest(int control) | void TestTest(int control) | ||||
{//======================= | {//======================= |
PHONEME_LIST *p; | PHONEME_LIST *p; | ||||
int ix; | int ix; | ||||
int count_stressed=0; | int count_stressed=0; | ||||
int count_stressed2=0; | |||||
int final_stressed=0; | int final_stressed=0; | ||||
int tone_ph; | int tone_ph; | ||||
PHONEME_TAB *tph; | |||||
PHONEME_TAB *prev_tph; // forget across word boundary | |||||
PHONEME_TAB *prevw_tph; // remember across word boundary | |||||
PHONEME_TAB *prev2_tph; // 2 tones previous | |||||
PHONEME_LIST *prev_p; | |||||
int pitch_adjust = 13; // pitch gradient through the clause - inital value | int pitch_adjust = 13; // pitch gradient through the clause - inital value | ||||
int pitch_decrement = 3; // decrease by this for each stressed syllable | int pitch_decrement = 3; // decrease by this for each stressed syllable | ||||
} | } | ||||
p = &phoneme_list[0]; | |||||
prev_p = p = &phoneme_list[0]; | |||||
prev_tph = prevw_tph = phoneme_tab[phonPAUSE]; | |||||
// perform tone sandhi | |||||
for(ix=0; ix<n_phoneme_list; ix++, p++) | for(ix=0; ix<n_phoneme_list; ix++, p++) | ||||
{ | { | ||||
if((p->newword) && ((option_tone1 & 1)==0)) | |||||
{ | |||||
prev_tph = phoneme_tab[phonPAUSE]; // forget across word boundaries | |||||
} | |||||
if(p->type == phVOWEL) | if(p->type == phVOWEL) | ||||
{ | { | ||||
tone_ph = p->tone_ph; | tone_ph = p->tone_ph; | ||||
if(tone_ph == 0) | |||||
p->tone_ph = tone_ph = LookupPh("11"); // default tone 5 | |||||
tph = phoneme_tab[tone_ph]; | |||||
if(p->tone >= 2) | |||||
// Mandarin | |||||
if(translator_name == L('z','h')) | |||||
{ | { | ||||
// a stressed syllable | |||||
if(p->tone >= 4) | |||||
if(prev_tph->mnemonic == 0x343132) // [214] | |||||
{ | { | ||||
count_stressed2++; | |||||
if(count_stressed2 == count_stressed) | |||||
{ | |||||
// the last stressed syllable | |||||
pitch_adjust = pitch_low; | |||||
} | |||||
if(tph->mnemonic == 0x343132) // [214] | |||||
prev_p->tone_ph = LookupPh("35"); | |||||
else | else | ||||
{ | |||||
pitch_adjust -= pitch_decrement; | |||||
if(pitch_adjust <= pitch_low) | |||||
pitch_adjust = pitch_high; | |||||
} | |||||
prev_p->tone_ph = LookupPh("21"); | |||||
} | |||||
if((prev_tph->mnemonic == 0x3135) && (tph->mnemonic == 0x3135)) // [51] + [51] | |||||
{ | |||||
prev_p->tone_ph = LookupPh("53"); | |||||
} | |||||
if(tph->mnemonic == 0x3131) // [11] Tone 5 | |||||
{ | |||||
// tone 5, change its level depending on the previous tone (across word boundaries) | |||||
if(prevw_tph->mnemonic == 0x3535) | |||||
p->tone_ph = LookupPh("22"); | |||||
if(prevw_tph->mnemonic == 0x3533) | |||||
p->tone_ph = LookupPh("33"); | |||||
if(prevw_tph->mnemonic == 0x343132) | |||||
p->tone_ph = LookupPh("44"); | |||||
// tone 5 is unstressed (shorter) | |||||
p->tone = 1; // diminished stress | |||||
} | |||||
} | |||||
prev_p = p; | |||||
prev2_tph = prevw_tph; | |||||
prevw_tph = prev_tph = tph; | |||||
} | |||||
} | |||||
// convert tone numbers to pitch | |||||
p = &phoneme_list[0]; | |||||
for(ix=0; ix<n_phoneme_list; ix++, p++) | |||||
{ | |||||
if(p->type == phVOWEL) | |||||
{ | |||||
tone_ph = p->tone_ph; | |||||
if(p->tone >= 0) // TEST, consider all syllables as stressed | |||||
{ | |||||
if(ix == final_stressed) | |||||
{ | |||||
// the last stressed syllable | |||||
pitch_adjust = pitch_low; | |||||
} | |||||
else | |||||
{ | |||||
pitch_adjust -= pitch_decrement; | |||||
if(pitch_adjust <= pitch_low) | |||||
pitch_adjust = pitch_high; | |||||
} | } | ||||
if(tone_ph ==0) | if(tone_ph ==0) |
#include "StdAfx.h" | #include "StdAfx.h" | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
unsigned int flags; | unsigned int flags; | ||||
char number_chars[N_WORD_BYTES]; | char number_chars[N_WORD_BYTES]; | ||||
static char *roman_numbers = "ixcmvld"; | |||||
static const char *roman_numbers = "ixcmvld"; | |||||
static int roman_values[] = {1,10,100,1000,5,50,500}; | static int roman_values[] = {1,10,100,1000,5,50,500}; | ||||
acc = 0; | acc = 0; | ||||
static char *M_Variant(int value) | |||||
{//============================== | |||||
static const char *M_Variant(int value) | |||||
{//==================================== | |||||
// returns M, or perhaps MA for some cases | // returns M, or perhaps MA for some cases | ||||
if(((value % 100)>20) || ((value % 100)<10)) // but not teens, 10 to 19 | if(((value % 100)>20) || ((value % 100)<10)) // but not teens, 10 to 19 |
#define N_XML_BUF 256 | #define N_XML_BUF 256 | ||||
char *xmlbase = ""; // base URL from <speak> | |||||
const char *xmlbase = ""; // base URL from <speak> | |||||
int namedata_ix=0; | int namedata_ix=0; | ||||
int n_namedata = 0; | int n_namedata = 0; | ||||
static void UngetC(int c) | static void UngetC(int c) | ||||
{//====================== | {//====================== | ||||
ungot_char = c; | ungot_char = c; | ||||
if((f_input != NULL) && feof(f_input)) | |||||
{ | |||||
// ungetc(' ',f_input); | |||||
} | |||||
} | } | ||||
const char *Translator::LookupSpecial(char *string) | |||||
{//================================================ | |||||
const char *Translator::LookupSpecial(const char *string) | |||||
{//====================================================== | |||||
unsigned int flags; | unsigned int flags; | ||||
char phonemes[55]; | char phonemes[55]; | ||||
char phonemes2[55]; | char phonemes2[55]; | ||||
static char buf[60]; | static char buf[60]; | ||||
char *string1 = (char *)string; | |||||
if(LookupDictList(&string,phonemes,&flags,0)) | |||||
if(LookupDictList(&string1,phonemes,&flags,0)) | |||||
{ | { | ||||
SetWordStress(phonemes,flags,-1,0); | SetWordStress(phonemes,flags,-1,0); | ||||
DecodePhonemes(phonemes,phonemes2); | DecodePhonemes(phonemes,phonemes2); | ||||
static char *VoiceFromStack() | |||||
{//========================== | |||||
static const char *VoiceFromStack() | |||||
{//================================ | |||||
// Use the voice properties from the SSML stack to choose a voice, and switch | // Use the voice properties from the SSML stack to choose a voice, and switch | ||||
// to that voice if it's not the current voice | // to that voice if it's not the current voice | ||||
int ix; | int ix; | ||||
SSML_STACK *sp; | SSML_STACK *sp; | ||||
char *v_id; | |||||
const char *v_id; | |||||
espeak_VOICE voice_select; | espeak_VOICE voice_select; | ||||
char voice_name[40]; | char voice_name[40]; | ||||
char language[40]; | char language[40]; | ||||
wchar_t *name; | wchar_t *name; | ||||
wchar_t *age; | wchar_t *age; | ||||
wchar_t *variant; | wchar_t *variant; | ||||
char *new_voice_id; | |||||
const char *new_voice_id; | |||||
static const MNEM_TAB mnem_gender[] = { | static const MNEM_TAB mnem_gender[] = { | ||||
{"male", 1}, | {"male", 1}, |
int length; | int length; | ||||
int finished = 0; | int finished = 0; | ||||
int count_buffers = 0; | int count_buffers = 0; | ||||
#ifdef USE_ASYNC | |||||
uint32_t a_write_pos=0; | uint32_t a_write_pos=0; | ||||
#endif | |||||
#ifdef DEBUG_ENABLED | #ifdef DEBUG_ENABLED | ||||
if (text) | if (text) |
// voice table | // voice table | ||||
typedef struct { | typedef struct { | ||||
char *name; // a given name for this voice. UTF8 string. | |||||
char *languages; // list of pairs of (byte) priority + (string) language (and dialect qualifier) | |||||
char *identifier; // the filename for this voice within espeak-data/voices | |||||
const char *name; // a given name for this voice. UTF8 string. | |||||
const char *languages; // list of pairs of (byte) priority + (string) language (and dialect qualifier) | |||||
const char *identifier; // the filename for this voice within espeak-data/voices | |||||
unsigned char gender; // 0=none 1=male, 2=female, | unsigned char gender; // 0=none 1=male, 2=female, | ||||
unsigned char age; // 0=not specified, or age in years | unsigned char age; // 0=not specified, or age in years | ||||
unsigned char variant; // only used when passed as a parameter to espeak_SetVoiceByProperties | unsigned char variant; // only used when passed as a parameter to espeak_SetVoiceByProperties |
#include "translate.h" | #include "translate.h" | ||||
#include "wave.h" | #include "wave.h" | ||||
const char *version_string = "1.29.12 29.Oct.07"; | |||||
const char *version_string = "1.29.15 01.Nov.07"; | |||||
const int version_phdata = 0x012901; | const int version_phdata = 0x012901; | ||||
int option_device_number = -1; | int option_device_number = -1; |
// entries in the wavegen command queue | // entries in the wavegen command queue | ||||
p_text = translator->TranslateClause(f_text,p_text,&clause_tone,&voice_change); | p_text = translator->TranslateClause(f_text,p_text,&clause_tone,&voice_change); | ||||
translator->CalcPitches(clause_tone); | |||||
translator->CalcLengths(); | |||||
translator->GetTranslatedPhonemeString(translator->phon_out,sizeof(translator->phon_out)); | |||||
if(option_phonemes > 0) | if(option_phonemes > 0) | ||||
{ | { | ||||
fprintf(f_trans,"%s\n",translator->phon_out); | fprintf(f_trans,"%s\n",translator->phon_out); | ||||
phoneme_callback(translator->phon_out); | phoneme_callback(translator->phon_out); | ||||
} | } | ||||
translator->CalcPitches(clause_tone); | |||||
translator->CalcLengths(); | |||||
if(skipping_text) | if(skipping_text) | ||||
{ | { |
{ | { | ||||
static int stress_amps_sk[8] = {16,16, 20,20, 20,24, 24,22 }; | static int stress_amps_sk[8] = {16,16, 20,20, 20,24, 24,22 }; | ||||
static int stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210}; | static int stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210}; | ||||
static char *sk_voiced = "bdgjlmnrvwzaeiouy"; | |||||
static const char *sk_voiced = "bdgjlmnrvwzaeiouy"; | |||||
tr = new Translator(); | tr = new Translator(); | ||||
SetupTranslator(tr,stress_lengths_sk,stress_amps_sk); | SetupTranslator(tr,stress_lengths_sk,stress_amps_sk); | ||||
break; | break; | ||||
case L('z','h'): | case L('z','h'): | ||||
case L_qa + 'a': // Test qaa | |||||
{ | { | ||||
static int stress_lengths_qaa[8] = {200,200, 248,248, 248,0, 248,250}; | |||||
static int stress_amps_qaa[] = {16,16, 20,20, 24,24, 24,22 }; | |||||
static int stress_lengths_qaa[8] = {220,150, 230,230, 230,0, 230,250}; | |||||
static int stress_amps_qaa[] = {22,18, 22,22, 22,22, 22,22 }; | |||||
tr = new Translator(); | tr = new Translator(); | ||||
SetupTranslator(tr,stress_lengths_qaa,stress_amps_qaa); | SetupTranslator(tr,stress_lengths_qaa,stress_amps_qaa); | ||||
tr->langopts.stress_rule = 0; | |||||
tr->langopts.stress_rule = 3; // stress on final syllable of a "word" | |||||
tr->langopts.stress_flags = 1; // don't automatically set diminished stress (may be set in the intonation module) | |||||
tr->langopts.vowel_pause = 0; | tr->langopts.vowel_pause = 0; | ||||
tr->langopts.intonation = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches() | tr->langopts.intonation = 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.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable | ||||
tr->langopts.tone_numbers = 9; | |||||
tr->langopts.tone_numbers = 9; // a number after letters indicates a tone number (eg. pinyin or jyutping) | |||||
tr->langopts.ideographs = 1; | tr->langopts.ideographs = 1; | ||||
tr->langopts.word_gap = 0x5; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word | tr->langopts.word_gap = 0x5; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word | ||||
} | } |
} // end of utf8_out | } // end of utf8_out | ||||
int utf8_in(int *c, char *buf, int backwards) | |||||
{//========================================== | |||||
int utf8_in(int *c, const char *buf, int backwards) | |||||
{//================================================ | |||||
int c1; | int c1; | ||||
int n_bytes; | int n_bytes; | ||||
int ix; | int ix; | ||||
int source_ix; | int source_ix; | ||||
int len; | int len; | ||||
int sylimit; // max. number of syllables in a word to be combined with a preceding preposition | int sylimit; // max. number of syllables in a word to be combined with a preceding preposition | ||||
char *new_language; | |||||
const char *new_language; | |||||
unsigned char bad_phoneme[4]; | unsigned char bad_phoneme[4]; | ||||
len = wtab->length; | len = wtab->length; | ||||
prev_out2 = prev_out; | prev_out2 = prev_out; | ||||
utf8_in(&prev_out,&sbuf[ix-1],1); // prev_out = sbuf[ix-1]; | utf8_in(&prev_out,&sbuf[ix-1],1); // prev_out = sbuf[ix-1]; | ||||
if(langopts.tone_numbers && isdigit(prev_out) && IsAlpha(prev_out2)) | |||||
{ | |||||
// tone numbers can be part of a word, consider them as alphabetic | |||||
prev_out = 'a'; | |||||
} | |||||
if(prev_in2 != 0) | if(prev_in2 != 0) | ||||
{ | { | ||||
prev_in = prev_in2; | prev_in = prev_in2; | ||||
prev_clause_pause = clause_pause; | prev_clause_pause = clause_pause; | ||||
GetTranslatedPhonemeString(phon_out,sizeof(phon_out)); | |||||
*tone_out = tone; | *tone_out = tone; | ||||
new_sentence = 0; | new_sentence = 0; |
// match 1 pre 2 post 0 - use common phoneme string | // match 1 pre 2 post 0 - use common phoneme string | ||||
// match 1 pre 2 post 3 0 - empty phoneme string | // match 1 pre 2 post 3 0 - empty phoneme string | ||||
typedef const char * constcharptr; | |||||
typedef struct { | typedef struct { | ||||
int points; | int points; | ||||
int LoadDictionary(const char *name, int no_error); | int LoadDictionary(const char *name, int no_error); | ||||
virtual void CalcLengths(); | virtual void CalcLengths(); | ||||
virtual void CalcPitches(int clause_tone); | virtual void CalcPitches(int clause_tone); | ||||
void GetTranslatedPhonemeString(char *phon_out, int n_phon_out); | |||||
LANGUAGE_OPTIONS langopts; | LANGUAGE_OPTIONS langopts; | ||||
int translator_name; | int translator_name; | ||||
int TranslateWord2(char *word, WORD_TAB *wtab, int pre_pause, int next_pause); | int TranslateWord2(char *word, WORD_TAB *wtab, int pre_pause, int next_pause); | ||||
int TranslateLetter(char *letter, char *phonemes, int control); | int TranslateLetter(char *letter, char *phonemes, int control); | ||||
void SetSpellingStress(char *phonemes, int control); | void SetSpellingStress(char *phonemes, int control); | ||||
void GetTranslatedPhonemeString(char *phon_out, int n_phon_out); | |||||
void WriteMnemonic(int *ix, int mnem); | void WriteMnemonic(int *ix, int mnem); | ||||
void MakePhonemeList(int post_pause, int new_sentence); | void MakePhonemeList(int post_pause, int new_sentence); | ||||
int SubstitutePhonemes(PHONEME_LIST2 *plist_out); | int SubstitutePhonemes(PHONEME_LIST2 *plist_out); | ||||
int ReadClause(FILE *f_in, char *buf, unsigned short *charix, int n_buf); | int ReadClause(FILE *f_in, char *buf, unsigned short *charix, int n_buf); | ||||
int AnnouncePunctuation(int c1, int c2, char *buf, int ix); | int AnnouncePunctuation(int c1, int c2, char *buf, int ix); | ||||
int LookupDict2(char *word, char *word2, char *phonetic, unsigned int *flags, int end_flags); | |||||
const char *LookupSpecial(char *string); | |||||
const char *LookupDict2(const char *word, const char *word2, char *phonetic, unsigned int *flags, int end_flags); | |||||
const char *LookupSpecial(const char *string); | |||||
const char *LookupCharName(int c); | const char *LookupCharName(int c); | ||||
int LookupNum2(int value, int control, char *ph_out); | int LookupNum2(int value, int control, char *ph_out); | ||||
int LookupNum3(int value, char *ph_out, int suppress_null, int thousandplex, int prev_thousands); | int LookupNum3(int value, char *ph_out, int suppress_null, int thousandplex, int prev_thousands); | ||||
void ApplySpecialAttribute(char *phonemes, int dict_flags); | void ApplySpecialAttribute(char *phonemes, int dict_flags); | ||||
int IsLetter(int letter, int group); | int IsLetter(int letter, int group); | ||||
int IsLetterGroup(char *word, int group); | |||||
int IsLetterGroup(char *word, int group, int pre); | |||||
void CalcPitches_Tone(int clause_tone); | void CalcPitches_Tone(int clause_tone); | ||||
int IsVowel(int letter); | int IsVowel(int letter); | ||||
int LookupDictList(char **wordptr, char *ph_out, unsigned int *flags, int end_flags); | int LookupDictList(char **wordptr, char *ph_out, unsigned int *flags, int end_flags); | ||||
int Lookup(char *word, char *ph_out); | |||||
int Lookup(const char *word, char *ph_out); | |||||
// groups1 and groups2 are indexes into data_dictrules, set up by InitGroups() | // groups1 and groups2 are indexes into data_dictrules, set up by InitGroups() | ||||
int PhonemeCode(unsigned int mnem); | int PhonemeCode(unsigned int mnem); | ||||
void ChangeWordStress(Translator *tr, char *word, int new_stress); | void ChangeWordStress(Translator *tr, char *word, int new_stress); | ||||
int TransposeAlphabet(char *text, int offset, int min, int max); | int TransposeAlphabet(char *text, int offset, int min, int max); | ||||
int utf8_in(int *c, char *buf, int backwards); | |||||
int utf8_in(int *c, const char *buf, int backwards); | |||||
int utf8_out(unsigned int c, char *buf); | int utf8_out(unsigned int c, char *buf); | ||||
int lookupwchar(const unsigned short *list,int c); | int lookupwchar(const unsigned short *list,int c); | ||||
int Eof(void); | int Eof(void); |
while((vp != NULL) && (n_ph_list < N_PH_LIST)) | while((vp != NULL) && (n_ph_list < N_PH_LIST)) | ||||
{ | { | ||||
vp = translator->TranslateClause(NULL,vp,&clause_tone,NULL); | vp = translator->TranslateClause(NULL,vp,&clause_tone,NULL); | ||||
translator->CalcPitches(clause_tone); | |||||
translator->CalcLengths(); | |||||
translator->GetTranslatedPhonemeString(translator->phon_out,sizeof(translator->phon_out)); | |||||
if(clause_count++ > 0) | if(clause_count++ > 0) | ||||
strcat(phon_out," ||"); | strcat(phon_out," ||"); | ||||
strcat(phon_out,translator->phon_out); | strcat(phon_out,translator->phon_out); | ||||
t_phonetic->SetValue(wxString(translator->phon_out,wxConvLocal)); | t_phonetic->SetValue(wxString(translator->phon_out,wxConvLocal)); | ||||
translator->CalcPitches(clause_tone); | |||||
translator->CalcLengths(); | |||||
if((n_ph_list + n_phoneme_list) >= N_PH_LIST) | if((n_ph_list + n_phoneme_list) >= N_PH_LIST) | ||||
{ | { |
extern voice_t *voice; | extern voice_t *voice; | ||||
extern int tone_points[10]; | extern int tone_points[10]; | ||||
char *SelectVoice(espeak_VOICE *voice_select); | |||||
const char *SelectVoice(espeak_VOICE *voice_select); | |||||
voice_t *LoadVoice(const char *voice_name, int control); | voice_t *LoadVoice(const char *voice_name, int control); | ||||
voice_t *LoadVoiceVariant(const char *voice_name, int variant); | voice_t *LoadVoiceVariant(const char *voice_name, int variant); | ||||
void DoVoiceChange(voice_t *v); | void DoVoiceChange(voice_t *v); |
char translator_name[40]; | char translator_name[40]; | ||||
char new_dictionary[40]; | char new_dictionary[40]; | ||||
char phonemes_name[40]; | char phonemes_name[40]; | ||||
char *language_type; | |||||
const char *language_type; | |||||
char buf[200]; | char buf[200]; | ||||
char path_voices[sizeof(path_home)+12]; | char path_voices[sizeof(path_home)+12]; | ||||
char langname[4]; | char langname[4]; | ||||
static int ScoreVoice(espeak_VOICE *voice_spec, int spec_n_parts, int spec_lang_len, espeak_VOICE *voice) | static int ScoreVoice(espeak_VOICE *voice_spec, int spec_n_parts, int spec_lang_len, espeak_VOICE *voice) | ||||
{//====================================================================================================== | {//====================================================================================================== | ||||
int ix; | int ix; | ||||
char *p; | |||||
const char *p; | |||||
int c1, c2; | int c1, c2; | ||||
int language_priority; | int language_priority; | ||||
int n_parts; | int n_parts; | ||||
int nv; // number of candidates | int nv; // number of candidates | ||||
int n_parts=0; | int n_parts=0; | ||||
int lang_len=0; | int lang_len=0; | ||||
char *p; | |||||
const char *p; | |||||
espeak_VOICE *vp; | espeak_VOICE *vp; | ||||
// count number of parts in the specified language | // count number of parts in the specified language | ||||
int match_fname = -1; | int match_fname = -1; | ||||
int match_fname2 = -1; | int match_fname2 = -1; | ||||
int match_name = -1; | int match_name = -1; | ||||
char *id; | |||||
const char *id; | |||||
int last_part_len; | int last_part_len; | ||||
char last_part[41]; | char last_part[41]; | ||||
char *SelectVoice(espeak_VOICE *voice_select) | |||||
{//========================================== | |||||
char const *SelectVoice(espeak_VOICE *voice_select) | |||||
{//================================================ | |||||
// Returns a path within espeak-voices, with a possible +variant suffix | // Returns a path within espeak-voices, with a possible +variant suffix | ||||
// variant is an output-only parameter | // variant is an output-only parameter | ||||
int nv; // number of candidates | int nv; // number of candidates | ||||
espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector) | espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector) | ||||
{//============================================================ | {//============================================================ | ||||
char *voice_id; | |||||
const char *voice_id; | |||||
voice_id = SelectVoice(voice_selector); | voice_id = SelectVoice(voice_selector); | ||||
// size of the vowelchart png | // size of the vowelchart png | ||||
#define WIDTH 1200 | |||||
#define WIDTH 1580 | |||||
#define HEIGHT 800 | #define HEIGHT 800 | ||||
static int VowelX(int f2) | static int VowelX(int f2) | ||||
{//====================== | {//====================== | ||||
return(WIDTH - int((log2a(f2) - 9.49)*WIDTH/1.8)); | |||||
// return(1024 - int((log2a(f2) - 9.50)*1020/1.8)); | |||||
return(WIDTH - int((log2a(f2) - 9.40)*WIDTH/1.9)); | |||||
// return(WIDTH - int((log2a(f2) - 9.49)*WIDTH/1.8)); | |||||
} | } | ||||
static int VowelY(int f1) | static int VowelY(int f1) | ||||
if(y < 0) y = 0; | if(y < 0) y = 0; | ||||
if(y > (HEIGHT-4)) y= (HEIGHT-4); | if(y > (HEIGHT-4)) y= (HEIGHT-4); | ||||
if(x < 0) x = 0; | if(x < 0) x = 0; | ||||
if(x > (WIDTH-8)) x = (WIDTH-8); | |||||
if(x > (WIDTH-12)) x = (WIDTH-12); | |||||
r = z; | r = z; | ||||
g = 255; | g = 255; | ||||
if((ix % 100) == 0) | if((ix % 100) == 0) | ||||
dc.DrawText(wxString::Format(_T("%d"),ix),1,y); | dc.DrawText(wxString::Format(_T("%d"),ix),1,y); | ||||
} | } | ||||
for(ix=800; ix<=2400; ix+=100) | |||||
for(ix=700; ix<=2400; ix+=100) | |||||
{ | { | ||||
x = VowelX(ix); | x = VowelX(ix); | ||||
dc.DrawLine(x,0,x,HEIGHT); | dc.DrawLine(x,0,x,HEIGHT); |
//> | //> | ||||
//<wave_open | //<wave_open | ||||
void* wave_open(char* the_api) | |||||
void* wave_open(const char* the_api) | |||||
{ | { | ||||
ENTER("wave_open"); | ENTER("wave_open"); | ||||
static int once=0; | static int once=0; | ||||
void wave_init() {} | void wave_init() {} | ||||
void* wave_open(char* the_api) {return (void *)1;} | |||||
void* wave_open(const char* the_api) {return (void *)1;} | |||||
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;} | size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;} | ||||
int wave_close(void* theHandler) {return 0;} | int wave_close(void* theHandler) {return 0;} | ||||
int wave_is_busy(void* theHandler) {return 0;} | int wave_is_busy(void* theHandler) {return 0;} |
extern void wave_init(); | extern void wave_init(); | ||||
// TBD: the arg could be "alsa", "oss",... | // TBD: the arg could be "alsa", "oss",... | ||||
extern void* wave_open(char* the_api); | |||||
extern void* wave_open(const char* the_api); | |||||
extern size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize); | extern size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize); | ||||
extern int wave_close(void* theHandler); | extern int wave_close(void* theHandler); |