mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-30 22:23:05 +00:00
Merge branch 'master' into build
This commit is contained in:
+301
-34
@@ -21,6 +21,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wx/wx.h"
|
||||
#include "wx/wfstream.h"
|
||||
@@ -42,6 +43,7 @@
|
||||
|
||||
extern void FindPhonemesUsed(void);
|
||||
extern void DisplayErrorFile(const char *fname);
|
||||
extern int utf8_out(unsigned int c, char *buf);
|
||||
char path_source[sizeof(path_home)+20];
|
||||
|
||||
|
||||
@@ -147,6 +149,7 @@ enum {
|
||||
kPROCEDURE,
|
||||
kENDPHONEME,
|
||||
kENDPROCEDURE,
|
||||
kEQUIVALENTS,
|
||||
kPHONEMENUMBER,
|
||||
kPHONEMETABLE,
|
||||
kINCLUDE,
|
||||
@@ -241,6 +244,7 @@ static keywtab_t keywords[] = {
|
||||
{"procedure", tSTATEMENT, kPROCEDURE},
|
||||
{"endphoneme", tSTATEMENT, kENDPHONEME},
|
||||
{"endprocedure", tSTATEMENT, kENDPROCEDURE},
|
||||
{"equivalents", tSTATEMENT, kEQUIVALENTS},
|
||||
{"import_phoneme", tSTATEMENT, kIMPORT_PH},
|
||||
{"stress_type",tSTATEMENT, kSTRESSTYPE},
|
||||
{"starttype", tSTATEMENT, kSTARTTYPE},
|
||||
@@ -290,6 +294,7 @@ static keywtab_t keywords[] = {
|
||||
{"LengthAdd", tINSTRN1, i_ADD_LENGTH},
|
||||
{"Lengthmod", tINSTRN1, i_LENGTH_MOD},
|
||||
{"lengthmod", tINSTRN1, i_LENGTH_MOD},
|
||||
{"ipa", tINSTRN1, i_IPA_NAME},
|
||||
|
||||
// flags
|
||||
{"wavef", tPHONEME_FLAG, phWAVE},
|
||||
@@ -357,6 +362,12 @@ static PHONEME_TAB *phoneme_out;
|
||||
static int n_phcodes_list[N_PHONEME_TABS];
|
||||
static PHONEME_TAB_LIST phoneme_tab_list2[N_PHONEME_TABS];
|
||||
static PHONEME_TAB *phoneme_tab2;
|
||||
static int phoneme_flags;
|
||||
static int place_articulation;
|
||||
|
||||
static char *p_equivalence;
|
||||
static char equivalence_buf[20000];
|
||||
|
||||
|
||||
#define N_PROCS 50
|
||||
int n_procs;
|
||||
@@ -392,6 +403,7 @@ static void DecompilePhoneme(FILE *f_out, PHONEME_TAB *ph, int compile_phoneme)
|
||||
int ix;
|
||||
int any;
|
||||
const char *name;
|
||||
char buf[120];
|
||||
|
||||
static const char *INV = "Invalid";
|
||||
|
||||
@@ -456,6 +468,18 @@ return;
|
||||
fprintf(f_out,"%s",instn0_string[data1]);
|
||||
}
|
||||
else
|
||||
if(type2 == i_IPA_NAME)
|
||||
{
|
||||
for(ix = 0; ix < data1; ix += 2)
|
||||
{
|
||||
instn = *pc++;
|
||||
buf[ix] = instn >> 8;
|
||||
buf[ix+1] = instn & 0xff;
|
||||
}
|
||||
buf[ix] = 0;
|
||||
fprintf(f_out,"ipa %s",buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(f_out,"%s(",KeyToMnem(keywords, tINSTRN1, type2));
|
||||
switch(instn1_paramtype[type2])
|
||||
@@ -823,16 +847,41 @@ static int ph_sorter(char **a, char **b)
|
||||
|
||||
|
||||
|
||||
static void PrintPhonemesUsed(FILE *f, const char *dictname)
|
||||
{//=========================================================
|
||||
static void PrintPhonemesUsed(FILE *f, const char *dsource, const char *dictname)
|
||||
{//==============================================================================
|
||||
int ix;
|
||||
PHONEME_TAB *ph;
|
||||
PHONEME_TAB *ph_tab[N_PHONEME_TAB];
|
||||
int count = 0;
|
||||
int n_ph = 0;
|
||||
int section = 0;
|
||||
time_t mod_time;
|
||||
char fname[sizeof(path_home)+45];
|
||||
struct stat statbuf;
|
||||
char time_string[20];
|
||||
const char *files[] = {"rules","list","listx"};
|
||||
|
||||
fprintf(f,"\n\nDictionary %s_dict\n",dictname);
|
||||
// find the date-stamp of the dictionary source files
|
||||
mod_time = 0;
|
||||
for(ix=0; ix<3; ix++)
|
||||
{
|
||||
sprintf(fname,"%s%s_%s",dsource, dictname, files[ix]);
|
||||
if(stat(fname,&statbuf) == 0)
|
||||
{
|
||||
if(statbuf.st_mtime > mod_time)
|
||||
mod_time = statbuf.st_mtime;
|
||||
}
|
||||
}
|
||||
|
||||
if(mod_time > 0)
|
||||
{
|
||||
strftime(time_string, sizeof(time_string), "%F", localtime(&mod_time));
|
||||
fprintf(f,"\n\nDictionary %s_dict %s\n",dictname, time_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(f,"\n\nDictionary %s_dict\n",dictname);
|
||||
}
|
||||
fflush(f);
|
||||
|
||||
for(ix=0; (ix<N_PHONEME_TAB) && (phoneme_tab[ix] != NULL); ix++)
|
||||
@@ -988,7 +1037,7 @@ static wxString CompileAllDictionaries()
|
||||
{
|
||||
memset(phoneme_tab_flags,0,sizeof(phoneme_tab_flags));
|
||||
FindPhonemesUsed();
|
||||
PrintPhonemesUsed(f_phused,dictname);
|
||||
PrintPhonemesUsed(f_phused, path_dsource, dictname);
|
||||
}
|
||||
|
||||
cont = dir.GetNext(&filename);
|
||||
@@ -2145,7 +2194,29 @@ int CompileSound(int keyword, int isvowel)
|
||||
strcpy(path, item_string);
|
||||
if(item_terminator == ',')
|
||||
{
|
||||
value = NextItemBrackets(tSIGNEDNUMBER,1);
|
||||
if((keyword == kVOWELSTART) || (keyword == kVOWELENDING))
|
||||
{
|
||||
value = NextItemBrackets(tSIGNEDNUMBER,1);
|
||||
if(value > 127)
|
||||
{
|
||||
value = 127;
|
||||
error("Parameter > 127",NULL);
|
||||
}
|
||||
if(value < -128)
|
||||
{
|
||||
value = -128;
|
||||
error("Parameter < -128",NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = NextItemBrackets(tNUMBER,1);
|
||||
if(value > 255)
|
||||
{
|
||||
value = 255;
|
||||
error("Parameter > 255",NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
addr = LoadDataFile(path, isvowel);
|
||||
addr = addr / 4; // addr is words not bytes
|
||||
@@ -2414,6 +2485,23 @@ static int CompileSwitch(int type)
|
||||
|
||||
|
||||
|
||||
static PHONEME_TAB_LIST *FindPhonemeTable(const char *string)
|
||||
{//==========================================================
|
||||
int ix;
|
||||
|
||||
for(ix=0; ix<n_phoneme_tabs; ix++)
|
||||
{
|
||||
if(strcmp(phoneme_tab_list2[ix].name, string) == 0)
|
||||
{
|
||||
return(&phoneme_tab_list2[ix]);
|
||||
}
|
||||
}
|
||||
error("Unknown phoneme table: '%s'",string);
|
||||
return(NULL);
|
||||
} // end of FindPhonemeTable
|
||||
|
||||
|
||||
|
||||
static PHONEME_TAB *FindPhoneme(const char *string)
|
||||
{//================================================
|
||||
PHONEME_TAB_LIST *phtab = NULL;
|
||||
@@ -2422,7 +2510,7 @@ static PHONEME_TAB *FindPhoneme(const char *string)
|
||||
char *phname;
|
||||
char buf[200];
|
||||
|
||||
// is this the name of a phoneme which is ijn scope
|
||||
// is this the name of a phoneme which is in scope
|
||||
if((strlen(string) <= 4) && ((ix = LookupPhoneme(string,0)) != -1))
|
||||
{
|
||||
return(&phoneme_tab2[ix]);
|
||||
@@ -2435,17 +2523,9 @@ static PHONEME_TAB *FindPhoneme(const char *string)
|
||||
*phname++ = 0;
|
||||
}
|
||||
|
||||
for(ix=0; ix<n_phoneme_tabs; ix++)
|
||||
{
|
||||
if(strcmp(phoneme_tab_list2[ix].name,buf) == 0)
|
||||
{
|
||||
phtab = &phoneme_tab_list2[ix];
|
||||
break;
|
||||
}
|
||||
}
|
||||
phtab = FindPhonemeTable(buf);
|
||||
if(phtab == NULL)
|
||||
{
|
||||
error("Unknown phoneme table: '%s'",buf);
|
||||
return(NULL); // phoneme table not found
|
||||
}
|
||||
|
||||
@@ -2510,6 +2590,18 @@ static void CallPhoneme(void)
|
||||
if((ph = FindPhoneme(item_string)) == NULL)
|
||||
return;
|
||||
addr = ph->program;
|
||||
|
||||
if(phoneme_out->type == phINVALID)
|
||||
{
|
||||
// Phoneme type has not been set. Copy it from the called phoneme
|
||||
phoneme_out->type = ph->type;
|
||||
phoneme_flags = ph->phflags & ~phARTICULATION;
|
||||
place_articulation = (ph->phflags & phARTICULATION) >> 16;
|
||||
phoneme_out->start_type = ph->start_type;
|
||||
phoneme_out->end_type = ph->end_type;
|
||||
phoneme_out->std_length = ph->std_length;
|
||||
phoneme_out->length_mod = ph->length_mod;
|
||||
}
|
||||
}
|
||||
|
||||
*prog_out++ = i_CALLPH + (addr >> 16);
|
||||
@@ -2536,11 +2628,14 @@ static void InstnPlusPhoneme(int instn)
|
||||
int CompilePhoneme(int compile_phoneme)
|
||||
{//====================================
|
||||
int endphoneme = 0;
|
||||
int phoneme_flags = 0;
|
||||
int place_articulation = 0;
|
||||
int keyword;
|
||||
int value;
|
||||
int phcode = 0;
|
||||
int ix;
|
||||
unsigned int c;
|
||||
char *p;
|
||||
char number_buf[12];
|
||||
char ipa_buf[N_ITEM_STRING];
|
||||
PHONEME_TAB phoneme_out2;
|
||||
PHONEME_PROG_LOG phoneme_prog_log;
|
||||
|
||||
@@ -2548,6 +2643,8 @@ int CompilePhoneme(int compile_phoneme)
|
||||
if_level = 0;
|
||||
if_stack[0].returned = 0;
|
||||
after_if = 0;
|
||||
phoneme_flags = 0;
|
||||
place_articulation = 0;
|
||||
|
||||
NextItem(tSTRING);
|
||||
if(compile_phoneme)
|
||||
@@ -2657,6 +2754,42 @@ int CompilePhoneme(int compile_phoneme)
|
||||
value = NextItem(tNUMBER);
|
||||
phoneme_out->length_mod = value;
|
||||
break;
|
||||
|
||||
case i_IPA_NAME:
|
||||
NextItem(tSTRING);
|
||||
|
||||
if(strcmp(item_string,"NULL")==0)
|
||||
strcpy(item_string," ");
|
||||
|
||||
// copy the string, recognize characters in the form U+9999
|
||||
p = item_string;
|
||||
ix = 0;
|
||||
while((c = *p++) != 0)
|
||||
{
|
||||
if((c=='U') && (p[0]=='+'))
|
||||
{
|
||||
// U+9999
|
||||
memcpy(number_buf,&p[1],4); // U+ should be followed by 4 hex digits
|
||||
number_buf[4] = 0;
|
||||
c = 0;
|
||||
sscanf(number_buf,"%x",&c);
|
||||
p += 5;
|
||||
ix += utf8_out(c, &ipa_buf[ix]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipa_buf[ix++] = c;
|
||||
}
|
||||
}
|
||||
ipa_buf[ix] = 0;
|
||||
value = strlen(ipa_buf); // 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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2702,6 +2835,11 @@ int CompilePhoneme(int compile_phoneme)
|
||||
case kSTRESSTYPE:
|
||||
value = NextItem(tNUMBER);
|
||||
phoneme_out->std_length = value;
|
||||
if(prog_out > prog_buf)
|
||||
{
|
||||
error("stress phonemes can't contain program instructions",NULL);
|
||||
prog_out = prog_buf;
|
||||
}
|
||||
break;
|
||||
|
||||
case kIF:
|
||||
@@ -2902,6 +3040,7 @@ static void WritePhonemeTables()
|
||||
fputc(phoneme_tab_list2[ix].includes,f_phtab);
|
||||
fputc(0,f_phtab);
|
||||
fputc(0,f_phtab);
|
||||
Write4Bytes(f_phtab, phoneme_tab_list2[ix].equivalence_tables); // byte index into phondata for equivalence tables
|
||||
|
||||
fwrite(phoneme_tab_list2[ix].name,1,N_PHONEME_TAB_NAME,f_phtab);
|
||||
|
||||
@@ -2924,6 +3063,8 @@ static void WritePhonemeTables()
|
||||
static void EndPhonemeTable()
|
||||
{//==========================
|
||||
int ix;
|
||||
int *pw;
|
||||
int length;
|
||||
|
||||
if(n_phoneme_tabs == 0)
|
||||
return;
|
||||
@@ -2938,10 +3079,24 @@ static void EndPhonemeTable()
|
||||
fprintf(f_errors,"%3d: Phoneme [%s] not declared, referenced at line %d\n",linenum,
|
||||
WordToString(phoneme_tab2[ix].mnemonic),int(phoneme_tab2[ix].program));
|
||||
error_count++;
|
||||
phoneme_tab2[ix].type = 0; // prevent the error message repeating
|
||||
}
|
||||
}
|
||||
|
||||
n_phcodes_list[n_phoneme_tabs-1] = n_phcodes;
|
||||
|
||||
if((length = p_equivalence - equivalence_buf) > 0)
|
||||
{
|
||||
// terminate the list of phoneme equivalence tables
|
||||
pw = (int *)p_equivalence;
|
||||
pw[0] = 0;
|
||||
|
||||
// write the equivalence data into phondata, and remember it's address
|
||||
ix = ftell(f_phdata);
|
||||
fprintf(f_phcontents,"Q 0x%.5x %s\n", ix, phoneme_tab_list2[n_phoneme_tabs-1].name);
|
||||
phoneme_tab_list2[n_phoneme_tabs-1].equivalence_tables = ix;
|
||||
fwrite(equivalence_buf, length+4, 1, f_phdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2969,11 +3124,12 @@ static void StartPhonemeTable(const char *name)
|
||||
if(gui_flag)
|
||||
progress->Update(n_phoneme_tabs);
|
||||
|
||||
memset(&phoneme_tab_list2[n_phoneme_tabs], 0, sizeof(PHONEME_TAB_LIST));
|
||||
phoneme_tab_list2[n_phoneme_tabs].phoneme_tab_ptr = phoneme_tab2 = p;
|
||||
memset(phoneme_tab_list2[n_phoneme_tabs].name, 0, N_PHONEME_TAB_NAME);
|
||||
strncpy0(phoneme_tab_list2[n_phoneme_tabs].name, name, N_PHONEME_TAB_NAME);
|
||||
n_phcodes = 1;
|
||||
phoneme_tab_list2[n_phoneme_tabs].includes = 0;
|
||||
p_equivalence = equivalence_buf;
|
||||
|
||||
if(n_phoneme_tabs > 0)
|
||||
{
|
||||
@@ -3008,6 +3164,111 @@ static void StartPhonemeTable(const char *name)
|
||||
} // end of StartPhonemeTable
|
||||
|
||||
|
||||
static void CompileEquivalents()
|
||||
{//=============================
|
||||
// a list of phonemes in another language and the equivalent phoneme strings in this language
|
||||
|
||||
int ix;
|
||||
int n_names;
|
||||
int n_bytes;
|
||||
int foreign_phoneme;
|
||||
int foreign_error = 0;
|
||||
int remove_stress = 0;
|
||||
char *p_start;
|
||||
char *p;
|
||||
int foreign_table;
|
||||
char foreign_table_name[40];
|
||||
char line_buf[80];
|
||||
char names[6][80];
|
||||
char phcode[7];
|
||||
char save_voice_name[80];
|
||||
|
||||
NextItem(tSTRING);
|
||||
strcpy(foreign_table_name, item_string);
|
||||
strcpy(save_voice_name,voice_name2);
|
||||
|
||||
if((foreign_table = SelectPhonemeTableName(foreign_table_name)) < 0)
|
||||
{
|
||||
error("Unknown phoneme table '%s'", foreign_table_name);
|
||||
foreign_error = 1;
|
||||
foreign_phoneme = 0;
|
||||
}
|
||||
|
||||
p_start = p_equivalence;
|
||||
p_equivalence += 8;
|
||||
|
||||
p_start[0] = foreign_table;
|
||||
|
||||
linenum--;
|
||||
while(!feof(f_in))
|
||||
{
|
||||
linenum++;
|
||||
if(fgets(line_buf, sizeof(line_buf), f_in) == NULL)
|
||||
break;
|
||||
|
||||
if((p = strstr(line_buf,"//")) != NULL)
|
||||
*p = 0;
|
||||
|
||||
for(ix=0; ix<6; ix++)
|
||||
names[ix][0] = 0;
|
||||
n_names = sscanf(line_buf,"%s %s %s %s %s %s",names[0],names[1],names[2],names[3],names[4],names[5]);
|
||||
if(n_names < 1)
|
||||
continue;
|
||||
|
||||
if(strcmp(names[0],"endphoneme") == 0)
|
||||
break;
|
||||
|
||||
if(strcmp(names[0],"remove_stress") == 0)
|
||||
{
|
||||
remove_stress = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(p_equivalence > &equivalence_buf[sizeof(equivalence_buf) - 16])
|
||||
{
|
||||
error("'equivalents' tables are too large",NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
if(foreign_error == 0)
|
||||
{
|
||||
phcode[0] = foreign_phoneme = LookupPhonemeString(names[0]);
|
||||
if(foreign_phoneme == 0)
|
||||
{
|
||||
sprintf(line_buf,"%s/%s", foreign_table_name, names[0]);
|
||||
error("Unknown phoneme '%s'", line_buf);
|
||||
}
|
||||
}
|
||||
|
||||
for(ix=1; ix<n_names; ix++)
|
||||
{
|
||||
phcode[ix] = LookupPhoneme(names[ix], 1);
|
||||
}
|
||||
|
||||
// only write a translation if it has an effect
|
||||
if((n_names > 2) || (phcode[0] != phcode[1]))
|
||||
{
|
||||
// write: foreign phoneme number, then a string of local phoneme numbers
|
||||
memcpy(p_equivalence, phcode, n_names);
|
||||
p_equivalence += n_names;
|
||||
*p_equivalence++ = 0;
|
||||
}
|
||||
}
|
||||
*p_equivalence++ = 0;
|
||||
|
||||
p_equivalence = (char *)((int)(p_equivalence + 3) & ~0x3); // align to word boundary
|
||||
n_bytes = p_equivalence - p_start;
|
||||
p_start[1] = remove_stress;
|
||||
n_bytes = n_bytes / 4;
|
||||
p_start[2] = n_bytes >> 8; // index of next table
|
||||
p_start[3] = n_bytes;
|
||||
|
||||
LoadVoice(voice_name2,0); // reset the original phoneme table
|
||||
LoadVoiceVariant(save_voice_name,0);
|
||||
} // end of CompileEquivalents
|
||||
|
||||
|
||||
|
||||
static void CompilePhonemeFiles()
|
||||
{//==============================
|
||||
int item;
|
||||
@@ -3038,8 +3299,9 @@ static void CompilePhonemeFiles()
|
||||
|
||||
item = NextItem(tKEYWORD);
|
||||
|
||||
if(item == kINCLUDE)
|
||||
switch(item)
|
||||
{
|
||||
case kINCLUDE:
|
||||
NextItem(tSTRING);
|
||||
sprintf(buf,"%s%s",path_source,item_string);
|
||||
if((stack_ix < N_STACK) && (f = fopen_log(f_errors,buf,"rb")) != NULL)
|
||||
@@ -3053,32 +3315,36 @@ static void CompilePhonemeFiles()
|
||||
strncpy0(current_fname,item_string,sizeof(current_fname));
|
||||
linenum = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(item == kPHONEMETABLE)
|
||||
{
|
||||
break;
|
||||
|
||||
case kPHONEMETABLE:
|
||||
EndPhonemeTable();
|
||||
NextItem(tSTRING); // name of the new phoneme table
|
||||
StartPhonemeTable(item_string);
|
||||
}
|
||||
else
|
||||
if(item == kPHONEMESTART)
|
||||
{
|
||||
break;
|
||||
|
||||
case kPHONEMESTART:
|
||||
if(n_phoneme_tabs == 0)
|
||||
{
|
||||
Error("phonemetable is missing");
|
||||
return;
|
||||
}
|
||||
CompilePhoneme(1);
|
||||
}
|
||||
else
|
||||
if(item == kPROCEDURE)
|
||||
{
|
||||
break;
|
||||
|
||||
case kPROCEDURE:
|
||||
CompilePhoneme(0);
|
||||
break;
|
||||
|
||||
case kEQUIVALENTS:
|
||||
CompileEquivalents();
|
||||
break;
|
||||
|
||||
default:
|
||||
if(!feof(f_in))
|
||||
Error("Keyword 'phoneme' expected");
|
||||
break;
|
||||
}
|
||||
else
|
||||
if(!feof(f_in))
|
||||
Error("Keyword 'phoneme' expected");
|
||||
}
|
||||
phoneme_tab2[n_phcodes+1].mnemonic = 0; // terminator
|
||||
} // end of CompilePhonemeFiles
|
||||
@@ -3152,6 +3418,7 @@ memset(markers_used,0,sizeof(markers_used));
|
||||
"# S - A SPECT_SEQ structure\n"
|
||||
"# W - A wavefile segment\n"
|
||||
"# E - An envelope\n"
|
||||
"# Q - Phoneme equivalence tables\n"
|
||||
"#\n"
|
||||
"# Address is the displacement within phondata of this item\n"
|
||||
"#\n"
|
||||
|
||||
+15
-7
@@ -53,6 +53,7 @@ static char *hash_chains[N_HASH_DICT];
|
||||
static char letterGroupsDefined[N_LETTER_GROUPS];
|
||||
|
||||
MNEM_TAB mnem_rules[] = {
|
||||
{"unpr", 0x01},
|
||||
{"w_alt2", 0x12},
|
||||
{"w_alt3", 0x13},
|
||||
{"w_alt", 0x11}, // note: put longer names before their sub-strings
|
||||
@@ -192,8 +193,8 @@ char *print_dictionary_flags(unsigned int *flags)
|
||||
|
||||
|
||||
|
||||
char *DecodeRule(const char *group_chars, int group_length, char *rule)
|
||||
{//====================================================================
|
||||
char *DecodeRule(const char *group_chars, int group_length, char *rule, int control)
|
||||
{//=================================================================================
|
||||
/* Convert compiled match template to ascii */
|
||||
|
||||
unsigned char rb;
|
||||
@@ -268,16 +269,20 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule)
|
||||
|
||||
if(rb == RULE_DOLLAR)
|
||||
{
|
||||
p[0] = '$';
|
||||
name = LookupMnemName(mnem_rules, *rule++);
|
||||
strcpy(&p[1],name);
|
||||
p += (strlen(name)+1);
|
||||
value = *rule++ & 0xff;
|
||||
if((value != 0x01) || (control & FLAG_UNPRON_TEST))
|
||||
{
|
||||
p[0] = '$';
|
||||
name = LookupMnemName(mnem_rules, value);
|
||||
strcpy(&p[1],name);
|
||||
p += (strlen(name)+1);
|
||||
}
|
||||
c = ' ';
|
||||
}
|
||||
else
|
||||
if(rb == RULE_ENDING)
|
||||
{
|
||||
static const char *flag_chars = "ei vtfq t";
|
||||
static const char *flag_chars = "eipvdfq tba ";
|
||||
flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f);
|
||||
suffix_char = 'S';
|
||||
if(flags & (SUFX_P >> 8))
|
||||
@@ -1118,6 +1123,9 @@ static void copy_rule_string(char *string, int &state)
|
||||
case 'b':
|
||||
sxflags |= SUFX_B;
|
||||
break;
|
||||
case 'a':
|
||||
sxflags |= SUFX_A;
|
||||
break;
|
||||
default:
|
||||
if(isdigit(c))
|
||||
value = (value*10) + (c - '0');
|
||||
|
||||
+206
-166
@@ -38,15 +38,16 @@ int dictionary_skipwords;
|
||||
char dictionary_name[40];
|
||||
|
||||
extern char *print_dictionary_flags(unsigned int *flags);
|
||||
extern char *DecodeRule(const char *group_chars, int group_length, char *rule);
|
||||
extern char *DecodeRule(const char *group_chars, int group_length, char *rule, int control);
|
||||
|
||||
// accented characters which indicate (in some languages) the start of a separate syllable
|
||||
//static const unsigned short diereses_list[7] = {L'ä',L'ë',L'ï',L'ö',L'ü',L'ÿ',0};
|
||||
static const unsigned short diereses_list[7] = {0xe4,0xeb,0xef,0xf6,0xfc,0xff,0};
|
||||
|
||||
// convert characters to an approximate 7 bit ascii equivalent
|
||||
// used for checking for vowels
|
||||
static unsigned char remove_accent[] = {
|
||||
// used for checking for vowels (up to 0x259=schwa)
|
||||
#define N_REMOVE_ACCENT 0x25e
|
||||
static unsigned char remove_accent[N_REMOVE_ACCENT] = {
|
||||
'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0c0
|
||||
'd','n','o','o','o','o','o', 0, 'o','u','u','u','u','y','t','s', // 0d0
|
||||
'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0e0
|
||||
@@ -73,7 +74,9 @@ static unsigned char remove_accent[] = {
|
||||
'r','r','r','r','u','u','u','u','s','s','t','t','y','y','h','h', // 210
|
||||
'n','d','o','o','z','z','a','a','e','e','o','o','o','o','o','o', // 220
|
||||
'o','o','y','y','l','n','t','j','d','q','a','c','c','l','t','s', // 230
|
||||
'z', 0 };
|
||||
'z', 0, 0, 'b','u','v','e','e','j','j','q','q','r','r','y','y', // 240
|
||||
'a','a','a','b','o','c','d','d','e','e','e','e','e','e' };
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -86,8 +89,8 @@ void strncpy0(char *to,const char *from, int size)
|
||||
}
|
||||
|
||||
|
||||
static int reverse_word_bytes(int word)
|
||||
{//=============================
|
||||
int Reverse4Bytes(int word)
|
||||
{//========================
|
||||
// reverse the order of bytes from little-endian to big-endian
|
||||
#ifdef ARCH_BIG
|
||||
int ix;
|
||||
@@ -170,9 +173,9 @@ static void InitGroups(Translator *tr)
|
||||
pw = (unsigned int *)(tr->langopts.replace_chars);
|
||||
while(*pw != 0)
|
||||
{
|
||||
*pw = reverse_word_bytes(*pw);
|
||||
*pw = Reverse4Bytes(*pw);
|
||||
pw++;
|
||||
*pw = reverse_word_bytes(*pw);
|
||||
*pw = Reverse4Bytes(*pw);
|
||||
pw++;
|
||||
}
|
||||
#endif
|
||||
@@ -245,6 +248,7 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
|
||||
char fname[sizeof(path_home)+20];
|
||||
|
||||
strcpy(dictionary_name,name); // currently loaded dictionary name
|
||||
strcpy(tr->dictionary_name, name);
|
||||
|
||||
// Load a pronunciation data file into memory
|
||||
// bytes 0-3: offset to rules data
|
||||
@@ -274,7 +278,7 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
|
||||
|
||||
|
||||
pw = (int *)(tr->data_dictlist);
|
||||
length = reverse_word_bytes(pw[1]);
|
||||
length = Reverse4Bytes(pw[1]);
|
||||
|
||||
if(size <= (N_HASH_DICT + sizeof(int)*2))
|
||||
{
|
||||
@@ -282,10 +286,10 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
|
||||
return(2);
|
||||
}
|
||||
|
||||
if((reverse_word_bytes(pw[0]) != N_HASH_DICT) ||
|
||||
if((Reverse4Bytes(pw[0]) != N_HASH_DICT) ||
|
||||
(length <= 0) || (length > 0x8000000))
|
||||
{
|
||||
fprintf(stderr,"Bad data: '%s' (%x length=%x)\n",fname,reverse_word_bytes(pw[0]),length);
|
||||
fprintf(stderr,"Bad data: '%s' (%x length=%x)\n",fname,Reverse4Bytes(pw[0]),length);
|
||||
return(2);
|
||||
}
|
||||
tr->data_dictrules = &(tr->data_dictlist[length]);
|
||||
@@ -506,20 +510,84 @@ void DecodePhonemes(const char *inptr, char *outptr)
|
||||
} // end of DecodePhonemes
|
||||
|
||||
|
||||
// using Kirschenbaum to IPA translation, ascii 0x20 to 0x7f
|
||||
unsigned short ipa1[96] = {
|
||||
0x20,0x21,0x22,0x2b0,0x24,0x25,0x0e6,0x2c8,0x28,0x27e,0x2a,0x2b,0x2cc,0x2d,0x2e,0x2f,
|
||||
0x252,0x31,0x32,0x25c,0x34,0x35,0x36,0x37,0x275,0x39,0x2d0,0x2b2,0x3c,0x3d,0x3e,0x294,
|
||||
0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x4c,0x271,0x14b,0x254,
|
||||
0x3a6,0x263,0x280,0x283,0x3b8,0x28a,0x28c,0x153,0x3c7,0xf8,0x292,0x32a,0x5c,0x5d,0x5e,0x5f,
|
||||
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
|
||||
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x303,0x7f
|
||||
};
|
||||
|
||||
static void WriteMnemonic(char *phon_out, int *ix, int mnem)
|
||||
{//=========================================================
|
||||
unsigned char c;
|
||||
|
||||
while((c = mnem & 0xff) != 0)
|
||||
static void WritePhMnemonic(char *phon_out, int *ix, PHONEME_TAB *ph, PHONEME_LIST *plist)
|
||||
{//=======================================================================================
|
||||
int c;
|
||||
int mnem;
|
||||
int len;
|
||||
int first;
|
||||
unsigned int ipa_control=0; // first byte of ipa string may control the phoneme name interpretation. 0x20 = ignore this phoneme
|
||||
PHONEME_DATA phdata;
|
||||
|
||||
if(option_phonemes == 3)
|
||||
{
|
||||
// has an ipa name been defined for this phoneme ?
|
||||
phdata.ipa_string[0] = 0;
|
||||
|
||||
if(plist == NULL)
|
||||
{
|
||||
InterpretPhoneme2(ph->code, &phdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
InterpretPhoneme(NULL, 0, plist, &phdata);
|
||||
}
|
||||
|
||||
len = strlen(phdata.ipa_string);
|
||||
if(len > 0)
|
||||
{
|
||||
if((ipa_control = phdata.ipa_string[0]) > 0x20)
|
||||
{
|
||||
strcpy(&phon_out[*ix], phdata.ipa_string);
|
||||
*ix += len;
|
||||
}
|
||||
if(ipa_control >= 0x20)
|
||||
return; // 0x20 = ignore phoneme
|
||||
}
|
||||
}
|
||||
|
||||
first = 1;
|
||||
for(mnem = ph->mnemonic; (c = mnem & 0xff) != 0; mnem = mnem >> 8)
|
||||
{
|
||||
if((c == '/') && (option_phoneme_variants==0))
|
||||
break; // discard phoneme variant indicator
|
||||
phon_out[(*ix)++]= c;
|
||||
// phon_out[phon_out_ix++]= ipa1[c];
|
||||
mnem = mnem >> 8;
|
||||
|
||||
if(option_phonemes == 3)
|
||||
{
|
||||
// convert from ascii to ipa
|
||||
if(first && (c == '_'))
|
||||
break; // don't show pause phonemes
|
||||
|
||||
if((c == '#') && (ph->type == phVOWEL))
|
||||
break; // # is subscript-h, but only for consonants
|
||||
|
||||
// ignore digits after the first character
|
||||
if(!first && isdigit(c))
|
||||
continue;
|
||||
|
||||
if((c >= 0x20) && (c < 128))
|
||||
c = ipa1[c-0x20];
|
||||
|
||||
*ix += utf8_out(c, &phon_out[*ix]);
|
||||
}
|
||||
else
|
||||
{
|
||||
phon_out[(*ix)++]= c;
|
||||
}
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
} // end of WritePhMnemonic
|
||||
|
||||
|
||||
|
||||
@@ -532,6 +600,7 @@ void GetTranslatedPhonemeString(char *phon_out, int n_phon_out)
|
||||
int ix;
|
||||
int phon_out_ix=0;
|
||||
int stress;
|
||||
unsigned int c;
|
||||
char *p;
|
||||
PHONEME_LIST *plist;
|
||||
|
||||
@@ -549,35 +618,52 @@ void GetTranslatedPhonemeString(char *phon_out, int n_phon_out)
|
||||
{
|
||||
if((stress = plist->stresslevel) > 1)
|
||||
{
|
||||
c = 0;
|
||||
if(stress > 5) stress = 5;
|
||||
phon_out[phon_out_ix++] = stress_chars[stress];
|
||||
|
||||
if(option_phonemes == 3)
|
||||
{
|
||||
c = 0x2cc; // ipa, secondary stress
|
||||
if(stress > 3)
|
||||
c = 0x02c8; // ipa, primary stress
|
||||
}
|
||||
else
|
||||
{
|
||||
c = stress_chars[stress];
|
||||
}
|
||||
|
||||
if(c != 0)
|
||||
{
|
||||
phon_out_ix += utf8_out(c, &phon_out[phon_out_ix]);
|
||||
}
|
||||
}
|
||||
}
|
||||
WriteMnemonic(phon_out, &phon_out_ix, plist->ph->mnemonic);
|
||||
|
||||
if(plist->synthflags & SFLAG_LENGTHEN)
|
||||
{
|
||||
WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonLENGTHEN]->mnemonic);
|
||||
}
|
||||
if((plist->synthflags & SFLAG_SYLLABLE) && (plist->type != phVOWEL))
|
||||
{
|
||||
// syllablic consonant
|
||||
WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonSYLLABIC]->mnemonic);
|
||||
}
|
||||
if(plist->ph->code == phonSWITCH)
|
||||
{
|
||||
// the tone_ph field contains a phoneme table number
|
||||
p = phoneme_tab_list[plist->tone_ph].name;
|
||||
while(*p != 0)
|
||||
{
|
||||
phon_out[phon_out_ix++] = *p++;
|
||||
}
|
||||
phon_out[phon_out_ix++] = ' ';
|
||||
|
||||
sprintf(&phon_out[phon_out_ix], "(%s)", p);
|
||||
phon_out_ix += (strlen(p) + 2);
|
||||
}
|
||||
else
|
||||
if(plist->tone_ph > 0)
|
||||
{
|
||||
WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[plist->tone_ph]->mnemonic);
|
||||
WritePhMnemonic(phon_out, &phon_out_ix, plist->ph, plist);
|
||||
|
||||
if(plist->synthflags & SFLAG_LENGTHEN)
|
||||
{
|
||||
WritePhMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonLENGTHEN], NULL);
|
||||
}
|
||||
if((plist->synthflags & SFLAG_SYLLABLE) && (plist->type != phVOWEL))
|
||||
{
|
||||
// syllablic consonant
|
||||
WritePhMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonSYLLABIC], NULL);
|
||||
}
|
||||
if(plist->tone_ph > 0)
|
||||
{
|
||||
WritePhMnemonic(phon_out, &phon_out_ix, phoneme_tab[plist->tone_ph], NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,7 +745,7 @@ static int IsLetter(Translator *tr, int letter, int group)
|
||||
}
|
||||
else
|
||||
{
|
||||
if((letter >= 0xc0) && (letter <= 0x241))
|
||||
if((letter >= 0xc0) && (letter < N_REMOVE_ACCENT))
|
||||
return(tr->letter_bits[remove_accent[letter-0xc0]] & (1L << group));
|
||||
}
|
||||
|
||||
@@ -670,107 +756,31 @@ static int IsLetter(Translator *tr, int letter, int group)
|
||||
}
|
||||
|
||||
|
||||
static int IsVowel(Translator *tr, int letter)
|
||||
{//===========================================
|
||||
return(IsLetter(tr, letter, 0));
|
||||
int IsVowel(Translator *tr, int letter)
|
||||
{//====================================
|
||||
return(IsLetter(tr, letter, LETTERGP_VOWEL2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int Unpronouncable_en(Translator *tr, char *word)
|
||||
{//=====================================================
|
||||
/* Determines whether a word in 'unpronouncable', i.e. whether it should
|
||||
be spoken as individual letters.
|
||||
|
||||
This function is language specific.
|
||||
*/
|
||||
|
||||
static int Unpronouncable2(Translator *tr, char *word)
|
||||
{//===================================================
|
||||
int c;
|
||||
int vowel_posn=9;
|
||||
int index;
|
||||
int count;
|
||||
int ix;
|
||||
int apostrophe=0;
|
||||
int end_flags;
|
||||
char ph_buf[N_WORD_PHONEMES];
|
||||
|
||||
static unsigned char initials_bitmap[86] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x22, 0x08, 0x00, 0x88, // 0
|
||||
0x20, 0x24, 0x20, 0x80, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x28, 0x08, 0x00, 0x88, 0x22, 0x04, 0x00, // 16
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x88, 0x22, 0x04, 0x00, 0x02, 0x00, 0x04, // 32
|
||||
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x28, 0x8a, 0x03, 0x00, 0x00, 0x40, 0x00, // 48
|
||||
0x02, 0x00, 0x41, 0xca, 0xbb, 0x06, 0x20, 0x80,
|
||||
0x91, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, // 64
|
||||
0x08, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x22, 0x00, 0x01, 0x00, };
|
||||
|
||||
|
||||
// words which we pass through to the dictionary, even though they look unpronouncable
|
||||
static const char *exceptions[] = {
|
||||
"'s ", "st ","nd ","rd ","th ",NULL };
|
||||
|
||||
if((*word == ' ') || (*word == 0))
|
||||
return(0);
|
||||
|
||||
for(ix=0; exceptions[ix] != NULL; ix++)
|
||||
{
|
||||
// Seemingly uncpronouncable words, but to be looked in the dictionary rules instead
|
||||
if(memcmp(word,exceptions[ix],3)==0)
|
||||
return(0);
|
||||
}
|
||||
|
||||
index=0;
|
||||
count=0;
|
||||
for(;;)
|
||||
{
|
||||
index += utf8_in(&c,&word[index]);
|
||||
count++;
|
||||
|
||||
if((c==0) || (c==' '))
|
||||
break;
|
||||
|
||||
if(IsVowel(tr, c) || (c == 'y'))
|
||||
{
|
||||
vowel_posn = count;
|
||||
break;
|
||||
}
|
||||
|
||||
if(c == '\'')
|
||||
apostrophe = 1;
|
||||
else
|
||||
if(!IsAlpha(c))
|
||||
return(0); // letter (not vowel) outside Latin character range or apostrophe, abort test
|
||||
}
|
||||
if((vowel_posn > 5) || ((word[0]!='s') && (vowel_posn > 4)))
|
||||
return(1); // no vowel, or no vowel in first four letters
|
||||
|
||||
/* there is at least one vowel, is the initial letter combination valid ? */
|
||||
|
||||
if(vowel_posn < 3)
|
||||
return(0); /* vowel in first two letters, OK */
|
||||
|
||||
if(apostrophe)
|
||||
return(0); // first two letters not a-z, abort test
|
||||
|
||||
index = (word[0]-'a') * 26 + (word[1]-'a');
|
||||
if(initials_bitmap[index >> 3] & (1L << (index & 7)))
|
||||
return(0);
|
||||
else
|
||||
return(1); /****/
|
||||
} /* end of Unpronounceable */
|
||||
|
||||
|
||||
static int Unpronouncable_de(Translator *tr, char *word)
|
||||
{//=====================================================
|
||||
if(memcmp(word,"tsch",4)==0)
|
||||
return(0);
|
||||
return(2);
|
||||
ph_buf[0] = 0;
|
||||
c = word[-1];
|
||||
word[-1] = ' '; // ensure there is a space before the "word"
|
||||
end_flags = TranslateRules(tr, word, ph_buf, sizeof(ph_buf), NULL, FLAG_UNPRON_TEST, NULL);
|
||||
word[-1] = c;
|
||||
if((end_flags == 0) || (end_flags & SUFX_UNPRON))
|
||||
return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Unpronouncable(Translator *tr, char *word)
|
||||
{//===========================================
|
||||
/* Determines whether a word in 'unpronouncable', i.e. whether it should
|
||||
@@ -785,18 +795,6 @@ int Unpronouncable(Translator *tr, char *word)
|
||||
int index;
|
||||
int count;
|
||||
int apostrophe=0;
|
||||
int result=2; // unknown
|
||||
|
||||
if(tr->translator_name == L('e','n'))
|
||||
{
|
||||
return(Unpronouncable_en(tr,word));
|
||||
}
|
||||
if(tr->translator_name == L('d','e'))
|
||||
{
|
||||
result = Unpronouncable_de(tr,word);
|
||||
}
|
||||
if(result < 2)
|
||||
return(result);
|
||||
|
||||
utf8_in(&c,word);
|
||||
if((tr->letter_bits_offset > 0) && (c < 0x241))
|
||||
@@ -808,7 +806,7 @@ int Unpronouncable(Translator *tr, char *word)
|
||||
if(tr->langopts.param[LOPT_UNPRONOUNCABLE] == 1)
|
||||
return(0);
|
||||
|
||||
if((*word == ' ') || (*word == 0))
|
||||
if(((c = *word) == ' ') || (c == 0) || (c == '\''))
|
||||
return(0);
|
||||
|
||||
index = 0;
|
||||
@@ -819,6 +817,9 @@ int Unpronouncable(Translator *tr, char *word)
|
||||
if((c==0) || (c==' '))
|
||||
break;
|
||||
|
||||
if((c=='\'') && (count > 1))
|
||||
break; // "tv'" but not "l'"
|
||||
|
||||
if(count==0)
|
||||
c1 = c;
|
||||
count++;
|
||||
@@ -833,17 +834,20 @@ int Unpronouncable(Translator *tr, char *word)
|
||||
apostrophe = 1;
|
||||
else
|
||||
if(!iswalpha(c))
|
||||
return(0); // letter (not vowel) outside a-z range or apostrophe, abort test
|
||||
return(0);
|
||||
}
|
||||
|
||||
if((vowel_posn < 9) && (tr->langopts.param[LOPT_UNPRONOUNCABLE] == 2))
|
||||
return(0); // option means allow any word with a vowel
|
||||
if((vowel_posn > 2) && (tr->langopts.param[LOPT_UNPRONOUNCABLE] == 2))
|
||||
{
|
||||
// Lookup unpronounable rules in *_rules
|
||||
return(Unpronouncable2(tr, word));
|
||||
}
|
||||
|
||||
if(c1 == tr->langopts.param[LOPT_UNPRONOUNCABLE])
|
||||
vowel_posn--; // disregard this as the initial letter when counting
|
||||
|
||||
if(vowel_posn > (tr->langopts.max_initial_consonants+1))
|
||||
return(1); // no vowel, or no vowel in first four letters
|
||||
return(1); // no vowel, or no vowel in first few letters
|
||||
|
||||
return(0);
|
||||
|
||||
@@ -1049,17 +1053,19 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress)
|
||||
|
||||
|
||||
|
||||
void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress)
|
||||
{//=========================================================================================================
|
||||
void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int control)
|
||||
{//=====================================================================================================
|
||||
/* Guess stress pattern of word. This is language specific
|
||||
|
||||
'output' is used for input and output
|
||||
|
||||
'dictionary_flags' has bits 0-3 position of stressed vowel (if > 0)
|
||||
or unstressed (if == 7) or syllables 1 and 2 (if == 6)
|
||||
bits 8... dictionary flags
|
||||
|
||||
If 'tonic' is set (>= 0), replace highest stress by this value.
|
||||
|
||||
Parameter used for input and output
|
||||
control: bit 0 This is an individual symbol, not a word
|
||||
*/
|
||||
|
||||
unsigned char phcode;
|
||||
@@ -1083,6 +1089,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
int opt_length;
|
||||
int done;
|
||||
int stressflags;
|
||||
int dflags = 0;
|
||||
|
||||
signed char vowel_stress[N_WORD_PHONEMES/2];
|
||||
char syllable_weight[N_WORD_PHONEMES/2];
|
||||
@@ -1101,6 +1108,9 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
|
||||
stressflags = tr->langopts.stress_flags;
|
||||
|
||||
if(dictionary_flags != NULL)
|
||||
dflags = dictionary_flags[0];
|
||||
|
||||
/* copy input string into internal buffer */
|
||||
for(ix=0; ix<N_WORD_PHONEMES; ix++)
|
||||
{
|
||||
@@ -1118,16 +1128,16 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
max_output = output + (N_WORD_PHONEMES-3); /* check for overrun */
|
||||
|
||||
// any stress position marked in the xx_list dictionary ?
|
||||
stressed_syllable = dictionary_flags[0] & 0x7;
|
||||
if(dictionary_flags[0] & 0x8)
|
||||
stressed_syllable = dflags & 0x7;
|
||||
if(dflags & 0x8)
|
||||
{
|
||||
// this indicates a word without a primary stress
|
||||
stressed_syllable = dictionary_flags[0] & 0x3;
|
||||
stressed_syllable = dflags & 0x3;
|
||||
unstressed_word = 1;
|
||||
}
|
||||
|
||||
max_stress = GetVowelStress(tr, phonetic, vowel_stress, vowel_count, stressed_syllable, 1);
|
||||
if(max_stress < 0)
|
||||
if((max_stress < 0) && dictionary_flags)
|
||||
{
|
||||
if((tr->langopts.stress_flags & 1) && (vowel_count == 2))
|
||||
{
|
||||
@@ -1495,7 +1505,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
p = phonetic;
|
||||
v = 1;
|
||||
|
||||
if((ph = phoneme_tab[*p]) != NULL)
|
||||
if(!(control & 1) && ((ph = phoneme_tab[*p]) != NULL))
|
||||
{
|
||||
|
||||
if(ph->type == phSTRESS)
|
||||
@@ -1724,6 +1734,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
|
||||
int match_type; /* left, right, or consume */
|
||||
int failed;
|
||||
int unpron_ignore;
|
||||
int consumed; /* number of letters consumed from input */
|
||||
int count; /* count through rules in the group */
|
||||
int syllable_count;
|
||||
@@ -1769,6 +1780,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
/* search through dictionary rules */
|
||||
while(rule[0] != RULE_GROUP_END)
|
||||
{
|
||||
unpron_ignore = word_flags & FLAG_UNPRON_TEST;
|
||||
match_type=0;
|
||||
consumed = 0;
|
||||
letter = 0;
|
||||
@@ -1785,6 +1797,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
|
||||
/* work through next rule until end, or until no-match proved */
|
||||
rule_start = rule;
|
||||
|
||||
failed = 0;
|
||||
while(!failed)
|
||||
{
|
||||
@@ -1815,6 +1828,14 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
break;
|
||||
case RULE_PRE:
|
||||
match_type = RULE_PRE;
|
||||
if(word_flags & FLAG_UNPRON_TEST)
|
||||
{
|
||||
// checking the start of the word for unpronouncable character sequences, only
|
||||
// consider rules which explicitly match the start of a word
|
||||
if(rule[0] != ' ')
|
||||
failed = 1;
|
||||
unpron_ignore = 0;
|
||||
}
|
||||
break;
|
||||
case RULE_POST:
|
||||
match_type = RULE_POST;
|
||||
@@ -1910,13 +1931,15 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
break;
|
||||
|
||||
case RULE_NOTVOWEL:
|
||||
if(!IsLetter(tr, letter_w,0))
|
||||
if(IsLetter(tr, letter_w, 0) || ((letter_w == ' ') && (word_flags & FLAG_SUFFIX_VOWEL)))
|
||||
{
|
||||
failed = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
add_points = (20-distance_right);
|
||||
post_ptr += letter_xbytes;
|
||||
}
|
||||
else
|
||||
failed = 1;
|
||||
break;
|
||||
|
||||
case RULE_DIGIT:
|
||||
@@ -1955,8 +1978,14 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
|
||||
case RULE_DOLLAR:
|
||||
command = *rule++;
|
||||
if(command == 0x01)
|
||||
{
|
||||
match.end_type = SUFX_UNPRON; // $unpron
|
||||
}
|
||||
else
|
||||
if((command & 0xf0) == 0x10)
|
||||
{
|
||||
// $w_alt
|
||||
if(dict_flags & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
|
||||
add_points = 23;
|
||||
else
|
||||
@@ -1965,6 +1994,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
else
|
||||
if((command & 0xf0) == 0x20)
|
||||
{
|
||||
// $p_alt
|
||||
// make a copy of the word up to the post-match characters
|
||||
ix = *word - word_start + consumed + group_length + 1;
|
||||
memcpy(word_buf, word_start-1, ix);
|
||||
@@ -2060,8 +2090,8 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
break;
|
||||
|
||||
case RULE_DEL_FWD:
|
||||
// find the next 'e' in the word and replace by ''
|
||||
for(p = *word + group_length; *p != ' '; p++)
|
||||
// find the next 'e' in the word and replace by 'E'
|
||||
for(p = *word + group_length; p < post_ptr; p++)
|
||||
{
|
||||
if(*p == 'e')
|
||||
{
|
||||
@@ -2275,9 +2305,11 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
match.points += add_points;
|
||||
}
|
||||
|
||||
if(failed == 2)
|
||||
|
||||
if((failed == 2) && (unpron_ignore == 0))
|
||||
{
|
||||
/* matched OK, is this better than the last best match ? */
|
||||
|
||||
if(match.points >= best.points)
|
||||
{
|
||||
memcpy(&best,&match,sizeof(match));
|
||||
@@ -2295,7 +2327,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
if(group_length > 1)
|
||||
pts += 35; // to account for an extra letter matching
|
||||
DecodePhonemes(match.phonemes,decoded_phonemes);
|
||||
fprintf(f_trans,"%3d\t%s [%s]\n",pts,DecodeRule(group_chars, group_length, rule_start),decoded_phonemes);
|
||||
fprintf(f_trans,"%3d\t%s [%s]\n",pts,DecodeRule(group_chars, group_length, rule_start, word_flags), decoded_phonemes);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2378,7 +2410,10 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
wordbuf[ix] = c;
|
||||
}
|
||||
wordbuf[ix] = 0;
|
||||
fprintf(f_trans,"Translate '%s'\n",wordbuf);
|
||||
if(word_flags & FLAG_UNPRON_TEST)
|
||||
fprintf(f_trans,"Unpronouncable? '%s'\n",wordbuf);
|
||||
else
|
||||
fprintf(f_trans,"Translate '%s'\n",wordbuf);
|
||||
}
|
||||
|
||||
p = p_start;
|
||||
@@ -2506,7 +2541,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
}
|
||||
|
||||
// no match, try removing the accent and re-translating the word
|
||||
if((letter >= 0xc0) && (letter <= 0x241) && ((ix = remove_accent[letter-0xc0]) != 0))
|
||||
if((letter >= 0xc0) && (letter < N_REMOVE_ACCENT) && ((ix = remove_accent[letter-0xc0]) != 0))
|
||||
{
|
||||
// within range of the remove_accent table
|
||||
if((p[-2] != ' ') || (p[n] != ' '))
|
||||
@@ -2564,7 +2599,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
}
|
||||
else
|
||||
{
|
||||
LookupLetter(tr, wc, -1, ph_buf);
|
||||
LookupLetter(tr, wc, -1, ph_buf, 0);
|
||||
if(ph_buf[0])
|
||||
{
|
||||
match1.phonemes = ph_buf;
|
||||
@@ -2591,7 +2626,11 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
strcpy(phonemes,match1.phonemes);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
if(word_flags & FLAG_UNPRON_TEST)
|
||||
return(match1.end_type | 1);
|
||||
match1.end_type &= ~SUFX_UNPRON;
|
||||
|
||||
if((match1.end_type != 0) && (end_phonemes != NULL))
|
||||
{
|
||||
/* a standard ending has been found, re-translate the word without it */
|
||||
@@ -3433,7 +3472,8 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
if((strcmp(ending,"s")==0) || (strcmp(ending,"es")==0))
|
||||
end_flags |= FLAG_SUFX_S;
|
||||
|
||||
if(strcmp(ending,"'s")==0)
|
||||
// if(strcmp(ending,"'s")==0)
|
||||
if(ending[0] == '\'')
|
||||
end_flags &= ~FLAG_SUFX; // don't consider 's as an added suffix
|
||||
|
||||
return(end_flags);
|
||||
|
||||
+19
-14
@@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
static const char *help_text =
|
||||
"\nspeak [options] [\"<words>\"]\n\n"
|
||||
"\nespeak [options] [\"<words>\"]\n\n"
|
||||
"-f <text file> Text file to speak\n"
|
||||
"--stdin Read text input from stdin instead of a file\n\n"
|
||||
"If neither -f nor --stdin, then <words> are spoken, or if none then text\n"
|
||||
@@ -43,6 +43,9 @@ static const char *help_text =
|
||||
"\t Amplitude, 0 to 200, default is 100\n"
|
||||
"-g <integer>\n"
|
||||
"\t Word gap. Pause between words, units of 10mS at the default speed\n"
|
||||
"-k <integer>\n"
|
||||
"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
|
||||
"\t higher values indicate a pitch increase (try -k20).\n"
|
||||
"-l <integer>\n"
|
||||
"\t Line length. If not zero (which is the default), consider\n"
|
||||
"\t lines less than this length as end-of-clause\n"
|
||||
@@ -53,34 +56,31 @@ static const char *help_text =
|
||||
"-v <voice name>\n"
|
||||
"\t Use voice file of this name from espeak-data/voices\n"
|
||||
"-w <wave file name>\n"
|
||||
"\t Write output to this WAV file, rather than speaking it directly\n"
|
||||
"\t Write speech to this WAV file, rather than speaking it directly\n"
|
||||
"-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n"
|
||||
"-m\t Interpret SSML markup, and ignore other < > tags\n"
|
||||
"-q\t Quiet, don't produce any speech (may be useful with -x)\n"
|
||||
"-x\t Write phoneme mnemonics to stdout\n"
|
||||
"-X\t Write phonemes mnemonics and translation trace to stdout\n"
|
||||
"-z\t No final sentence pause at the end of the text\n"
|
||||
"--stdout Write speech output to stdout\n"
|
||||
"--compile=<voice name>\n"
|
||||
"\t Compile the pronunciation rules and dictionary in the current\n"
|
||||
"\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"
|
||||
"--path=\"<path>\"\n"
|
||||
"\t Specifies the directory containing the espeak-data directory\n"
|
||||
"--pho\n"
|
||||
"\t Write mbrola phoneme data (.pho) to stdout, or to the file in --phonout\n"
|
||||
"--pho Write mbrola phoneme data (.pho) to stdout or to the file in --phonout\n"
|
||||
"--phonout=\"<filename>\"\n"
|
||||
"\t Write phoneme output from -x -X and --pho to this file\n"
|
||||
"\t Write phoneme output from -x -X --ipa and --pho to this file\n"
|
||||
"--punct=\"<characters>\"\n"
|
||||
"\t Speak the names of punctuation characters during speaking. If\n"
|
||||
"\t =<characters> is omitted, all punctuation is spoken.\n"
|
||||
"--split=\"<minutes>\"\n"
|
||||
"\t Starts a new WAV file every <minutes>. Used with -w\n"
|
||||
"--stdout Write speech output to stdout\n"
|
||||
"--voices=<language>\n"
|
||||
"\t List the available voices for the specified language.\n"
|
||||
"\t If <language> is omitted, then list all voices.\n"
|
||||
"-k <integer>\n"
|
||||
"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
|
||||
"\t higher values indicate a pitch increase (try -k20).\n";
|
||||
"\t If <language> is omitted, then list all voices.\n";
|
||||
|
||||
|
||||
|
||||
@@ -355,6 +355,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},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -573,9 +574,9 @@ int main (int argc, char **argv)
|
||||
|
||||
case 0x106: // -- split
|
||||
if(optarg2 == NULL)
|
||||
samples_split = 30 * 60; // default 30 minutes
|
||||
samples_split_seconds = 30 * 60; // default 30 minutes
|
||||
else
|
||||
samples_split = atoi(optarg2) * 60;
|
||||
samples_split_seconds = atoi(optarg2) * 60;
|
||||
break;
|
||||
|
||||
case 0x107: // --path
|
||||
@@ -590,7 +591,11 @@ int main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 0x109: // --pho
|
||||
option_mbrola_phonemes = 8;
|
||||
option_mbrola_phonemes = 16;
|
||||
break;
|
||||
|
||||
case 0x10a: // --ipa
|
||||
option_phonemes = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+55
-52
@@ -178,7 +178,7 @@ if(argc > 1)
|
||||
|
||||
|
||||
// Make a menubar
|
||||
myframe->SetMenuBar(MakeMenu(0));
|
||||
myframe->SetMenuBar(MakeMenu(0, voice_name2));
|
||||
myframe->CreateStatusBar();
|
||||
myframe->SetVoiceTitle(voice_name2);
|
||||
|
||||
@@ -198,7 +198,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
EVT_MENU(MENU_SPECTRUM, MyFrame::OnNewWindow)
|
||||
EVT_MENU(MENU_SPECTRUM2, MyFrame::OnNewWindow)
|
||||
EVT_MENU(MENU_PROSODY, MyFrame::OnProsody)
|
||||
EVT_MENU(MENU_PARAMS, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_OPT_SPEED, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_OPT_PUNCT, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_OPT_SPELL, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_PATH0, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_PATH1, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_PATH2, MyFrame::OnOptions)
|
||||
@@ -215,6 +217,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
EVT_MENU(MENU_QUIT, MyFrame::OnQuit)
|
||||
EVT_MENU(MENU_SPEAK_TRANSLATE, MyFrame::OnSpeak)
|
||||
EVT_MENU(MENU_SPEAK_RULES, MyFrame::OnSpeak)
|
||||
EVT_MENU(MENU_SPEAK_IPA, MyFrame::OnSpeak)
|
||||
EVT_MENU(MENU_SPEAK_TEXT, MyFrame::OnSpeak)
|
||||
EVT_MENU(MENU_SPEAK_FILE, MyFrame::OnSpeak)
|
||||
EVT_MENU(MENU_SPEAK_STOP, MyFrame::OnSpeak)
|
||||
@@ -230,6 +233,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
EVT_MENU(MENU_LEXICON_DE, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_LEXICON_IT, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_LEXICON_IT2, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_LEXICON_TEST, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_TO_UTF8, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_COUNT_WORDS, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_TEST, MyFrame::OnTools)
|
||||
@@ -237,7 +241,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
|
||||
EVT_TIMER(1, MyFrame::OnTimer)
|
||||
EVT_SIZE(MyFrame::OnSize)
|
||||
EVT_SASH_DRAGGED_RANGE(ID_WINDOW_TOP, ID_WINDOW_BOTTOM, MyFrame::OnSashDrag)
|
||||
EVT_SASH_DRAGGED(ID_WINDOW_LEFT, MyFrame::OnSashDrag)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
@@ -257,22 +261,16 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
|
||||
int result;
|
||||
int param;
|
||||
|
||||
// Create some dummy layout windows
|
||||
wxSashLayoutWindow *win;
|
||||
|
||||
// Another window to the left of the client window
|
||||
win = new wxSashLayoutWindow(this, ID_WINDOW_LEFT2,
|
||||
m_leftWindow = new wxSashLayoutWindow(this, ID_WINDOW_LEFT,
|
||||
wxDefaultPosition, wxSize(298, 30),
|
||||
wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN);
|
||||
win->SetDefaultSize(wxSize(310, 1000));
|
||||
win->SetOrientation(wxLAYOUT_VERTICAL);
|
||||
win->SetAlignment(wxLAYOUT_LEFT);
|
||||
// win->SetBackgroundColour(wxColour(0, 255, 255));
|
||||
win->SetSashVisible(wxSASH_RIGHT, TRUE);
|
||||
m_leftWindow->SetDefaultSize(wxSize(310, 1000));
|
||||
m_leftWindow->SetOrientation(wxLAYOUT_VERTICAL);
|
||||
m_leftWindow->SetAlignment(wxLAYOUT_LEFT);
|
||||
m_leftWindow->SetSashVisible(wxSASH_RIGHT, TRUE);
|
||||
|
||||
m_leftWindow2 = win;
|
||||
|
||||
notebook = new wxNotebook(m_leftWindow2,-1);
|
||||
notebook = new wxNotebook(m_leftWindow,-1);
|
||||
// notebook->AddPage(voicedlg,_T("Voice"),FALSE);
|
||||
formantdlg = new FormantDlg(notebook);
|
||||
notebook->AddPage(formantdlg,_T(" Spect"),FALSE);
|
||||
@@ -333,12 +331,14 @@ void MyFrame::SetVoiceTitle(char *voice_name)
|
||||
{//==========================================
|
||||
char buf[100];
|
||||
SetTitle(AppName + _T(" - ") + wxString(voice_name,wxConvLocal) + _T(" voice"));
|
||||
if(data_menu != NULL)
|
||||
if((data_menu != NULL) && (translator != NULL))
|
||||
{
|
||||
sprintf(buf,"Compile &dictionary '%s'",dictionary_name);
|
||||
sprintf(buf,"Compile &dictionary '%s'",translator->dictionary_name);
|
||||
data_menu->SetLabel(MENU_COMPILE_DICT, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Layout '%s_rules' file",dictionary_name);
|
||||
sprintf(buf,"&Layout '%s_rules' file",translator->dictionary_name);
|
||||
data_menu->SetLabel(MENU_FORMAT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Sort '%s_rules' file",translator->dictionary_name);
|
||||
data_menu->SetLabel(MENU_SORT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ void OnOptions2(int event_id)
|
||||
|
||||
switch(event_id)
|
||||
{
|
||||
case MENU_PARAMS:
|
||||
case MENU_OPT_SPEED:
|
||||
value = wxGetNumberFromUser(_T(""),_T(""),_T("Speed"),option_speed,80,500);
|
||||
if(value > 0)
|
||||
{
|
||||
@@ -484,6 +484,18 @@ void OnOptions2(int event_id)
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_OPT_PUNCT:
|
||||
transldlg->t_source->SetValue(_T("<tts:style field=\"punctuation\" mode=\"all\">\n"));
|
||||
transldlg->t_source->SetInsertionPointEnd();
|
||||
notebook->SetSelection(1);
|
||||
break;
|
||||
|
||||
case MENU_OPT_SPELL:
|
||||
transldlg->t_source->SetValue(_T("<say-as interpret-as=\"tts:char\">\n"));
|
||||
transldlg->t_source->SetInsertionPointEnd();
|
||||
notebook->SetSelection(1);
|
||||
break;
|
||||
|
||||
case MENU_PATH0:
|
||||
string = wxFileSelector(_T("Master phonemes file"),wxFileName(path_phfile).GetPath(),
|
||||
_T(""),_T(""),_T("*"),wxOPEN);
|
||||
@@ -548,8 +560,8 @@ void DisplayErrorFile(const char *fname)
|
||||
len = GetFileLength(fname);
|
||||
if(len > 0)
|
||||
{
|
||||
if(len > 2000)
|
||||
len = 2000; // restrict length to pppppevent crash in wxLogMessage()
|
||||
if(len > 1500)
|
||||
len = 1500; // restrict length to pppppevent crash in wxLogMessage()
|
||||
msg = (char *)malloc(len+1);
|
||||
if(msg != NULL)
|
||||
{
|
||||
@@ -597,6 +609,7 @@ void MyFrame::OnTools(wxCommandEvent& event)
|
||||
case MENU_LEXICON_DE:
|
||||
case MENU_LEXICON_IT:
|
||||
case MENU_LEXICON_IT2:
|
||||
case MENU_LEXICON_TEST:
|
||||
CompareLexicon(event.GetId()); // Compare a lexicon with _rules translation
|
||||
break;
|
||||
|
||||
@@ -618,8 +631,8 @@ void MyFrame::OnTools(wxCommandEvent& event)
|
||||
sprintf(fname_log,"%s%s",path_dsource,"dict_log");
|
||||
log = fopen(fname_log,"w");
|
||||
|
||||
LoadDictionary(translator, dictionary_name, 0);
|
||||
if((err = CompileDictionary(path_dsource,dictionary_name,log,err_fname,debug_flag)) < 0)
|
||||
LoadDictionary(translator, translator->dictionary_name, 0);
|
||||
if((err = CompileDictionary(path_dsource,translator->dictionary_name,log,err_fname,debug_flag)) < 0)
|
||||
{
|
||||
wxLogError(_T("Can't access file:\n")+wxString(err_fname,wxConvLocal));
|
||||
|
||||
@@ -678,6 +691,7 @@ void MyFrame::OnSpeak(wxCommandEvent& event)
|
||||
{
|
||||
case MENU_SPEAK_TRANSLATE:
|
||||
case MENU_SPEAK_RULES:
|
||||
case MENU_SPEAK_IPA:
|
||||
case MENU_SPEAK_TEXT:
|
||||
transldlg->OnCommand(event);
|
||||
break;
|
||||
@@ -713,37 +727,26 @@ void MyFrame::OnSpeak(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnSashDrag(wxSashEvent& event)
|
||||
{
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
int w, h;
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_WINDOW_TOP:
|
||||
{
|
||||
m_topWindow->SetDefaultSize(wxSize(1000, event.GetDragRect().height));
|
||||
break;
|
||||
}
|
||||
case ID_WINDOW_LEFT1:
|
||||
{
|
||||
m_leftWindow1->SetDefaultSize(wxSize(event.GetDragRect().width, 1000));
|
||||
break;
|
||||
}
|
||||
case ID_WINDOW_LEFT2:
|
||||
{
|
||||
m_leftWindow2->SetDefaultSize(wxSize(event.GetDragRect().width, 1000));
|
||||
break;
|
||||
}
|
||||
case ID_WINDOW_BOTTOM:
|
||||
{
|
||||
m_bottomWindow->SetDefaultSize(wxSize(1000, event.GetDragRect().height));
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
// Leaves bits of itself behind sometimes
|
||||
GetClientWindow()->Refresh();
|
||||
GetClientSize(&w, &h);
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_WINDOW_LEFT:
|
||||
{
|
||||
m_leftWindow->SetDefaultSize(wxSize(event.GetDragRect().width, h));
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
|
||||
// Leaves bits of itself behind sometimes
|
||||
GetClientWindow()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -763,6 +763,75 @@ void Lexicon_De()
|
||||
}
|
||||
|
||||
|
||||
extern int IsVowel(Translator *tr, int letter);
|
||||
|
||||
void Lexicon_Test()
|
||||
{//================
|
||||
int c1, c2, c3;
|
||||
char *p;
|
||||
int prev_c1=0;
|
||||
int prev_c2=0;
|
||||
int prev_c3 = 0;
|
||||
FILE *f_in;
|
||||
FILE *f_out;
|
||||
char buf[200];
|
||||
|
||||
wxString s_fname = wxFileSelector(_T("List of UTF-8 words with Combining Grave Accent U+300 to indicate stress"),path_dir1,
|
||||
_T(""),_T(""),_T("*"),wxOPEN);
|
||||
if(s_fname.IsEmpty())
|
||||
return;
|
||||
strcpy(buf,s_fname.mb_str(wxConvLocal));
|
||||
path_dir1 = wxFileName(s_fname).GetPath();
|
||||
|
||||
if((f_in = fopen(buf,"r")) == NULL)
|
||||
{
|
||||
wxLogError(_T("Can't read file: ") + wxString(buf,wxConvLocal));
|
||||
return;
|
||||
}
|
||||
|
||||
strcat(buf,"_1");
|
||||
if((f_out = fopen(buf,"w")) == NULL)
|
||||
{
|
||||
wxLogError(_T("Can't write file: ") + wxString(buf,wxConvLocal));
|
||||
fclose(f_in);
|
||||
return;
|
||||
}
|
||||
|
||||
while(!feof(f_in))
|
||||
{
|
||||
if((p = fgets(buf,sizeof(buf),f_in)) == NULL)
|
||||
break;
|
||||
|
||||
if(buf[0] == 0)
|
||||
continue;
|
||||
|
||||
p += utf8_in(&c1, p);
|
||||
p += utf8_in(&c2, p);
|
||||
p += utf8_in(&c3, p);
|
||||
|
||||
c1 = towlower(c1);
|
||||
c2 = towlower(c2);
|
||||
c3 = towlower(c3);
|
||||
|
||||
if(IsVowel(translator, c1))
|
||||
continue;
|
||||
if(IsVowel(translator, c2))
|
||||
continue;
|
||||
|
||||
if((prev_c1 != c1) || (prev_c2 != c2) || ((prev_c3 != c3) && !IsVowel(translator,c3)))
|
||||
fputc('\n',f_out);
|
||||
prev_c1 = c1;
|
||||
prev_c2 = c2;
|
||||
prev_c3 = c3;
|
||||
fprintf(f_out,"%s",buf);
|
||||
|
||||
}
|
||||
fclose(f_in);
|
||||
fclose(f_out);
|
||||
} // end of Lexicon_Test
|
||||
|
||||
|
||||
|
||||
void Lexicon_Bg()
|
||||
{//==============
|
||||
// Bulgarian: compare stress markup in a list of words with lookup using bg_rules
|
||||
@@ -1275,6 +1344,9 @@ void CompareLexicon(int id)
|
||||
case MENU_LEXICON_IT2:
|
||||
Lexicon_It(2);
|
||||
break;
|
||||
case MENU_LEXICON_TEST:
|
||||
Lexicon_Test();
|
||||
break;
|
||||
}
|
||||
} // end of CompareLexicon
|
||||
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ static unsigned char env_risefallrise[128] = {
|
||||
|
||||
|
||||
|
||||
unsigned char *envelope_data[20] = {
|
||||
unsigned char *envelope_data[N_ENVELOPE_DATA] = {
|
||||
env_fall, env_fall,
|
||||
env_rise, env_rise,
|
||||
env_frise, env_r_frise,
|
||||
|
||||
+10
-10
@@ -421,7 +421,7 @@ if(option_log_frames)
|
||||
#endif
|
||||
|
||||
out = resonator(&(kt_globals.rsn[Rout]),out);
|
||||
temp = (out * wdata.amplitude * kt_globals.amp_gain0) ; /* Convert back to integer */
|
||||
temp = (int)(out * wdata.amplitude * kt_globals.amp_gain0) ; /* Convert back to integer */
|
||||
|
||||
|
||||
// mix with a recorded WAV if required for this phoneme
|
||||
@@ -458,7 +458,7 @@ if(option_log_frames)
|
||||
temp = (temp * kt_globals.fadeout) / 64;
|
||||
}
|
||||
|
||||
value = int(temp) + ((echo_buf[echo_tail++]*echo_amp) >> 8);
|
||||
value = (int)temp + ((echo_buf[echo_tail++]*echo_amp) >> 8);
|
||||
if(echo_tail >= N_ECHO_BUF)
|
||||
echo_tail=0;
|
||||
|
||||
@@ -973,7 +973,7 @@ static double DBtoLIN(long dB)
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(double(amptable[dB]) * 0.001);
|
||||
return((double)(amptable[dB]) * 0.001);
|
||||
}
|
||||
|
||||
|
||||
@@ -1050,7 +1050,7 @@ int Wavegen_Klatt(int resume)
|
||||
for(ix=0; ix < N_KLATTP; ix++)
|
||||
{
|
||||
klattp1[ix] += klattp_inc[ix];
|
||||
klattp[ix] = int(klattp1[ix]);
|
||||
klattp[ix] = (int)klattp1[ix];
|
||||
}
|
||||
|
||||
for(ix=0; ix<=6; ix++)
|
||||
@@ -1213,7 +1213,7 @@ if(option_log_frames)
|
||||
else
|
||||
{
|
||||
klattp1[ix] = klattp[ix] = fr1->klattp[ix];
|
||||
klattp_inc[ix] = double((fr2->klattp[ix] - klattp[ix]) * STEPSIZE)/length;
|
||||
klattp_inc[ix] = (double)((fr2->klattp[ix] - klattp[ix]) * STEPSIZE)/length;
|
||||
}
|
||||
|
||||
// get klatt parameter adjustments for the voice
|
||||
@@ -1226,7 +1226,7 @@ if(option_log_frames)
|
||||
for(ix=1; ix < 6; ix++)
|
||||
{
|
||||
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
|
||||
peaks[ix].freq = int(peaks[ix].freq1);
|
||||
peaks[ix].freq = (int)peaks[ix].freq1;
|
||||
next = (fr2->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
|
||||
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * STEPSIZE) / length;
|
||||
|
||||
@@ -1234,7 +1234,7 @@ if(option_log_frames)
|
||||
{
|
||||
// klatt bandwidth for f1, f2, f3 (others are fixed)
|
||||
peaks[ix].bw1 = fr1->bw[ix] * 2;
|
||||
peaks[ix].bw = int(peaks[ix].bw1);
|
||||
peaks[ix].bw = (int)peaks[ix].bw1;
|
||||
next = fr2->bw[ix] * 2;
|
||||
peaks[ix].bw_inc = ((next - peaks[ix].bw1) * STEPSIZE) / length;
|
||||
}
|
||||
@@ -1245,7 +1245,7 @@ if(option_log_frames)
|
||||
if(peaks[0].freq1 == 0)
|
||||
peaks[0].freq1 = kt_frame.Fhz[F_NP]; // if no nasal zero, set it to same freq as nasal pole
|
||||
|
||||
peaks[0].freq = int(peaks[0].freq1);
|
||||
peaks[0].freq = (int)peaks[0].freq1;
|
||||
next = fr2->klattp[KLATT_FNZ] * 2;
|
||||
if(next == 0)
|
||||
next = kt_frame.Fhz[F_NP];
|
||||
@@ -1262,12 +1262,12 @@ if(option_log_frames)
|
||||
for(ix=1; ix < 7; ix++)
|
||||
{
|
||||
peaks[ix].bp1 = fr1->klatt_bp[ix] * 4; // parallel bandwidth
|
||||
peaks[ix].bp = int(peaks[ix].bp1);
|
||||
peaks[ix].bp = (int)peaks[ix].bp1;
|
||||
next = fr2->klatt_bp[ix] * 2;
|
||||
peaks[ix].bp_inc = ((next - peaks[ix].bp1) * STEPSIZE) / length;
|
||||
|
||||
peaks[ix].ap1 = fr1->klatt_ap[ix]; // parallal amplitude
|
||||
peaks[ix].ap = int(peaks[ix].ap1);
|
||||
peaks[ix].ap = (int)peaks[ix].ap1;
|
||||
next = fr2->klatt_ap[ix] * 2;
|
||||
peaks[ix].ap_inc = ((next - peaks[ix].ap1) * STEPSIZE) / length;
|
||||
}
|
||||
|
||||
+9
-11
@@ -8,7 +8,7 @@ typedef unsigned char UCHAR;
|
||||
|
||||
|
||||
|
||||
extern wxMenuBar *MakeMenu(int type);
|
||||
extern wxMenuBar *MakeMenu(int type, const char *dict_name);
|
||||
|
||||
extern wxString path_phsource;
|
||||
extern wxString path_speaktext;
|
||||
@@ -56,10 +56,7 @@ class MyFrame: public wxMDIParentFrame
|
||||
|
||||
|
||||
protected:
|
||||
wxSashLayoutWindow* m_topWindow;
|
||||
wxSashLayoutWindow* m_leftWindow1;
|
||||
wxSashLayoutWindow* m_leftWindow2;
|
||||
wxSashLayoutWindow* m_bottomWindow;
|
||||
wxSashLayoutWindow* m_leftWindow;
|
||||
wxTimer m_timer;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
@@ -94,11 +91,11 @@ public:
|
||||
void SpeakFile(void);
|
||||
void ReadVoice(int variant);
|
||||
void OnCommand(wxCommandEvent& event);
|
||||
wxTextCtrl* t_source;
|
||||
|
||||
private:
|
||||
wxButton *t_translate;
|
||||
wxButton *t_process;
|
||||
wxTextCtrl* t_source;
|
||||
wxTextCtrl* t_phonetic;
|
||||
|
||||
|
||||
@@ -124,7 +121,9 @@ enum {
|
||||
MENU_DOCS,
|
||||
|
||||
MENU_OPTIONS,
|
||||
MENU_PARAMS,
|
||||
MENU_OPT_SPEED,
|
||||
MENU_OPT_PUNCT,
|
||||
MENU_OPT_SPELL,
|
||||
MENU_PATHS,
|
||||
MENU_PATH0,
|
||||
MENU_PATH1,
|
||||
@@ -143,6 +142,7 @@ enum {
|
||||
|
||||
MENU_SPEAK_TRANSLATE,
|
||||
MENU_SPEAK_RULES,
|
||||
MENU_SPEAK_IPA,
|
||||
MENU_SPEAK_TEXT,
|
||||
MENU_SPEAK_FILE,
|
||||
MENU_SPEAK_PAUSE,
|
||||
@@ -161,6 +161,7 @@ enum {
|
||||
MENU_LEXICON_DE,
|
||||
MENU_LEXICON_IT,
|
||||
MENU_LEXICON_IT2,
|
||||
MENU_LEXICON_TEST,
|
||||
MENU_TO_UTF8,
|
||||
MENU_COUNT_WORDS,
|
||||
MENU_TEST,
|
||||
@@ -174,10 +175,7 @@ enum {
|
||||
SPECTSEQ_VOICEDLG
|
||||
};
|
||||
|
||||
#define ID_WINDOW_TOP 100
|
||||
#define ID_WINDOW_LEFT1 101
|
||||
#define ID_WINDOW_LEFT2 102
|
||||
#define ID_WINDOW_BOTTOM 103
|
||||
#define ID_WINDOW_LEFT 101
|
||||
|
||||
|
||||
|
||||
|
||||
+90
-63
@@ -19,7 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
@@ -74,19 +74,19 @@ static void log(const char *msg, ...)
|
||||
va_end(params);
|
||||
}
|
||||
|
||||
static void err(const char *err, ...)
|
||||
static void err(const char *errmsg, ...)
|
||||
{
|
||||
va_list params;
|
||||
|
||||
va_start(params, err);
|
||||
vsnprintf(mbr_errorbuf, sizeof(mbr_errorbuf), err, params);
|
||||
va_start(params, errmsg);
|
||||
vsnprintf(mbr_errorbuf, sizeof(mbr_errorbuf), errmsg, params);
|
||||
va_end(params);
|
||||
log("mbrola error: \"%s\"", mbr_errorbuf);
|
||||
log("mbrowrap error: %s", mbr_errorbuf);
|
||||
}
|
||||
|
||||
static int create_pipes(int p1[2], int p2[2], int p3[2])
|
||||
{
|
||||
int error=0;
|
||||
int error;
|
||||
|
||||
if (pipe(p1) != -1) {
|
||||
if (pipe(p2) != -1) {
|
||||
@@ -100,7 +100,8 @@ static int create_pipes(int p1[2], int p2[2], int p3[2])
|
||||
error = errno;
|
||||
close(p1[0]);
|
||||
close(p1[1]);
|
||||
}
|
||||
} else
|
||||
error = errno;
|
||||
|
||||
err("pipe(): %s", strerror(error));
|
||||
return -1;
|
||||
@@ -231,67 +232,89 @@ static void free_pending_data(void)
|
||||
mbr_pending_data_tail = NULL;
|
||||
}
|
||||
|
||||
static int mbrola_died(void)
|
||||
{
|
||||
pid_t pid;
|
||||
int status, len;
|
||||
const char *msg;
|
||||
char msgbuf[80];
|
||||
|
||||
pid = waitpid(mbr_pid, &status, WNOHANG);
|
||||
if (!pid) {
|
||||
msg = "mbrola closed stderr and did not exit";
|
||||
} else if (pid != mbr_pid) {
|
||||
msg = "waitpid() is confused";
|
||||
} else {
|
||||
mbr_pid = 0;
|
||||
if (WIFSIGNALED(status)) {
|
||||
int sig = WTERMSIG(status);
|
||||
snprintf(msgbuf, sizeof(msgbuf),
|
||||
"mbrola died by signal %d", sig);
|
||||
msg = msgbuf;
|
||||
} else if (WIFEXITED(status)) {
|
||||
int exst = WEXITSTATUS(status);
|
||||
snprintf(msgbuf, sizeof(msgbuf),
|
||||
"mbrola exited with status %d", exst);
|
||||
msg = msgbuf;
|
||||
} else {
|
||||
msg = "mbrola died and wait status is weird";
|
||||
}
|
||||
}
|
||||
|
||||
log("mbrowrap error: %s", msg);
|
||||
|
||||
len = strlen(mbr_errorbuf);
|
||||
if (!len)
|
||||
snprintf(mbr_errorbuf, sizeof(mbr_errorbuf), "%s", msg);
|
||||
else
|
||||
snprintf(mbr_errorbuf + len, sizeof(mbr_errorbuf) - len,
|
||||
", (%s)", msg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int mbrola_has_errors(void)
|
||||
{
|
||||
int result, error;
|
||||
int result;
|
||||
char buffer[256];
|
||||
char *buf_ptr, *lf;
|
||||
|
||||
result = read(mbr_error_fd, mbr_errorbuf, sizeof(mbr_errorbuf)-1);
|
||||
|
||||
if (result == -1) {
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
err("read(error): %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
mbr_errorbuf[result] = 0;
|
||||
if (mbr_errorbuf[result - 1] == '\n')
|
||||
mbr_errorbuf[result - 1] = 0;
|
||||
/* inhibit the reset signal message */
|
||||
if (strncmp(mbr_errorbuf, "Got a reset signal", 18) == 0) {
|
||||
mbr_errorbuf[0] = 0;
|
||||
return 0;
|
||||
buf_ptr = buffer;
|
||||
for (;;) {
|
||||
result = read(mbr_error_fd, buf_ptr,
|
||||
sizeof(buffer) - (buf_ptr - buffer) - 1);
|
||||
if (result == -1) {
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
err("read(error): %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
/* don't consider this fatal at this point */
|
||||
error = 0;
|
||||
} else {
|
||||
/* EOF on stderr, assume mbrola died. */
|
||||
pid_t pid;
|
||||
int status, len;
|
||||
const char *msg;
|
||||
char msgbuf[80];
|
||||
|
||||
pid = waitpid(mbr_pid, &status, WNOHANG);
|
||||
if (!pid) {
|
||||
msg = "mbrola closed stderr and did not exit";
|
||||
} else {
|
||||
mbr_pid = 0;
|
||||
if (WIFSIGNALED(status)) {
|
||||
int sig = WTERMSIG(status);
|
||||
snprintf(msgbuf, sizeof(msgbuf),
|
||||
"mbrola died by signal %d", sig);
|
||||
msg = msgbuf;
|
||||
} else if (WIFEXITED(status)) {
|
||||
int exst = WEXITSTATUS(status);
|
||||
snprintf(msgbuf, sizeof(msgbuf),
|
||||
"mbrola exited with status %d", exst);
|
||||
msg = msgbuf;
|
||||
} else {
|
||||
msg = "mbrola died and wait status is weird";
|
||||
if (result == 0) {
|
||||
/* EOF on stderr, assume mbrola died. */
|
||||
return mbrola_died();
|
||||
}
|
||||
|
||||
buf_ptr[result] = 0;
|
||||
|
||||
for (; (lf = strchr(buf_ptr, '\n')); buf_ptr = lf + 1) {
|
||||
/* inhibit the reset signal messages */
|
||||
if (strncmp(buf_ptr, "Got a reset signal", 18) == 0 ||
|
||||
strncmp(buf_ptr, "Input Flush Signal", 18) == 0)
|
||||
continue;
|
||||
*lf = 0;
|
||||
log("mbrola: %s", buf_ptr);
|
||||
/* is this the last line? */
|
||||
if (lf == &buf_ptr[result - 1]) {
|
||||
snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
|
||||
"%s", buf_ptr);
|
||||
/* don't consider this fatal at this point */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
len = strlen(mbr_errorbuf);
|
||||
if (!len)
|
||||
snprintf(mbr_errorbuf, sizeof(mbr_errorbuf), "%s", msg);
|
||||
else
|
||||
snprintf(mbr_errorbuf+len, sizeof(mbr_errorbuf)-len,
|
||||
", (%s)", msg);
|
||||
error = -1;
|
||||
}
|
||||
|
||||
log("mbrola error: \"%s\"", mbr_errorbuf);
|
||||
return error;
|
||||
memmove(buffer, buf_ptr, result);
|
||||
buf_ptr = buffer + result;
|
||||
}
|
||||
}
|
||||
|
||||
static int send_to_mbrola(const char *cmd)
|
||||
@@ -468,7 +491,8 @@ int init_MBR(const char *voice_path)
|
||||
/* we should actually be getting only 44 bytes */
|
||||
result = receive_from_mbrola(wavhdr, 45);
|
||||
if (result != 44) {
|
||||
err("unable to get .wav header from mbrola");
|
||||
if (result >= 0)
|
||||
err("unable to get .wav header from mbrola");
|
||||
stop_mbrola();
|
||||
return -1;
|
||||
}
|
||||
@@ -482,7 +506,7 @@ int init_MBR(const char *voice_path)
|
||||
}
|
||||
mbr_samplerate = wavhdr[24] + (wavhdr[25]<<8) +
|
||||
(wavhdr[26]<<16) + (wavhdr[27]<<24);
|
||||
//log("mbrola: voice samplerate = %d", mbr_samplerate);
|
||||
//log("mbrowrap: voice samplerate = %d", mbr_samplerate);
|
||||
|
||||
/* remember the voice path for setVolumeRatio_MBR() */
|
||||
if (mbr_voice_path != voice_path) {
|
||||
@@ -568,7 +592,10 @@ void setVolumeRatio_MBR(float value)
|
||||
|
||||
int lastErrorStr_MBR(char *buffer, int bufsize)
|
||||
{
|
||||
int result = snprintf(buffer, bufsize, "%s", mbr_errorbuf);
|
||||
int result;
|
||||
if (mbr_pid)
|
||||
mbrola_has_errors();
|
||||
result = snprintf(buffer, bufsize, "%s", mbr_errorbuf);
|
||||
return result >= bufsize ? (bufsize - 1) : result;
|
||||
}
|
||||
|
||||
|
||||
+15
-5
@@ -22,13 +22,12 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
wxMenu *speak_menu;
|
||||
wxMenu *data_menu = NULL;
|
||||
|
||||
wxMenuBar *MakeMenu(int type)
|
||||
{//==========================
|
||||
|
||||
wxMenuBar *MakeMenu(int type, const char *dict_name)
|
||||
{//=================================================
|
||||
char buf[100];
|
||||
wxMenu *file_menu;
|
||||
wxMenu *help_menu;
|
||||
wxMenu *option_menu = NULL;
|
||||
@@ -71,6 +70,7 @@ wxMenuBar *MakeMenu(int type)
|
||||
speak_menu = new wxMenu;
|
||||
speak_menu->Append(MENU_SPEAK_TRANSLATE, _("&Translate"));
|
||||
speak_menu->Append(MENU_SPEAK_RULES, _("Show &Rules"));
|
||||
speak_menu->Append(MENU_SPEAK_IPA, _("Show &IPA"));
|
||||
speak_menu->Append(MENU_SPEAK_TEXT, _("&Speak"));
|
||||
speak_menu->AppendSeparator();
|
||||
speak_menu->Append(MENU_SPEAK_FILE, _("Speak &file..."));
|
||||
@@ -94,6 +94,13 @@ wxMenuBar *MakeMenu(int type)
|
||||
data_menu->Append(MENU_FORMAT_DICTIONARY, _("&Layout *_rules file"));
|
||||
data_menu->Append(MENU_SORT_DICTIONARY, _("&Sort *_rules file"));
|
||||
|
||||
sprintf(buf,"Compile &dictionary '%s'",dict_name);
|
||||
data_menu->SetLabel(MENU_COMPILE_DICT, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Layout '%s_rules' file",dict_name);
|
||||
data_menu->SetLabel(MENU_FORMAT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Sort '%s_rules' file",dict_name);
|
||||
data_menu->SetLabel(MENU_SORT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
|
||||
// OPTIONS MENU
|
||||
paths_menu = new wxMenu;
|
||||
paths_menu->Append(MENU_PATH0, _("Master phonemes file..."));
|
||||
@@ -105,7 +112,9 @@ wxMenuBar *MakeMenu(int type)
|
||||
|
||||
option_menu = new wxMenu;
|
||||
option_menu->Append(MENU_PATHS, _("Set &paths"), paths_menu);
|
||||
option_menu->Append(MENU_PARAMS, _("Speed..."));
|
||||
option_menu->Append(MENU_OPT_SPEED, _("Speed..."));
|
||||
option_menu->Append(MENU_OPT_PUNCT, _("Speak punctiation"));
|
||||
option_menu->Append(MENU_OPT_SPELL, _("Speak character names"));
|
||||
|
||||
// TOOLS
|
||||
vowelchart_menu = new wxMenu;
|
||||
@@ -119,6 +128,7 @@ wxMenuBar *MakeMenu(int type)
|
||||
lexicon_menu->Append(MENU_LEXICON_DE, _("German"));
|
||||
lexicon_menu->Append(MENU_LEXICON_IT, _("Italian"));
|
||||
lexicon_menu->Append(MENU_LEXICON_IT2, _("Italian, pass 2"));
|
||||
// lexicon_menu->Append(MENU_LEXICON_TEST, _("Test"));
|
||||
|
||||
tools_menu = new wxMenu;
|
||||
tools_menu->Append(MENU_VOWELCHART, _("Make &Vowels Chart"), vowelchart_menu);
|
||||
|
||||
+39
-32
@@ -498,12 +498,12 @@ void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf)
|
||||
|
||||
|
||||
|
||||
void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1)
|
||||
{//=================================================================================
|
||||
void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1, int control)
|
||||
{//==============================================================================================
|
||||
// control, bit 0: not the first letter of a word
|
||||
|
||||
int len;
|
||||
unsigned char *p;
|
||||
static char single_letter[10] = {0,0};
|
||||
char ph_stress[2];
|
||||
unsigned int dict_flags[2];
|
||||
char ph_buf3[40];
|
||||
char *ptr;
|
||||
@@ -568,27 +568,17 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b
|
||||
LookupAccentedLetter(tr, letter, ph_buf3);
|
||||
}
|
||||
|
||||
if(ph_buf3[0] == 0)
|
||||
strcpy(ph_buf1, ph_buf3);
|
||||
if((ph_buf1[0] == 0) || (ph_buf1[0] == phonSWITCH))
|
||||
{
|
||||
ph_buf1[0] = 0;
|
||||
return;
|
||||
}
|
||||
if(ph_buf3[0] == phonSWITCH)
|
||||
{
|
||||
strcpy(ph_buf1,ph_buf3);
|
||||
return;
|
||||
}
|
||||
// at a stress marker at the start of the letter name, unless one is already marked
|
||||
ph_stress[0] = phonSTRESS_P;
|
||||
ph_stress[1] = 0;
|
||||
|
||||
for(p=(unsigned char *)ph_buf3; (*p != 0) && (phoneme_tab[*p] != NULL); p++)
|
||||
{
|
||||
if(phoneme_tab[*p]->type == phSTRESS)
|
||||
ph_stress[0] = 0; // stress is already marked
|
||||
}
|
||||
sprintf(ph_buf1,"%s%s",ph_stress,ph_buf3);
|
||||
}
|
||||
dict_flags[0] = 0;
|
||||
dict_flags[1] = 0;
|
||||
SetWordStress(tr, ph_buf1, dict_flags, -1, control & 1);
|
||||
|
||||
} // end of LookupLetter
|
||||
|
||||
|
||||
|
||||
@@ -596,7 +586,9 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
{//=========================================================================
|
||||
// get pronunciation for an isolated letter
|
||||
// return number of bytes used by the letter
|
||||
// control 2=say-as glyphs, 3-say-as chars
|
||||
// control bit 0: a non-initial letter in a word
|
||||
// bit 1: say 'capital'
|
||||
|
||||
int n_bytes;
|
||||
int letter;
|
||||
int len;
|
||||
@@ -618,7 +610,7 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
letter &= 0xff; // uncode private usage area
|
||||
}
|
||||
|
||||
if(control > 2)
|
||||
if(control & 2)
|
||||
{
|
||||
// include CAPITAL information
|
||||
if(iswupper(letter))
|
||||
@@ -628,7 +620,7 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
}
|
||||
letter = towlower2(letter);
|
||||
|
||||
LookupLetter(tr, letter, word[n_bytes], ph_buf);
|
||||
LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
|
||||
|
||||
if(ph_buf[0] == phonSWITCH)
|
||||
{
|
||||
@@ -642,7 +634,7 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
SetTranslator2("en");
|
||||
save_option_phonemes = option_phonemes;
|
||||
option_phonemes = 0;
|
||||
LookupLetter(translator2, letter, word[n_bytes], ph_buf);
|
||||
LookupLetter(translator2, letter, word[n_bytes], ph_buf, control & 1);
|
||||
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
|
||||
option_phonemes = save_option_phonemes;
|
||||
|
||||
@@ -671,7 +663,7 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
{
|
||||
pbuf += strlen(pbuf);
|
||||
*pbuf++ = phonPAUSE_VSHORT;
|
||||
LookupLetter(tr, *p2, 0, pbuf);
|
||||
LookupLetter(tr, *p2, 0, pbuf, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -740,9 +732,11 @@ void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
|
||||
if(control == 4)
|
||||
c = phonPAUSE; // pause after each character
|
||||
if(((count % 3) == 0) || (control > 2))
|
||||
c = phonPAUSE_SHORT; // pause following a primary stress
|
||||
c = phonPAUSE_NOLINK; // pause following a primary stress
|
||||
else
|
||||
continue; // remove marker
|
||||
c = phonPAUSE_VSHORT;
|
||||
// else
|
||||
// continue; // remove marker
|
||||
}
|
||||
*phonemes++ = c;
|
||||
}
|
||||
@@ -772,7 +766,7 @@ static int CheckDotOrdinal(Translator *tr, char *word, char *word_end, WORD_TAB
|
||||
if(word_end[0] == '.')
|
||||
utf8_in(&c2, &word_end[2]);
|
||||
else
|
||||
utf8_in(&c2, &word_end[1]);
|
||||
utf8_in(&c2, &word_end[0]);
|
||||
|
||||
if((word_end[1] != 0) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || IsAlpha(c2)))
|
||||
{
|
||||
@@ -856,8 +850,8 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
flags[0] = 0;
|
||||
flags[1] = 0;
|
||||
|
||||
if((tr->langopts.numbers & NUM_ROMAN_CAPITALS) && !(wtab[0].flags & FLAG_ALL_UPPER))
|
||||
return(0);
|
||||
if(((tr->langopts.numbers & NUM_ROMAN_CAPITALS) && !(wtab[0].flags & FLAG_ALL_UPPER)) || isdigit(word[-2]))
|
||||
return(0); // not '2xx'
|
||||
|
||||
word_start = word;
|
||||
while((c = *word++) != ' ')
|
||||
@@ -895,6 +889,10 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
prev = value;
|
||||
n_digits++;
|
||||
}
|
||||
|
||||
if(isdigit(word[0]))
|
||||
return(0); // eg. 'xx2'
|
||||
|
||||
acc += prev;
|
||||
if(acc < tr->langopts.min_roman)
|
||||
return(0);
|
||||
@@ -902,6 +900,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
if(acc > tr->langopts.max_roman)
|
||||
return(0);
|
||||
|
||||
|
||||
Lookup(tr, "_roman",ph_roman); // precede by "roman" if _rom is defined in *_list
|
||||
p = &ph_out[0];
|
||||
|
||||
@@ -937,6 +936,10 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wtab[0].flags |= FLAG_ORDINAL;
|
||||
}
|
||||
}
|
||||
|
||||
tr->prev_dict_flags = 0;
|
||||
@@ -1077,6 +1080,10 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou
|
||||
}
|
||||
}
|
||||
sprintf(ph_out,"%s%s",ph_of,ph_thousands);
|
||||
|
||||
if((value == 1) && (thousandplex == 1) && (tr->langopts.numbers & NUM_OMIT_1_THOUSAND))
|
||||
return(1);
|
||||
|
||||
return(found_value);
|
||||
}
|
||||
|
||||
@@ -1593,7 +1600,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
hyphen = 1;
|
||||
ix++;
|
||||
}
|
||||
while((word[ix] != 0) && (word[ix] != ' ') && (ix < int(sizeof(suffix)-1)))
|
||||
while((word[ix] != 0) && (word[ix] != ' ') && (ix < (int)(sizeof(suffix)-1)))
|
||||
{
|
||||
*p++ = word[ix++];
|
||||
}
|
||||
|
||||
+3
-2
@@ -36,6 +36,7 @@
|
||||
|
||||
// phoneme properties
|
||||
// bits 16-19 give place of articulation
|
||||
#define phARTICULATION 0xf0000
|
||||
#define phWAVE 0x01
|
||||
#define phUNSTRESSED 0x02
|
||||
#define phFORTIS 0x08
|
||||
@@ -50,7 +51,6 @@
|
||||
#define phBRKAFTER 0x4000 // [*] add a post-pause
|
||||
#define phBEFOREPAUSE 0x8000 // replace with the link_out phoneme if the next phoneme is a pause
|
||||
|
||||
|
||||
#define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
|
||||
#define phLONG 0x200000
|
||||
#define phLENGTHENSTOP 0x400000 // make the pre-pause slightly longer
|
||||
@@ -130,7 +130,8 @@ typedef struct {
|
||||
char name[N_PHONEME_TAB_NAME];
|
||||
PHONEME_TAB *phoneme_tab_ptr;
|
||||
int n_phonemes;
|
||||
int includes; // also include the phonemes from this other phoneme table
|
||||
int includes; // also include the phonemes from this other phoneme table
|
||||
int equivalence_tables; // lists of equivalent phonemes to match other languages, byte index into phondata
|
||||
} PHONEME_TAB_LIST;
|
||||
|
||||
|
||||
|
||||
+11
-4
@@ -380,9 +380,12 @@ void ProsodyDisplay::DrawEnv(wxDC& dc, int x1, int y1, int width, PHONEME_LIST *
|
||||
{
|
||||
// the envelope is given by a Tone phoneme acting on this vowel
|
||||
InterpretPhoneme2(ph->tone_ph, &phdata_tone);
|
||||
env = LookupEnvelope(phdata_tone.pitch_env);
|
||||
env = GetEnvelope(phdata_tone.pitch_env);
|
||||
}
|
||||
|
||||
if(env == NULL)
|
||||
return;
|
||||
|
||||
for(ix=0; ix<=width; ix+=4)
|
||||
{
|
||||
x = int((ix * 127.9)/width);
|
||||
@@ -588,6 +591,8 @@ void MyFrame::OnProsody(wxCommandEvent& WXUNUSED(event))
|
||||
// Open the Prosody display window
|
||||
// Make another frame, containing a canvas
|
||||
|
||||
int h, w, w2;
|
||||
|
||||
if(prosodyframe != NULL)
|
||||
{
|
||||
// The Prosody window is already open
|
||||
@@ -595,8 +600,10 @@ void MyFrame::OnProsody(wxCommandEvent& WXUNUSED(event))
|
||||
return;
|
||||
}
|
||||
|
||||
m_leftWindow->GetSize(&w2, &h);
|
||||
GetClientSize(&w, &h);
|
||||
prosodyframe = new ChildFrProsody(myframe, _T(""),
|
||||
wxPoint(10, 200), wxSize(1000, 300),
|
||||
wxPoint(0, 100), wxSize(w-w2, 420),
|
||||
wxDEFAULT_FRAME_STYLE |
|
||||
wxNO_FULL_REPAINT_ON_RESIZE);
|
||||
|
||||
@@ -606,7 +613,7 @@ void MyFrame::OnProsody(wxCommandEvent& WXUNUSED(event))
|
||||
prosodyframe->CreateStatusBar();
|
||||
|
||||
int width, height;
|
||||
wxMDIClientWindow *clientwin = this->GetClientWindow();
|
||||
wxMDIClientWindow *clientwin = (wxMDIClientWindow *)this->GetClientWindow();
|
||||
clientwin->GetClientSize(&width, &height);
|
||||
|
||||
#ifdef deleted
|
||||
@@ -619,7 +626,7 @@ void MyFrame::OnProsody(wxCommandEvent& WXUNUSED(event))
|
||||
prosodycanvas = canvas;
|
||||
|
||||
// Associate the menu bar with the frame
|
||||
prosodyframe->SetMenuBar(MakeMenu(2));
|
||||
prosodyframe->SetMenuBar(MakeMenu(2,translator->dictionary_name));
|
||||
prosodyframe->prosodycanvas = canvas;
|
||||
prosodyframe->Show(TRUE);
|
||||
|
||||
|
||||
+11
-15
@@ -121,17 +121,17 @@ static const unsigned int punct_attributes [] = { 0,
|
||||
CLAUSE_COMMA, CLAUSE_PERIOD, CLAUSE_QUESTION, CLAUSE_EXCLAMATION, CLAUSE_COLON, CLAUSE_SEMICOLON,
|
||||
CLAUSE_SEMICOLON, // en-dash
|
||||
CLAUSE_SEMICOLON, // em-dash
|
||||
CLAUSE_SEMICOLON + PUNCT_SAY_NAME | 0x8000, // elipsis
|
||||
CLAUSE_SEMICOLON | PUNCT_SAY_NAME | 0x8000, // elipsis
|
||||
|
||||
CLAUSE_QUESTION, // Greek question mark
|
||||
CLAUSE_SEMICOLON, // Greek semicolon
|
||||
CLAUSE_PERIOD+0x8000, // Devanagari Danda (fullstop)
|
||||
CLAUSE_PERIOD | 0x8000, // Devanagari Danda (fullstop)
|
||||
|
||||
CLAUSE_PERIOD+0x8000, // Armenian period
|
||||
CLAUSE_PERIOD | 0x8000, // Armenian period
|
||||
CLAUSE_COMMA, // Armenian comma
|
||||
CLAUSE_EXCLAMATION + PUNCT_IN_WORD, // Armenian exclamation
|
||||
CLAUSE_QUESTION + PUNCT_IN_WORD, // Armenian question
|
||||
CLAUSE_PERIOD + PUNCT_IN_WORD, // Armenian emphasis mark
|
||||
CLAUSE_EXCLAMATION | PUNCT_IN_WORD, // Armenian exclamation
|
||||
CLAUSE_QUESTION | PUNCT_IN_WORD, // Armenian question
|
||||
CLAUSE_PERIOD | PUNCT_IN_WORD, // Armenian emphasis mark
|
||||
|
||||
CLAUSE_SEMICOLON, // Arabic ;
|
||||
CLAUSE_QUESTION, // Arabic question mark
|
||||
@@ -1995,8 +1995,8 @@ static MNEM_TAB xml_char_mnemonics[] = {
|
||||
{NULL,-1}};
|
||||
|
||||
|
||||
int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type)
|
||||
{//=============================================================================================================
|
||||
int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change)
|
||||
{//=================================================================================================================================
|
||||
/* Find the end of the current clause.
|
||||
Write the clause into buf
|
||||
|
||||
@@ -2051,6 +2051,7 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
tr->clause_lower_count = 0;
|
||||
end_of_input = 0;
|
||||
*tone_type = 0;
|
||||
*voice_change = 0;
|
||||
|
||||
f_input = f_in; // for GetC etc
|
||||
|
||||
@@ -2218,16 +2219,11 @@ f_input = f_in; // for GetC etc
|
||||
|
||||
if(terminator & CLAUSE_BIT_VOICE)
|
||||
{
|
||||
// a change in voice, write the new voice name to the end of the buf
|
||||
p = current_voice_id;
|
||||
while((*p != 0) && (ix < (n_buf-1)))
|
||||
{
|
||||
buf[ix++] = *p++;
|
||||
}
|
||||
buf[ix++] = 0;
|
||||
strcpy(voice_change, current_voice_id);
|
||||
}
|
||||
return(terminator);
|
||||
}
|
||||
c1 = ' ';
|
||||
c2 = GetC();
|
||||
continue;
|
||||
}
|
||||
|
||||
+10
-4
@@ -360,14 +360,14 @@ void SetParameter(int parameter, int value, int relative)
|
||||
|
||||
|
||||
|
||||
static void DoEmbedded2(int &embix)
|
||||
static void DoEmbedded2(int *embix)
|
||||
{//================================
|
||||
// There were embedded commands in the text at this point
|
||||
|
||||
unsigned int word;
|
||||
|
||||
do {
|
||||
word = embedded_list[embix++];
|
||||
word = embedded_list[(*embix)++];
|
||||
|
||||
if((word & 0x1f) == EMBED_S)
|
||||
{
|
||||
@@ -420,7 +420,7 @@ void CalcLengths(Translator *tr)
|
||||
|
||||
if(p->synthflags & SFLAG_EMBEDDED)
|
||||
{
|
||||
DoEmbedded2(embedded_ix);
|
||||
DoEmbedded2(&embedded_ix);
|
||||
}
|
||||
|
||||
type = p->type;
|
||||
@@ -734,6 +734,12 @@ if(p->type != phVOWEL)
|
||||
}
|
||||
p->length = length_mod;
|
||||
|
||||
if(p->env >= (N_ENVELOPE_DATA-1))
|
||||
{
|
||||
fprintf(stderr,"espeak: Bad intonation data\n");
|
||||
p->env = 0;
|
||||
}
|
||||
|
||||
// pre-vocalic part
|
||||
// set last-pitch
|
||||
env2 = p->env + 1; // version for use with preceding semi-vowel
|
||||
@@ -741,7 +747,7 @@ if(p->type != phVOWEL)
|
||||
if(p->tone_ph != 0)
|
||||
{
|
||||
InterpretPhoneme2(p->tone_ph, &phdata_tone);
|
||||
pitch_env = LookupEnvelope(phdata_tone.pitch_env);
|
||||
pitch_env = GetEnvelope(phdata_tone.pitch_env);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+17
-12
@@ -75,44 +75,44 @@ static const char *help_text =
|
||||
"\t Amplitude, 0 to 200, default is 100\n"
|
||||
"-g <integer>\n"
|
||||
"\t Word gap. Pause between words, units of 10mS at the default speed\n"
|
||||
"-k <integer>\n"
|
||||
"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
|
||||
"\t higher values indicate a pitch increase (try -k20).\n"
|
||||
"-l <integer>\n"
|
||||
"\t Line length. If not zero (which is the default), consider\n"
|
||||
"\t lines less than this length as end-of-clause\n"
|
||||
"-p <integer>\n"
|
||||
"\t Pitch adjustment, 0 to 99, default is 50\n"
|
||||
"-s <integer>\n"
|
||||
"\t Speed in words per minute 80 to 450, default is 175\n"
|
||||
"\t Speed in words per minute, 80 to 450, default is 175\n"
|
||||
"-v <voice name>\n"
|
||||
"\t Use voice file of this name from espeak-data/voices\n"
|
||||
"-w <wave file name>\n"
|
||||
"\t Write output to this WAV file, rather than speaking it directly\n"
|
||||
"\t Write speech to this WAV file, rather than speaking it directly\n"
|
||||
"-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n"
|
||||
"-m\t Interpret SSML markup, and ignore other < > tags\n"
|
||||
"-q\t Quiet, don't produce any speech (may be useful with -x)\n"
|
||||
"-x\t Write phoneme mnemonics to stdout\n"
|
||||
"-X\t Write phonemes mnemonics and translation trace to stdout\n"
|
||||
"-z\t No final sentence pause at the end of the text\n"
|
||||
"--stdout Write speech output to stdout\n"
|
||||
"--compile=<voice name>\n"
|
||||
"\t Compile the pronunciation rules and dictionary in the current\n"
|
||||
"\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"
|
||||
"--path=\"<path>\"\n"
|
||||
"\t Specifies the directory containing the espeak-data directory\n"
|
||||
"--pho\n"
|
||||
"\t Write mbrola phoneme data (.pho) to stdout, or to the file in --phonout\n"
|
||||
"--pho Write mbrola phoneme data (.pho) to stdout or to the file in --phonout\n"
|
||||
"--phonout=\"<filename>\"\n"
|
||||
"\t Write phoneme output from -x -X and --pho to this file\n"
|
||||
"\t Write phoneme output from -x -X --ipa and --pho to this file\n"
|
||||
"--punct=\"<characters>\"\n"
|
||||
"\t Speak the names of punctuation characters during speaking. If\n"
|
||||
"\t =<characters> is omitted, all punctuation is spoken.\n"
|
||||
"--split=\"<minutes>\"\n"
|
||||
"\t Starts a new WAV file every <minutes>. Used with -w\n"
|
||||
"--stdout Write speech output to stdout\n"
|
||||
"--voices=<language>\n"
|
||||
"\t List the available voices for the specified language.\n"
|
||||
"\t If <language> is omitted, then list all voices.\n"
|
||||
"-k <integer>\n"
|
||||
"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
|
||||
"\t higher values indicate a pitch increase (try -k20).\n";
|
||||
"\t If <language> is omitted, then list all voices.\n";
|
||||
|
||||
|
||||
void DisplayVoices(FILE *f_out, char *language);
|
||||
@@ -478,6 +478,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},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -708,7 +709,11 @@ int main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 0x109: // --pho
|
||||
option_mbrola_phonemes = 8;
|
||||
option_mbrola_phonemes = 16;
|
||||
break;
|
||||
|
||||
case 0x10a: // --ipa
|
||||
option_phonemes = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+7
-5
@@ -1120,13 +1120,15 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream)
|
||||
{//============================================================
|
||||
ENTER("espeak_SetPhonemes");
|
||||
/* Controls the output of phoneme symbols for the text
|
||||
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)
|
||||
bit 3: produce mbrola pho data
|
||||
bits 0-3:
|
||||
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
|
||||
bit 4: produce mbrola pho data
|
||||
*/
|
||||
option_phonemes = value & 3;
|
||||
option_mbrola_phonemes = value & 8;
|
||||
option_mbrola_phonemes = value & 16;
|
||||
f_trans = stream;
|
||||
if(stream == NULL)
|
||||
f_trans = stderr;
|
||||
|
||||
@@ -444,6 +444,7 @@ 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 rather than ascii phoneme names
|
||||
|
||||
stream output stream for the phoneme symbols (and trace). If stream=NULL then it uses stdout.
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "phoneme.h"
|
||||
#include "synthesize.h"
|
||||
#include "voice.h"
|
||||
#include "translate.h"
|
||||
#include "spect.h"
|
||||
#include "options.h"
|
||||
|
||||
@@ -981,6 +982,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
|
||||
SpectSeq *spectseq;
|
||||
wxString leaf;
|
||||
wxString pathload;
|
||||
int width, height;
|
||||
|
||||
if(event.GetId() == MENU_SPECTRUM)
|
||||
pathload = path_spectload;
|
||||
@@ -1021,10 +1023,11 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
|
||||
else
|
||||
path_spectload2 = path.GetPath();
|
||||
|
||||
// Make another frame, containing a canvas
|
||||
// Make another frame, containing a canvas
|
||||
GetClientSize(&width, &height);
|
||||
MyChild *subframe = new MyChild(myframe, _T("Spectrum"),
|
||||
wxPoint(10, 10), wxSize(300, 300),
|
||||
wxDEFAULT_FRAME_STYLE | wxMAXIMIZE |
|
||||
wxPoint(10, 0), wxSize(500, height),
|
||||
wxDEFAULT_FRAME_STYLE |
|
||||
wxNO_FULL_REPAINT_ON_RESIZE);
|
||||
|
||||
subframe->SetTitle(leaf);
|
||||
@@ -1032,14 +1035,13 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
|
||||
// Give it a status line
|
||||
subframe->CreateStatusBar();
|
||||
|
||||
int width, height;
|
||||
subframe->GetClientSize(&width, &height);
|
||||
SpectDisplay *canvas = new SpectDisplay(subframe, wxPoint(0, 0), wxSize(width, height), spectseq);
|
||||
canvas->savepath = filename;
|
||||
currentcanvas = canvas;
|
||||
|
||||
// Associate the menu bar with the frame
|
||||
subframe->SetMenuBar(MakeMenu(1));
|
||||
subframe->SetMenuBar(MakeMenu(1,translator->dictionary_name));
|
||||
subframe->canvas = canvas;
|
||||
subframe->Show(TRUE);
|
||||
|
||||
|
||||
+19
-22
@@ -73,7 +73,7 @@ BOOL load_MBR()
|
||||
if(hinstDllMBR != NULL)
|
||||
return TRUE; // already loaded
|
||||
|
||||
if (!(hinstDllMBR=LoadLibraryA("mbrola.dll")))
|
||||
if ((hinstDllMBR=LoadLibraryA("mbrola.dll")) == 0)
|
||||
return FALSE;
|
||||
init_MBR =(PROCIC) GetProcAddress(hinstDllMBR,"init_MBR");
|
||||
write_MBR =(PROCIC) GetProcAddress(hinstDllMBR,"write_MBR");
|
||||
@@ -386,7 +386,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
int done;
|
||||
int len_percent;
|
||||
const char *final_pitch;
|
||||
char buf[80];
|
||||
char *ptr;
|
||||
char mbr_buf[120];
|
||||
|
||||
static int phix;
|
||||
@@ -404,7 +404,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
if (WcmdqFree() < MIN_WCMDQ)
|
||||
return 1;
|
||||
|
||||
mbr_buf[0] = 0;
|
||||
ptr = mbr_buf;
|
||||
|
||||
p = &plist[phix];
|
||||
next = &plist[phix+1];
|
||||
@@ -415,7 +415,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
|
||||
if(p->synthflags & SFLAG_EMBEDDED)
|
||||
{
|
||||
DoEmbedded(embedded_ix, p->sourceix);
|
||||
DoEmbedded(&embedded_ix, p->sourceix);
|
||||
}
|
||||
|
||||
if(p->newword & 4)
|
||||
@@ -446,13 +446,12 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
|
||||
DoMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, ph->mnemonic);
|
||||
|
||||
sprintf(buf,"%s\t",WordToString(name));
|
||||
strcat(mbr_buf,buf);
|
||||
ptr += sprintf(ptr,"%s\t",WordToString(name));
|
||||
|
||||
if(name2 == '_')
|
||||
{
|
||||
// add a pause after this phoneme
|
||||
pause = PauseLength(len_percent,0);
|
||||
pause = len_percent;
|
||||
name2 = 0;
|
||||
}
|
||||
|
||||
@@ -472,17 +471,19 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
|
||||
if(name2 == 0)
|
||||
{
|
||||
sprintf(buf,"%d\t%s", len, WritePitch(p->env,p->pitch1,p->pitch2,0,0));
|
||||
strcat(mbr_buf,buf);
|
||||
char *pitch = WritePitch(p->env,p->pitch1,p->pitch2,0,0);
|
||||
ptr += sprintf(ptr,"%d\t%s", len, pitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
len1 = (len * len_percent)/100;
|
||||
sprintf(buf,"%d\t%s", len1, WritePitch(p->env,p->pitch1,p->pitch2,len_percent,0));
|
||||
strcat(mbr_buf,buf);
|
||||
char *pitch;
|
||||
|
||||
sprintf(buf,"%s\t%d\t%s", WordToString(name2), len-len1, WritePitch(p->env,p->pitch1,p->pitch2,-len_percent,0));
|
||||
strcat(mbr_buf,buf);
|
||||
pitch = WritePitch(p->env,p->pitch1,p->pitch2,len_percent,0);
|
||||
len1 = (len * len_percent)/100;
|
||||
ptr += sprintf(ptr,"%d\t%s", len1, pitch);
|
||||
|
||||
pitch = WritePitch(p->env,p->pitch1,p->pitch2,-len_percent,0);
|
||||
ptr += sprintf(ptr,"%s\t%d\t%s", WordToString(name2), len-len1, pitch);
|
||||
}
|
||||
done = 1;
|
||||
break;
|
||||
@@ -521,7 +522,6 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
memset(&fmtp, 0, sizeof(fmtp));
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
len = DoSpect2(p->ph, 0, &fmtp, p, -1);
|
||||
// len = DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,-1);
|
||||
len = (len * 1000)/samplerate;
|
||||
@@ -545,25 +545,22 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
if(name2 != 0)
|
||||
{
|
||||
len1 = (len * len_percent)/100;
|
||||
sprintf(buf,"%d\n%s\t",len1,WordToString(name2));
|
||||
strcat(mbr_buf,buf);
|
||||
ptr += sprintf(ptr,"%d\n%s\t",len1,WordToString(name2));
|
||||
len -= len1;
|
||||
}
|
||||
sprintf(buf,"%d%s\n",len,final_pitch);
|
||||
strcat(mbr_buf,buf);
|
||||
ptr += sprintf(ptr,"%d%s\n",len,final_pitch);
|
||||
}
|
||||
|
||||
if(pause)
|
||||
{
|
||||
len += PauseLength(pause,0);
|
||||
sprintf(buf,"_ \t%d\n",PauseLength(pause,0));
|
||||
strcat(mbr_buf,buf);
|
||||
ptr += sprintf(ptr,"_ \t%d\n",PauseLength(pause,0));
|
||||
pause = 0;
|
||||
}
|
||||
|
||||
if(f_mbrola)
|
||||
{
|
||||
fwrite(mbr_buf,1,strlen(mbr_buf),f_mbrola); // write .pho to a file
|
||||
fwrite(mbr_buf,1,(ptr-mbr_buf),f_mbrola); // write .pho to a file
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+36
-18
@@ -35,8 +35,8 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.43.48 28.Jun.10";
|
||||
const int version_phdata = 0x014342;
|
||||
const char *version_string = "1.43.63 02.Aug.10";
|
||||
const int version_phdata = 0x014361;
|
||||
|
||||
int option_device_number = -1;
|
||||
FILE *f_logespeak = NULL;
|
||||
@@ -49,7 +49,7 @@ PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
|
||||
unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited
|
||||
|
||||
USHORT *phoneme_index=NULL;
|
||||
char *spects_data=NULL;
|
||||
char *phondata_ptr=NULL;
|
||||
unsigned char *wavefile_data=NULL;
|
||||
static unsigned char *phoneme_tab_data = NULL;
|
||||
|
||||
@@ -116,16 +116,17 @@ int LoadPhData()
|
||||
int result = 1;
|
||||
int length;
|
||||
unsigned char *p;
|
||||
int *pw;
|
||||
|
||||
if((phoneme_tab_data = (unsigned char *)ReadPhFile((void *)(phoneme_tab_data),"phontab",NULL)) == NULL)
|
||||
return(-1);
|
||||
if((phoneme_index = (USHORT *)ReadPhFile((void *)(phoneme_index),"phonindex",NULL)) == NULL)
|
||||
return(-1);
|
||||
if((spects_data = ReadPhFile((void *)(spects_data),"phondata",NULL)) == NULL)
|
||||
if((phondata_ptr = ReadPhFile((void *)(phondata_ptr),"phondata",NULL)) == NULL)
|
||||
return(-1);
|
||||
if((tunes = (TUNE *)ReadPhFile((void *)(tunes),"intonations",&length)) == NULL)
|
||||
return(-1);
|
||||
wavefile_data = (unsigned char *)spects_data;
|
||||
wavefile_data = (unsigned char *)phondata_ptr;
|
||||
n_tunes = length / sizeof(TUNE);
|
||||
|
||||
// read the version number from the first 4 bytes of phondata
|
||||
@@ -150,7 +151,9 @@ int LoadPhData()
|
||||
n_phonemes = p[0];
|
||||
phoneme_tab_list[ix].n_phonemes = p[0];
|
||||
phoneme_tab_list[ix].includes = p[1];
|
||||
p += 4;
|
||||
pw = (int *)p;
|
||||
phoneme_tab_list[ix].equivalence_tables = Reverse4Bytes(pw[1]);
|
||||
p += 8;
|
||||
memcpy(phoneme_tab_list[ix].name,p,N_PHONEME_TAB_NAME);
|
||||
p += N_PHONEME_TAB_NAME;
|
||||
phoneme_tab_list[ix].phoneme_tab_ptr = (PHONEME_TAB *)p;
|
||||
@@ -168,10 +171,10 @@ void FreePhData(void)
|
||||
{//==================
|
||||
Free(phoneme_tab_data);
|
||||
Free(phoneme_index);
|
||||
Free(spects_data);
|
||||
Free(phondata_ptr);
|
||||
phoneme_tab_data=NULL;
|
||||
phoneme_index=NULL;
|
||||
spects_data=NULL;
|
||||
phondata_ptr=NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +229,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
frame_t *frame;
|
||||
static frameref_t frames_buf[N_SEQ_FRAMES];
|
||||
|
||||
seq = (SPECT_SEQ *)(&spects_data[fmt_params->fmt_addr]);
|
||||
seq = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt_addr]);
|
||||
seqk = (SPECT_SEQK *)seq;
|
||||
nf = seq->n_frames;
|
||||
|
||||
@@ -279,7 +282,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
{
|
||||
// a secondary reference has been returned, which is not a wavefile
|
||||
// add these spectra to the main sequence
|
||||
seq2 = (SPECT_SEQ *)(&spects_data[fmt_params->fmt2_addr]);
|
||||
seq2 = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt2_addr]);
|
||||
seqk2 = (SPECT_SEQK *)seq2;
|
||||
|
||||
// first frame of the addition just sets the length of the last frame of the main seq
|
||||
@@ -364,11 +367,14 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
|
||||
|
||||
|
||||
unsigned char *LookupEnvelope(int ix)
|
||||
{//================================
|
||||
if(ix==0)
|
||||
return(NULL);
|
||||
return((unsigned char *)&spects_data[ix]);
|
||||
unsigned char *GetEnvelope(int index)
|
||||
{//==================================
|
||||
if(index==0)
|
||||
{
|
||||
fprintf(stderr,"espeak: No envelope\n");
|
||||
return(envelope_data[0]); // not found, use a default envelope
|
||||
}
|
||||
return((unsigned char *)&phondata_ptr[index]);
|
||||
}
|
||||
|
||||
|
||||
@@ -877,6 +883,18 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
phdata->pd_param[i_APPEND_PHONEME] = data;
|
||||
}
|
||||
else
|
||||
if(instn2 == i_IPA_NAME)
|
||||
{
|
||||
// followed by utf-8 characters, 2 per instn word
|
||||
for(ix=0; (ix < data) && (ix < 16); ix += 2)
|
||||
{
|
||||
prog++;
|
||||
phdata->ipa_string[ix] = prog[0] >> 8;
|
||||
phdata->ipa_string[ix+1] = prog[0] & 0xff;
|
||||
}
|
||||
phdata->ipa_string[ix] = 0;
|
||||
}
|
||||
else
|
||||
if(instn2 < N_PHONEME_DATA_PARAM)
|
||||
{
|
||||
if(instn2 == i_CHANGE_PHONEME2)
|
||||
@@ -1026,15 +1044,15 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
}
|
||||
}
|
||||
else
|
||||
if(instn2 == 4)
|
||||
if(instn2 ==pd_ADDWAV)
|
||||
{
|
||||
// addWav(), return if previous instruction was FMT() or WAV()
|
||||
end_flag--;
|
||||
}
|
||||
|
||||
if((instn2 != 1) && (instn2 != 4))
|
||||
if((instn2 == pd_VWLSTART) || (instn2 == pd_VWLEND))
|
||||
{
|
||||
// FMT, VowelStart or VowelEnding.
|
||||
// VowelStart or VowelEnding.
|
||||
phdata->sound_param[instn2] = param_sc; // sign extend
|
||||
}
|
||||
}
|
||||
|
||||
+59
-24
@@ -54,6 +54,7 @@ static int last_wcmdq;
|
||||
static int pitch_length;
|
||||
static int amp_length;
|
||||
static int modn_flags;
|
||||
static int fmt_amplitude=0;
|
||||
|
||||
static int syllable_start;
|
||||
static int syllable_end;
|
||||
@@ -223,6 +224,13 @@ static void DoPause(int length, int control)
|
||||
wcmdq[wcmdq_tail][1] = len;
|
||||
WcmdqInc();
|
||||
last_frame = NULL;
|
||||
|
||||
if(fmt_amplitude != 0)
|
||||
{
|
||||
wcmdq[wcmdq_tail][0] = WCMD_FMT_AMPLITUDE;
|
||||
wcmdq[wcmdq_tail][1] = fmt_amplitude = 0;
|
||||
WcmdqInc();
|
||||
}
|
||||
} // end of DoPause
|
||||
|
||||
|
||||
@@ -246,6 +254,9 @@ static int DoSample2(int index, int which, int std_length, int control, int leng
|
||||
wav_length = (p[1] * 256);
|
||||
wav_length += p[0]; // length in bytes
|
||||
|
||||
if(wav_length == 0)
|
||||
return(0);
|
||||
|
||||
min_length = speed.min_sample_len;
|
||||
|
||||
if(wav_scale==0)
|
||||
@@ -972,7 +983,7 @@ static void StartSyllable(void)
|
||||
|
||||
int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation)
|
||||
{//========================================================================================================
|
||||
// which 0 not a vowel, 1 start of vowel, 2 body and end of vowel
|
||||
// which: 0 not a vowel, 1 start of vowel, 2 body and end of vowel
|
||||
// length_mod: 256 = 100%
|
||||
// modulation: -1 = don't write to wcmdq
|
||||
|
||||
@@ -1025,6 +1036,15 @@ if(which==1)
|
||||
if(frames == NULL)
|
||||
return(0); // not found
|
||||
|
||||
if(fmt_params->fmt_amp != fmt_amplitude)
|
||||
{
|
||||
// an amplitude adjustment is specified for this sequence
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_FMT_AMPLITUDE;
|
||||
q[1] = fmt_amplitude = fmt_params->fmt_amp;
|
||||
WcmdqInc();
|
||||
}
|
||||
|
||||
frame1 = frames[0].frame;
|
||||
if(voice->klattv[0])
|
||||
wcmd_spect = WCMD_KLATT;
|
||||
@@ -1166,6 +1186,16 @@ if(which==1)
|
||||
total_len += len;
|
||||
}
|
||||
}
|
||||
|
||||
if((which != 1) && (fmt_amplitude != 0))
|
||||
{
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_FMT_AMPLITUDE;
|
||||
q[1] = fmt_amplitude = 0;
|
||||
WcmdqInc();
|
||||
}
|
||||
|
||||
|
||||
return(total_len);
|
||||
} // end of DoSpect
|
||||
|
||||
@@ -1198,7 +1228,7 @@ void DoVoiceChange(voice_t *v)
|
||||
}
|
||||
|
||||
|
||||
void DoEmbedded(int &embix, int sourceix)
|
||||
void DoEmbedded(int *embix, int sourceix)
|
||||
{//======================================
|
||||
// There were embedded commands in the text at this point
|
||||
unsigned int word; // bit 7=last command for this word, bits 5,6 sign, bits 0-4 command
|
||||
@@ -1206,7 +1236,7 @@ void DoEmbedded(int &embix, int sourceix)
|
||||
int command;
|
||||
|
||||
do {
|
||||
word = embedded_list[embix++];
|
||||
word = embedded_list[(*embix)++];
|
||||
value = word >> 8;
|
||||
command = word & 0x7f;
|
||||
|
||||
@@ -1323,7 +1353,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
|
||||
if(p->synthflags & SFLAG_EMBEDDED)
|
||||
{
|
||||
DoEmbedded(embedded_ix, p->sourceix);
|
||||
DoEmbedded(&embedded_ix, p->sourceix);
|
||||
}
|
||||
|
||||
if(p->newword)
|
||||
@@ -1429,7 +1459,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
// a period of voicing before the release
|
||||
InterpretPhoneme(NULL, 0x01, p, &phdata);
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
|
||||
DoSpect2(ph, 0, &fmtp, p, 0);
|
||||
if(p->synthflags & SFLAG_LENGTHEN)
|
||||
@@ -1457,7 +1487,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
}
|
||||
InterpretPhoneme(NULL,0, p, &phdata);
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
fmtp.wav_addr = phdata.sound_addr[pd_ADDWAV];
|
||||
fmtp.wav_amp = phdata.sound_param[pd_ADDWAV];
|
||||
DoSpect2(ph, 0, &fmtp, p, 0);
|
||||
@@ -1504,7 +1534,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
memset(&fmtp, 0, sizeof(fmtp));
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
fmtp.wav_addr = phdata.sound_addr[pd_ADDWAV];
|
||||
fmtp.wav_amp = phdata.sound_param[pd_ADDWAV];
|
||||
|
||||
@@ -1529,7 +1559,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
InterpretPhoneme(NULL,0, p, &phdata);
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
|
||||
if(next->type==phVOWEL)
|
||||
{
|
||||
@@ -1578,7 +1608,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
fmtp.wav_addr = phdata.sound_addr[pd_ADDWAV];
|
||||
fmtp.wav_amp = phdata.sound_param[pd_ADDWAV];
|
||||
DoSpect2(p->ph, 0, &fmtp, p, modulation);
|
||||
@@ -1619,16 +1649,18 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
fmtp.use_vowelin = 1;
|
||||
fmtp.fmt_control = 1;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
// fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
}
|
||||
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
|
||||
pitch_env = envelope_data[p->env];
|
||||
amp_env = NULL;
|
||||
if(p->tone_ph != 0)
|
||||
{
|
||||
InterpretPhoneme2(p->tone_ph, &phdata_tone);
|
||||
pitch_env = LookupEnvelope(phdata_tone.pitch_env);
|
||||
amp_env = LookupEnvelope(phdata_tone.amp_env);
|
||||
pitch_env = GetEnvelope(phdata_tone.pitch_env);
|
||||
if(phdata_tone.amp_env > 0)
|
||||
amp_env = GetEnvelope(phdata_tone.amp_env);
|
||||
}
|
||||
|
||||
StartSyllable();
|
||||
@@ -1670,7 +1702,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
}
|
||||
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_length = phdata.sound_param[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
fmtp.transition0 = 0;
|
||||
fmtp.transition1 = 0;
|
||||
|
||||
@@ -1848,20 +1880,23 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
|
||||
CalcPitches(translator, clause_tone);
|
||||
CalcLengths(translator);
|
||||
|
||||
GetTranslatedPhonemeString(translator->phon_out,sizeof(translator->phon_out));
|
||||
if(option_phonemes > 0)
|
||||
if((option_phonemes > 0) || (phoneme_callback != NULL))
|
||||
{
|
||||
fprintf(f_trans,"%s\n",translator->phon_out);
|
||||
|
||||
if(!iswalpha(0x010d))
|
||||
GetTranslatedPhonemeString(translator->phon_out,sizeof(translator->phon_out));
|
||||
if(option_phonemes > 0)
|
||||
{
|
||||
// check that c-caron is recognized as an alphabetic character
|
||||
fprintf(stderr,"Warning: Accented letters are not recognized, eg: U+010D\nSet LC_CTYPE to a UTF-8 locale\n");
|
||||
fprintf(f_trans,"%s\n",translator->phon_out);
|
||||
|
||||
if(!iswalpha(0x010d))
|
||||
{
|
||||
// check that c-caron is recognized as an alphabetic character
|
||||
fprintf(stderr,"Warning: Accented letters are not recognized, eg: U+010D\nSet LC_CTYPE to a UTF-8 locale\n");
|
||||
}
|
||||
}
|
||||
if(phoneme_callback != NULL)
|
||||
{
|
||||
phoneme_callback(translator->phon_out);
|
||||
}
|
||||
}
|
||||
if(phoneme_callback != NULL)
|
||||
{
|
||||
phoneme_callback(translator->phon_out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+13
-3
@@ -177,6 +177,7 @@ int mix_wavefile_offset;
|
||||
|
||||
int amplitude;
|
||||
int amplitude_v;
|
||||
int amplitude_fmt; // percentage amplitude adjustment for formant synthesis
|
||||
} WGEN_DATA;
|
||||
|
||||
|
||||
@@ -266,6 +267,7 @@ typedef struct {
|
||||
int vowel_transition[4];
|
||||
int pitch_env;
|
||||
int amp_env;
|
||||
char ipa_string[18];
|
||||
} PHONEME_DATA;
|
||||
|
||||
|
||||
@@ -274,6 +276,7 @@ typedef struct {
|
||||
int use_vowelin;
|
||||
int fmt_addr;
|
||||
int fmt_length;
|
||||
int fmt_amp;
|
||||
int fmt2_addr;
|
||||
int fmt2_lenadj;
|
||||
int wav_addr;
|
||||
@@ -289,7 +292,7 @@ typedef struct {
|
||||
#define i_RETURN 0x0001
|
||||
#define i_CONTINUE 0x0002
|
||||
|
||||
// Group 0 instrcutions with 8 bit operand. These value go into bits 8-15 if the instruction
|
||||
// Group 0 instrcutions with 8 bit operand. These values go into bits 8-15 of the instruction
|
||||
#define i_CHANGE_PHONEME 0x01
|
||||
#define i_REPLACE_NEXT_PHONEME 0x02
|
||||
#define i_INSERT_PHONEME 0x03
|
||||
@@ -302,6 +305,8 @@ typedef struct {
|
||||
#define i_SET_LENGTH 0x0a
|
||||
#define i_LONG_LENGTH 0x0b
|
||||
#define i_CHANGE_PHONEME2 0x0c // not yet used
|
||||
#define i_IPA_NAME 0x0d
|
||||
|
||||
#define i_CHANGE_IF 0x10 // 0x10 to 0x14
|
||||
|
||||
#define i_ADD_LENGTH 0x0c
|
||||
@@ -463,6 +468,8 @@ extern unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1];
|
||||
#define WCMD_VOICE 11
|
||||
#define WCMD_EMBEDDED 12
|
||||
#define WCMD_MBROLA_DATA 13
|
||||
#define WCMD_FMT_AMPLITUDE 14
|
||||
|
||||
|
||||
|
||||
#define N_WCMDQ 160
|
||||
@@ -526,13 +533,15 @@ int SelectPhonemeTableName(const char *name);
|
||||
|
||||
void Write4Bytes(FILE *f, int value);
|
||||
int Read4Bytes(FILE *f);
|
||||
int Reverse4Bytes(int word);
|
||||
int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, char *err_name,int flags);
|
||||
|
||||
|
||||
#define ENV_LEN 128 // length of pitch envelopes
|
||||
#define PITCHfall 0 // standard pitch envelopes
|
||||
#define PITCHrise 2
|
||||
extern unsigned char *envelope_data[20];
|
||||
#define N_ENVELOPE_DATA 20
|
||||
extern unsigned char *envelope_data[N_ENVELOPE_DATA];
|
||||
|
||||
extern int formant_rate[]; // max rate of change of each formant
|
||||
extern SPEED_FACTORS speed;
|
||||
@@ -562,13 +571,14 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume);
|
||||
int MbrolaFill(int length, int resume);
|
||||
void MbrolaReset(void);
|
||||
void DoEmbedded(int &embix, int sourceix);
|
||||
void DoEmbedded(int *embix, int sourceix);
|
||||
void DoMarker(int type, int char_posn, int length, int value);
|
||||
//int DoSample(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int length_mod, int amp);
|
||||
int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp);
|
||||
int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation);
|
||||
int PauseLength(int pause, int control);
|
||||
int LookupPhonemeTable(const char *name);
|
||||
unsigned char *GetEnvelope(int index);
|
||||
|
||||
void InitBreath(void);
|
||||
|
||||
|
||||
+34
-18
@@ -60,8 +60,6 @@ static void Translator_Russian(Translator *tr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void SetLetterVowel(Translator *tr, int c)
|
||||
{//==============================================
|
||||
tr->letter_bits[c] = (tr->letter_bits[c] & 0x40) | 0x81; // keep value for group 6 (front vowels e,i,y)
|
||||
@@ -132,7 +130,7 @@ static Translator* NewTranslator(void)
|
||||
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
|
||||
memset(tr->letter_groups,0,sizeof(tr->letter_groups));
|
||||
|
||||
// 0-5 sets of characters matched by A B C E F G in pronunciation rules
|
||||
// 0-5 sets of characters matched by A B C H F G Y in pronunciation rules
|
||||
// these may be set differently for different languages
|
||||
SetLetterBits(tr,0,"aeiou"); // A vowels, except y
|
||||
SetLetterBits(tr,1,"bcdfgjklmnpqstvxz"); // B hard consonants, excluding h,r,w
|
||||
@@ -418,7 +416,7 @@ Translator *SelectTranslator(const char *name)
|
||||
|
||||
case L('d','a'): // Danish
|
||||
{
|
||||
static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,210};
|
||||
static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,230};
|
||||
SetupTranslator(tr,stress_lengths_da,NULL);
|
||||
|
||||
tr->transpose_min = 'a';
|
||||
@@ -426,7 +424,7 @@ Translator *SelectTranslator(const char *name)
|
||||
|
||||
tr->langopts.stress_rule = STRESSPOSN_1L;
|
||||
SetLetterVowel(tr,'y');
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -442,8 +440,9 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 175/2;
|
||||
memcpy(tr->stress_lengths,stress_lengths_de,sizeof(tr->stress_lengths));
|
||||
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
|
||||
SetLetterVowel(tr,'y');
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use de_rules for unpronouncable rules
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -460,6 +459,8 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.numbers = NUM_HUNDRED_AND | NUM_ROMAN | NUM_1900;
|
||||
tr->langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
|
||||
tr->langopts.suffix_add_e = 'e';
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use en_rules for unpronouncable rules
|
||||
SetLetterBits(tr,6,"aeiouy"); // Group Y: vowels, including y
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -549,7 +550,7 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.unstressed_wd2 = 2;
|
||||
tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
|
||||
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_ROMAN | NUM_ROMAN_AFTER;
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_AFTER;
|
||||
|
||||
if(name2 == L('c','a'))
|
||||
{
|
||||
@@ -561,6 +562,10 @@ Translator *SelectTranslator(const char *name)
|
||||
{
|
||||
tr->langopts.stress_flags = 0x100 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
|
||||
}
|
||||
else
|
||||
{
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use es_rules for unpronouncable rules
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -605,18 +610,20 @@ Translator *SelectTranslator(const char *name)
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case L('f','r'): // french
|
||||
{
|
||||
static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 235, 240};
|
||||
static const unsigned char stress_amps_fr[8] = {18,16, 20,20, 20,22, 22,21 };
|
||||
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, 20,20, 20,22, 18,18 };
|
||||
|
||||
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.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.
|
||||
tr->langopts.vowel_pause = 0;
|
||||
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL | NUM_DFRACTION_4;
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_AFTER | NUM_VIGESIMAL | NUM_DFRACTION_4;
|
||||
SetLetterVowel(tr,'y');
|
||||
}
|
||||
break;
|
||||
@@ -668,7 +675,7 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.spelling_stress = 1;
|
||||
tr->langopts.accents = 1;
|
||||
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_UC;
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS;
|
||||
tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
|
||||
tr->langopts.replace_chars = replace_cyrillic_latin;
|
||||
|
||||
@@ -678,6 +685,15 @@ Translator *SelectTranslator(const char *name)
|
||||
break;
|
||||
|
||||
|
||||
case L('h','t'): // Haitian Creole
|
||||
// static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 235, 240};
|
||||
// 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.numbers = NUM_SINGLE_STRESS | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL | NUM_DFRACTION_4;
|
||||
break;
|
||||
|
||||
|
||||
case L('h','u'): // Hungarian
|
||||
{
|
||||
static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,22, 22,21 };
|
||||
@@ -693,7 +709,7 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
|
||||
tr->langopts.param[LOPT_ANNOUNCE_PUNCT] = 2; // don't break clause before announcing . ? !
|
||||
|
||||
tr->langopts.numbers = NUM_DFRACTION_5 | NUM_ALLOW_SPACE | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS | NUM_ORDINAL_DOT | NUM_OMIT_1_HUNDRED;
|
||||
tr->langopts.numbers = NUM_DFRACTION_5 | NUM_ALLOW_SPACE | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS | NUM_ORDINAL_DOT | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
|
||||
tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
|
||||
tr->langopts.decimal_sep = ',';
|
||||
tr->langopts.max_roman = 899;
|
||||
@@ -870,7 +886,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->letter_groups[0] = vowels_cyrillic;
|
||||
|
||||
tr->langopts.stress_rule = STRESSPOSN_3R; // antipenultimate
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
|
||||
tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
|
||||
}
|
||||
break;
|
||||
@@ -1089,7 +1105,7 @@ SetLengthMods(tr,3); // all equal
|
||||
if(name2 == L('t','a'))
|
||||
{
|
||||
tr->letter_bits_offset = OFFSET_TAMIL;
|
||||
tr->langopts.numbers = 0x1;
|
||||
tr->langopts.numbers = NUM_OMIT_1_THOUSAND ;
|
||||
}
|
||||
if(name2 == L('m','r'))
|
||||
{
|
||||
@@ -1131,8 +1147,8 @@ SetLengthMods(tr,3); // all equal
|
||||
|
||||
case L('t','r'): // Turkish
|
||||
{
|
||||
static const unsigned char stress_amps_tr[8] = {18,16, 20,20, 20,21, 21,20 };
|
||||
static const short stress_lengths_tr[8] = {190,180, 200,200, 0,0, 240,250};
|
||||
static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
|
||||
static const short stress_lengths_tr[8] = {190,180, 200,230, 0,0, 240,250};
|
||||
|
||||
SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
|
||||
tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
|
||||
@@ -1140,7 +1156,7 @@ SetLengthMods(tr,3); // all equal
|
||||
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.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2;
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
|
||||
tr->langopts.max_initial_consonants = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
+150
-20
@@ -577,11 +577,17 @@ char *strchr_w(const char *s, int c)
|
||||
static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word)
|
||||
{//============================================================================================
|
||||
int posn = 0;
|
||||
int capitals = 0;
|
||||
int non_initial = 0;
|
||||
|
||||
if (spell_word > 2)
|
||||
capitals = 2;
|
||||
|
||||
while((*word != ' ') && (*word != 0))
|
||||
{
|
||||
word += TranslateLetter(tr, word, phonemes, spell_word);
|
||||
word += TranslateLetter(tr, word, phonemes, capitals | non_initial);
|
||||
posn++;
|
||||
non_initial = 1;
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
// change to another language in order to translate this word
|
||||
@@ -661,15 +667,105 @@ static int CheckDottedAbbrev(char *word1, WORD_TAB *wtab)
|
||||
} // end of CheckDottedAbbrev
|
||||
|
||||
|
||||
extern char *phondata_ptr;
|
||||
|
||||
int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes)
|
||||
{//====================================================================
|
||||
// tr: the original language
|
||||
// lang2: phoneme table number for the temporary language
|
||||
// phonemes: the phonemes to be replaced
|
||||
|
||||
int ix;
|
||||
int len;
|
||||
char phon;
|
||||
char *p;
|
||||
unsigned char *pb;
|
||||
char *eqlist;
|
||||
char *p_out;
|
||||
char *p_in;
|
||||
int remove_stress = 0;
|
||||
char phonbuf[N_WORD_PHONEMES];
|
||||
|
||||
// has a phoneme equivalence table been specified for thus language pair?
|
||||
if((ix = phoneme_tab_list[tr->phoneme_tab_ix].equivalence_tables) == 0)
|
||||
return(0);
|
||||
|
||||
pb = (unsigned char *)&phondata_ptr[ix];
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(pb[0] == 0)
|
||||
return(0); // table not found
|
||||
|
||||
if(pb[0] == lang2)
|
||||
break;
|
||||
|
||||
len = (pb[2] << 8) + pb[3]; // size of this table in words
|
||||
pb += (len * 4);
|
||||
}
|
||||
remove_stress = pb[1];
|
||||
|
||||
if(option_phonemes == 2)
|
||||
{
|
||||
DecodePhonemes(phonemes, phonbuf);
|
||||
fprintf(f_trans,"(%s) %s -> (%s) ", phoneme_tab_list[lang2].name, phonbuf, phoneme_tab_list[tr->phoneme_tab_ix].name);
|
||||
}
|
||||
|
||||
p_in = phonemes;
|
||||
eqlist = (char *)&pb[8];
|
||||
p_out = phonbuf;
|
||||
|
||||
while((phon = *p_in++) != 0)
|
||||
{
|
||||
if(remove_stress && ((phon & 0xff) < phonSTRESS_PREV))
|
||||
continue; // remove stress marks
|
||||
|
||||
// is there a translation for this phoneme code?
|
||||
p = eqlist;
|
||||
while(*p != 0)
|
||||
{
|
||||
len = strlen(&p[1]);
|
||||
if(*p == phon)
|
||||
{
|
||||
strcpy(p_out, &p[1]);
|
||||
p_out += len;
|
||||
break;
|
||||
}
|
||||
p += (len + 2);
|
||||
}
|
||||
if(*p == 0)
|
||||
{
|
||||
// no translation found
|
||||
*p_out++ = phon;
|
||||
}
|
||||
}
|
||||
*p_out = 0;
|
||||
|
||||
if(remove_stress)
|
||||
{
|
||||
SetWordStress(tr, phonbuf, NULL, -1, 0);
|
||||
}
|
||||
|
||||
strcpy(phonemes, phonbuf);
|
||||
|
||||
if(option_phonemes == 2)
|
||||
{
|
||||
SelectPhonemeTable(tr->phoneme_tab_ix);
|
||||
DecodePhonemes(phonemes, phonbuf);
|
||||
fprintf(f_trans,"%s\n\n", phonbuf);
|
||||
}
|
||||
return(1);
|
||||
} // end of ChangeEquivalentPhonemes
|
||||
|
||||
|
||||
|
||||
|
||||
int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
|
||||
{//===========================================================================
|
||||
// word1 is terminated by space (0x20) character
|
||||
|
||||
int length;
|
||||
int word_length;
|
||||
int ix;
|
||||
int posn;
|
||||
int pfix;
|
||||
int n_chars;
|
||||
unsigned int dictionary_flags[2];
|
||||
@@ -858,7 +954,7 @@ if((wmark > 0) && (wmark < 8))
|
||||
{
|
||||
// either all upper or all lower case
|
||||
|
||||
if((tr->langopts.numbers & NUM_ROMAN) || ((tr->langopts.numbers & NUM_ROMAN_UC) && (wflags & FLAG_ALL_UPPER)))
|
||||
if((tr->langopts.numbers & NUM_ROMAN) || ((tr->langopts.numbers & NUM_ROMAN_CAPITALS) && (wflags & FLAG_ALL_UPPER)))
|
||||
{
|
||||
if((found = TranslateRoman(tr, word1, phonemes, wtab)) != 0)
|
||||
dictionary_flags[0] |= FLAG_ABBREV; // prevent emphasis if capitals
|
||||
@@ -898,10 +994,14 @@ if((wmark > 0) && (wmark < 8))
|
||||
else
|
||||
if(found == 0)
|
||||
{
|
||||
int posn;
|
||||
int non_initial;
|
||||
int length;
|
||||
// word's pronunciation is not given in the dictionary list, although
|
||||
// dictionary_flags may have ben set there
|
||||
|
||||
posn = 0;
|
||||
non_initial = 0;
|
||||
length = 999;
|
||||
wordx = word1;
|
||||
|
||||
@@ -911,7 +1011,14 @@ if((wmark > 0) && (wmark < 8))
|
||||
// This word looks "unpronouncable", so speak letters individually until we
|
||||
// find a remainder that we can pronounce.
|
||||
emphasize_allcaps = 0;
|
||||
wordx += TranslateLetter(tr, wordx, unpron_phonemes, 0);
|
||||
|
||||
if(wordx[0] == '\'')
|
||||
break;
|
||||
|
||||
if(posn > 0)
|
||||
non_initial = 1;
|
||||
|
||||
wordx += TranslateLetter(tr, wordx, unpron_phonemes, non_initial);
|
||||
posn++;
|
||||
if(unpron_phonemes[0] == phonSWITCH)
|
||||
{
|
||||
@@ -922,6 +1029,7 @@ if((wmark > 0) && (wmark < 8))
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef deleted
|
||||
p = &wordx[word_length-3]; // this looks wrong. Doesn't consider multi-byte chars.
|
||||
if(memcmp(p,"'s ",3) == 0)
|
||||
{
|
||||
@@ -931,7 +1039,7 @@ if((wmark > 0) && (wmark < 8))
|
||||
p[1] = ' ';
|
||||
last_char = p[-1];
|
||||
}
|
||||
|
||||
#endif
|
||||
length=0;
|
||||
while(wordx[length] != ' ') length++;
|
||||
}
|
||||
@@ -940,7 +1048,7 @@ if((wmark > 0) && (wmark < 8))
|
||||
// anything left ?
|
||||
if(*wordx != ' ')
|
||||
{
|
||||
if(unpron_phonemes[0] != 0)
|
||||
if((unpron_phonemes[0] != 0) && (wordx[0] != '\''))
|
||||
{
|
||||
// letters which have been spoken individually from affecting the pronunciation of the pronuncable part
|
||||
wordx[-1] = ' ';
|
||||
@@ -1132,6 +1240,12 @@ strcpy(phonemes2,phonemes);
|
||||
strcpy(word_phonemes,phonemes);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(dictionary_flags2[0] & FLAG_ABBREV)
|
||||
{
|
||||
// Removing the suffix leaves a word which should be spoken as individual letters
|
||||
// Not yet implemented
|
||||
}
|
||||
if(dictionary_flags[0]==0)
|
||||
{
|
||||
dictionary_flags[0] = dictionary_flags2[0];
|
||||
@@ -1151,9 +1265,11 @@ strcpy(phonemes2,phonemes);
|
||||
else
|
||||
{
|
||||
if(end_flags & FLAG_SUFX)
|
||||
TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL,wflags | FLAG_SUFFIX_REMOVED, dictionary_flags);
|
||||
else
|
||||
TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL,wflags,dictionary_flags);
|
||||
wflags |= FLAG_SUFFIX_REMOVED;
|
||||
if(end_type & SUFX_A)
|
||||
wflags |= FLAG_SUFFIX_VOWEL;
|
||||
|
||||
TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL, wflags, dictionary_flags);
|
||||
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
@@ -1234,13 +1350,13 @@ strcpy(phonemes2,phonemes);
|
||||
snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
|
||||
#endif
|
||||
word_phonemes[N_WORD_PHONEMES-1] = 0;
|
||||
SetWordStress(tr, word_phonemes, dictionary_flags, -1, tr->prev_last_stress);
|
||||
SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(prefix_phonemes[0] == 0)
|
||||
SetWordStress(tr, phonemes, dictionary_flags, -1, tr->prev_last_stress);
|
||||
SetWordStress(tr, phonemes, dictionary_flags, -1, 0);
|
||||
else
|
||||
SetWordStress(tr, phonemes, dictionary_flags, -1, 0);
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
@@ -1679,6 +1795,19 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
p[1] = phonSCHWA;
|
||||
p[2] = 0;
|
||||
}
|
||||
|
||||
// ?? Option to convert from language2 phonemes to the equivalent language1 phonemes
|
||||
// ?? Option to set the word-stress according to language1 rules eg. lang=fr)
|
||||
if(ChangeEquivalentPhonemes(tr, switch_phonemes, (char *)p))
|
||||
{
|
||||
switch_phonemes = -1;
|
||||
}
|
||||
|
||||
if(switch_phonemes == -1)
|
||||
{
|
||||
strcpy(dictionary_name, old_dictionary_name);
|
||||
SelectPhonemeTable(voice->phoneme_tab_ix);
|
||||
}
|
||||
}
|
||||
|
||||
if(!(word_flags & FLAG_HYPHEN))
|
||||
@@ -2178,6 +2307,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
|
||||
short charix[N_TR_SOURCE+4];
|
||||
WORD_TAB words[N_CLAUSE_WORDS];
|
||||
static char voice_change_name[40];
|
||||
int word_count=0; // index into words
|
||||
|
||||
char sbuf[N_TR_SOURCE];
|
||||
@@ -2200,7 +2330,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
|
||||
for(ix=0; ix<N_TR_SOURCE; ix++)
|
||||
charix[ix] = 0;
|
||||
terminator = ReadClause(tr, f_text, source, charix, &charix_top, N_TR_SOURCE, &tone2);
|
||||
terminator = ReadClause(tr, f_text, source, charix, &charix_top, N_TR_SOURCE, &tone2, voice_change_name);
|
||||
|
||||
if((f_logespeak != NULL) && (logging_type & 4))
|
||||
{
|
||||
@@ -2334,6 +2464,12 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
}
|
||||
next_in_nbytes = utf8_in(&next_in,&source[source_index]);
|
||||
|
||||
if(c == 0)
|
||||
{
|
||||
finished = 1;
|
||||
c = ' ';
|
||||
}
|
||||
|
||||
if((c == CTRL_EMBEDDED) || (c == ctrl_embedded))
|
||||
{
|
||||
// start of embedded command in the text
|
||||
@@ -2486,12 +2622,6 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
}
|
||||
}
|
||||
|
||||
if(c == 0)
|
||||
{
|
||||
finished = 1;
|
||||
c = ' ';
|
||||
}
|
||||
else
|
||||
if(IsAlpha(c))
|
||||
{
|
||||
if(!IsAlpha(prev_out) || (tr->langopts.ideographs && ((c > 0x3040) || (prev_out > 0x3040))))
|
||||
@@ -3020,7 +3150,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
{
|
||||
// return new voice name if an embedded voice change command terminated the clause
|
||||
if(terminator & CLAUSE_BIT_VOICE)
|
||||
*voice_change = &source[source_index];
|
||||
*voice_change = voice_change_name;
|
||||
else
|
||||
*voice_change = NULL;
|
||||
}
|
||||
|
||||
+40
-28
@@ -109,8 +109,11 @@
|
||||
#define FLAG_COMMA_AFTER 0x20000 // comma after this word
|
||||
#define FLAG_MULTIPLE_SPACES 0x40000 // word is preceded by multiple spaces, newline, or tab
|
||||
|
||||
#define FLAG_SUFFIX_VOWEL 0x08000000 // remember an initial vowel from the suffix
|
||||
#define FLAG_NO_TRACE 0x10000000 // passed to TranslateRules() to suppress dictionary lookup printout
|
||||
#define FLAG_NO_PREFIX 0x20000000
|
||||
#define FLAG_UNPRON_TEST 0x80000000 // do unpronounability test on the beginning of the word
|
||||
|
||||
|
||||
// prefix/suffix flags (bits 8 to 14, bits 16 to 22) don't use 0x8000, 0x800000
|
||||
#define SUFX_E 0x0100 // e may have been added
|
||||
@@ -122,6 +125,10 @@
|
||||
#define SUFX_Q 0x4000 // don't retranslate
|
||||
#define SUFX_T 0x10000 // don't affect the stress position in the stem
|
||||
#define SUFX_B 0x20000 // break, this character breaks the word into stem and suffix (used with SUFX_P)
|
||||
#define SUFX_A 0x40000 // remember that the suffix starts with a vowel
|
||||
|
||||
#define SUFX_UNPRON 0x8000 // used to return $unpron flag from *_rules
|
||||
|
||||
|
||||
#define FLAG_ALLOW_TEXTMODE 0x02 // allow dictionary to translate to text rather than phonemes
|
||||
#define FLAG_SUFX 0x04
|
||||
@@ -218,9 +225,9 @@
|
||||
typedef const char * constcharptr;
|
||||
|
||||
typedef struct {
|
||||
int points;
|
||||
int points;
|
||||
const char *phonemes;
|
||||
int end_type;
|
||||
int end_type;
|
||||
char *del_fwd;
|
||||
} MatchRecord;
|
||||
|
||||
@@ -380,16 +387,17 @@ typedef struct {
|
||||
#define NUM_DFRACTION_3 0x6000
|
||||
#define NUM_DFRACTION_4 0x8000
|
||||
#define NUM_DFRACTION_5 0xa000
|
||||
#define NUM_ORDINAL_DOT 0x10000
|
||||
#define NUM_ROMAN 0x20000
|
||||
#define NUM_ROMAN_UC 0x40000
|
||||
#define NUM_NOPAUSE 0x80000
|
||||
#define NUM_AND_HUNDRED 0x100000
|
||||
#define NUM_ROMAN_AFTER 0x200000
|
||||
#define NUM_VIGESIMAL 0x400000
|
||||
#define NUM_ROMAN_ORDINAL 0x800000
|
||||
#define NUM_ROMAN_CAPITALS 0x1000000
|
||||
#define NUM_THOUSAND_AND 0x2000000
|
||||
#define NUM_ORDINAL_DOT 0x10000
|
||||
#define NUM_NOPAUSE 0x20000
|
||||
#define NUM_AND_HUNDRED 0x40000
|
||||
#define NUM_THOUSAND_AND 0x80000
|
||||
#define NUM_VIGESIMAL 0x100000
|
||||
#define NUM_OMIT_1_THOUSAND 0x200000
|
||||
|
||||
#define NUM_ROMAN 0x1000000
|
||||
#define NUM_ROMAN_CAPITALS 0x2000000
|
||||
#define NUM_ROMAN_AFTER 0x4000000
|
||||
#define NUM_ROMAN_ORDINAL 0x8000000
|
||||
|
||||
// bits0-1=which numbers routine to use.
|
||||
// bit2= thousands separator must be space
|
||||
@@ -404,16 +412,18 @@ typedef struct {
|
||||
// bit11=say 19** as nineteen hundred
|
||||
// bit12=allow space as thousands separator (in addition to langopts.thousands_sep)
|
||||
// bits13-15 post-decimal-digits 0=single digits, 1=(LANG=it) 2=(LANG=pl) 3=(LANG=ro)
|
||||
// bit16=dot after number indicates ordinal
|
||||
// bit17=recognize roman numbers
|
||||
// bit18=Roman numbers only if upper case
|
||||
// bit19=don't add pause after a number
|
||||
// bit20='and' before hundreds
|
||||
// bit21= say "roman" after the number, not before
|
||||
// bit22= vigesimal number, if tens are not found
|
||||
// bit23=Roman numbers are ordinal numbers
|
||||
// bit24=Roman numbers must be capital letters
|
||||
// bit25='and' after thousands if there are no hundreds
|
||||
|
||||
// bit16= dot after number indicates ordinal
|
||||
// bit17= don't add pause after a number
|
||||
// bit18= 'and' before hundreds
|
||||
// bit19= 'and' after thousands if there are no hundreds
|
||||
// bit20= vigesimal number, if tens are not found
|
||||
// bit21= omit "one" before "thousand"
|
||||
|
||||
// bit24= recognize roman numbers
|
||||
// bit25= Roman numbers only if upper case
|
||||
// bit26= say "roman" after the number, not before
|
||||
// bit27= Roman numbers are ordinal numbers
|
||||
int numbers;
|
||||
|
||||
// bits 1-4 use variant form of numbers before thousands,millions,etc.
|
||||
@@ -469,17 +479,19 @@ typedef struct {
|
||||
#define NUM_SEP_SPACE 0x1000 // allow space as thousands separator (in addition to langopts.thousands_sep)
|
||||
#define NUM_DEC_IT 0x2000 // (LANG=it) speak post-decimal-point digits as a combined number not as single digits
|
||||
|
||||
struct Translator
|
||||
{//=============
|
||||
typedef struct
|
||||
{//===========
|
||||
|
||||
LANGUAGE_OPTIONS langopts;
|
||||
int translator_name;
|
||||
int transpose_max;
|
||||
int transpose_min;
|
||||
char dictionary_name[40];
|
||||
|
||||
char phon_out[300];
|
||||
char phonemes_repeat[20];
|
||||
int phonemes_repeat_count;
|
||||
int phonemes_repeat_count;
|
||||
int phoneme_tab_ix;
|
||||
|
||||
unsigned char stress_amps[8];
|
||||
unsigned char stress_amps_r[8];
|
||||
@@ -535,7 +547,7 @@ struct Translator
|
||||
int end_stressed_vowel; // word ends with stressed vowel
|
||||
int prev_dict_flags; // dictionary flags from previous word
|
||||
int clause_terminator;
|
||||
}; // end of class Translator
|
||||
} Translator;
|
||||
|
||||
|
||||
extern int option_tone2;
|
||||
@@ -624,7 +636,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab);
|
||||
void ChangeWordStress(Translator *tr, char *word, int new_stress);
|
||||
void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars);
|
||||
int TranslateLetter(Translator *tr, char *letter, char *phonemes, int control);
|
||||
void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf);
|
||||
void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf, int control);
|
||||
void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf);
|
||||
|
||||
int LoadDictionary(Translator *tr, const char *name, int no_error);
|
||||
@@ -645,7 +657,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata);
|
||||
|
||||
+58
-41
@@ -48,6 +48,7 @@
|
||||
#define T_TRANSLATE 503
|
||||
#define T_PROCESS 504
|
||||
#define T_RULES 505
|
||||
#define T_TRANSLATE_IPA 506
|
||||
|
||||
TranslDlg *transldlg = NULL;
|
||||
extern char *speech_to_phonemes(char *data, char *phout);
|
||||
@@ -58,12 +59,19 @@ BEGIN_EVENT_TABLE(TranslDlg, wxPanel)
|
||||
EVT_BUTTON(T_TRANSLATE,TranslDlg::OnCommand)
|
||||
EVT_BUTTON(T_PROCESS,TranslDlg::OnCommand)
|
||||
EVT_BUTTON(T_RULES,TranslDlg::OnCommand)
|
||||
EVT_BUTTON(T_TRANSLATE_IPA,TranslDlg::OnCommand)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
FILE *f_wave = NULL;
|
||||
wxFont font_phonetic;
|
||||
wxTextAttr style_phonetic;
|
||||
wxFont font_phonetic_large;
|
||||
wxTextAttr style_phonetic_large;
|
||||
|
||||
|
||||
#ifdef deleted
|
||||
|
||||
class IPATextCtrl : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
@@ -78,27 +86,6 @@ BEGIN_EVENT_TABLE(IPATextCtrl, wxTextCtrl)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
// using Kirschenbaum scheme to enter IPA from the keyboard
|
||||
wchar_t ipa1[256] = {
|
||||
0,0x250,32,32,32,32,32,32,32,32,0xa,0xb,0xc,0x26f,0x272,0x275,
|
||||
32,32,0x25a,32,32,32,32,0x28d,32,32,32,32,32,32,32,32,
|
||||
0x20,0x21,0x22,0x23,0x24,0x25,0x0e6,0x27,0x28,0x27e,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
|
||||
0x252,0x31,0x32,0x25c,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x294,
|
||||
0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x26c,0x271,0x14b,0x254,
|
||||
0x3a6,0x263,0x280,0x283,0x3b8,0x28a,0x28c,0x153,0x3c7,0xf8,0x292,0x32a,0x5c,0x5d,0x5e,0x5f,
|
||||
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
|
||||
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x303,0x7f,
|
||||
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
|
||||
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
|
||||
0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
|
||||
0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
|
||||
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
|
||||
0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
|
||||
0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
|
||||
0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
|
||||
};
|
||||
|
||||
|
||||
IPATextCtrl::IPATextCtrl(wxWindow *parent,wxWindowID id,const wxPoint& pos,const wxSize& size) :
|
||||
wxTextCtrl(parent,id,_T(""),pos,size,wxTE_MULTILINE)
|
||||
{
|
||||
@@ -132,7 +119,7 @@ void IPATextCtrl::OnKey(wxKeyEvent& event)
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -280,8 +267,10 @@ TranslDlg::TranslDlg(wxWindow *parent) : wxPanel(parent)
|
||||
int height;
|
||||
int width;
|
||||
int x,y;
|
||||
int font_size;
|
||||
int height_ph = 350;
|
||||
|
||||
|
||||
wxTextAttr attr;
|
||||
wxFont font = wxFont(12,wxFONTFAMILY_ROMAN,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_LIGHT,false,_T(""),wxFONTENCODING_SYSTEM);
|
||||
|
||||
@@ -303,11 +292,21 @@ TranslDlg::TranslDlg(wxWindow *parent) : wxPanel(parent)
|
||||
|
||||
|
||||
t_phonetic = new wxTextCtrl(this,T_PHONETIC,_T(""),wxPoint(0,262),
|
||||
wxSize(298,height_ph),wxTE_MULTILINE | wxTE_READONLY,wxDefaultValidator,_T("Phoneme translation window"));
|
||||
wxSize(298,height_ph),wxTE_MULTILINE | wxTE_READONLY, wxDefaultValidator,_T("Phoneme translation window"));
|
||||
|
||||
style_phonetic = t_phonetic->GetDefaultStyle();
|
||||
font_phonetic = style_phonetic.GetFont();
|
||||
font_size = font_phonetic.GetPointSize();
|
||||
font_phonetic_large = font_phonetic;
|
||||
style_phonetic_large = style_phonetic;
|
||||
//font_phonetic_large.SetFamily(wxFONTFAMILY_SWISS);
|
||||
font_phonetic_large.SetPointSize(font_size+1);
|
||||
style_phonetic_large.SetFont(font_phonetic_large);
|
||||
|
||||
y = height_ph + 270;
|
||||
t_translate = new wxButton(this,T_TRANSLATE,_T("Translate"),wxPoint(4,y));
|
||||
t_translate = new wxButton(this,T_RULES,_T("Show Rules"),wxPoint(4,y+32));
|
||||
t_translate = new wxButton(this,T_TRANSLATE_IPA,_T("Show IPA"),wxPoint(100,y+32));
|
||||
t_process = new wxButton(this,T_PROCESS,_T("Speak"),wxPoint(100,y));
|
||||
|
||||
t_source->SetFocus();
|
||||
@@ -399,6 +398,7 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
|
||||
#define N_PH_LIST N_PHONEME_LIST
|
||||
|
||||
void *vp;
|
||||
int translate_text = 0;
|
||||
char buf[1000];
|
||||
char phon_out[N_PH_LIST*2];
|
||||
int clause_tone;
|
||||
@@ -415,8 +415,6 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
|
||||
{
|
||||
case T_RULES:
|
||||
case MENU_SPEAK_RULES:
|
||||
option_phonemes = 2;
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
strcpy(fname_temp,"/tmp/espeakXXXXXX");
|
||||
if((fd_temp = mkstemp(fname_temp)) >= 0)
|
||||
@@ -435,8 +433,41 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
|
||||
f_trans = f; // write translation rule trace to a temp file
|
||||
}
|
||||
#endif
|
||||
t_phonetic->SetDefaultStyle(style_phonetic);
|
||||
translate_text = 2;
|
||||
break;
|
||||
|
||||
case T_TRANSLATE:
|
||||
case MENU_SPEAK_TRANSLATE:
|
||||
t_phonetic->SetDefaultStyle(style_phonetic);
|
||||
translate_text = 1;
|
||||
break;
|
||||
|
||||
case T_TRANSLATE_IPA:
|
||||
case MENU_SPEAK_IPA:
|
||||
t_phonetic->SetDefaultStyle(style_phonetic_large);
|
||||
|
||||
translate_text = 3;
|
||||
break;
|
||||
|
||||
case T_PROCESS:
|
||||
case MENU_SPEAK_TEXT:
|
||||
if(prosodycanvas == NULL)
|
||||
{
|
||||
myframe->OnProsody(event);
|
||||
}
|
||||
prosodycanvas->LayoutData(ph_list,n_ph_list);
|
||||
option_phoneme_events = 1;
|
||||
option_log_frames = 1;
|
||||
MakeWave2(ph_list,n_ph_list);
|
||||
option_log_frames = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if(translate_text)
|
||||
{
|
||||
option_phonemes = translate_text;
|
||||
|
||||
option_multibyte = espeakCHARS_AUTO;
|
||||
SpeakNextClause(NULL,NULL,2); // stop speaking file
|
||||
|
||||
@@ -457,7 +488,7 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
|
||||
if(clause_count++ > 0)
|
||||
strcat(phon_out," ||");
|
||||
strcat(phon_out,translator->phon_out);
|
||||
t_phonetic->SetValue(wxString(translator->phon_out,wxConvLocal));
|
||||
t_phonetic->SetValue(wxString(translator->phon_out,wxConvUTF8));
|
||||
|
||||
if((n_ph_list + n_phoneme_list) >= N_PH_LIST)
|
||||
{
|
||||
@@ -482,20 +513,6 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
|
||||
fclose(f_trans);
|
||||
remove(fname_temp);
|
||||
}
|
||||
t_phonetic->AppendText(wxString(phon_out,wxConvLocal));
|
||||
break;
|
||||
|
||||
case T_PROCESS:
|
||||
case MENU_SPEAK_TEXT:
|
||||
if(prosodycanvas == NULL)
|
||||
{
|
||||
myframe->OnProsody(event);
|
||||
}
|
||||
prosodycanvas->LayoutData(ph_list,n_ph_list);
|
||||
option_phoneme_events = 1;
|
||||
option_log_frames = 1;
|
||||
MakeWave2(ph_list,n_ph_list);
|
||||
option_log_frames = 0;
|
||||
break;
|
||||
t_phonetic->AppendText(wxString(phon_out,wxConvUTF8));
|
||||
}
|
||||
} // end of TranslDlg::OnCommand
|
||||
|
||||
@@ -978,6 +978,7 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
fprintf(stderr,"Unknown phoneme table: '%s'\n",phonemes_name);
|
||||
}
|
||||
voice->phoneme_tab_ix = ix;
|
||||
new_translator->phoneme_tab_ix = ix;
|
||||
error = LoadDictionary(new_translator, new_dictionary, control & 4);
|
||||
if(dictionary_name[0]==0)
|
||||
return(NULL); // no dictionary loaded
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@
|
||||
*/
|
||||
extern wxString path_phsource;
|
||||
|
||||
extern char *spects_data;
|
||||
extern char *phondata_ptr;
|
||||
extern USHORT *phoneme_index;
|
||||
extern int n_phoneme_tables;
|
||||
|
||||
@@ -664,7 +664,7 @@ void MakeVowelLists(void)
|
||||
{
|
||||
ix = vowelfmt_addr[vowelfmt_ix];
|
||||
|
||||
seq = (SPECT_SEQ *)(&spects_data[ix]);
|
||||
seq = (SPECT_SEQ *)(&phondata_ptr[ix]);
|
||||
seqk = (SPECT_SEQK *)seq;
|
||||
|
||||
if(seq->frame[0].frflags & FRFLAG_KLATT)
|
||||
|
||||
+12
-3
@@ -693,6 +693,7 @@ void WavegenInit(int rate, int wavemult_fact)
|
||||
max_hval = 0;
|
||||
|
||||
wdata.amplitude = 32;
|
||||
wdata.amplitude_fmt = 100;
|
||||
|
||||
for(ix=0; ix<N_EMBEDDED_VALUES; ix++)
|
||||
embedded_value[ix] = embedded_default[ix];
|
||||
@@ -1147,7 +1148,8 @@ int Wavegen()
|
||||
maxh2 = PeaksToHarmspect(peaks, wdata.pitch<<4, hspect[0], 0);
|
||||
|
||||
// adjust amplitude to compensate for fewer harmonics at higher pitch
|
||||
amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
|
||||
// amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
|
||||
amplitude2 = (wdata.amplitude * (wdata.pitch >> 8) * wdata.amplitude_fmt)/(10000 << 3);
|
||||
|
||||
// switch sign of harmonics above about 900Hz, to reduce max peak amplitude
|
||||
h_switch_sign = 890 / (wdata.pitch >> 12);
|
||||
@@ -1200,7 +1202,8 @@ int Wavegen()
|
||||
}
|
||||
|
||||
// adjust amplitude to compensate for fewer harmonics at higher pitch
|
||||
amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
|
||||
// amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
|
||||
amplitude2 = (wdata.amplitude * (wdata.pitch >> 8) * wdata.amplitude_fmt)/(10000 << 3);
|
||||
|
||||
if(glottal_flag > 0)
|
||||
{
|
||||
@@ -1535,7 +1538,7 @@ void SetEmbedded(int control, int value)
|
||||
general_amplitude = GetAmplitude();
|
||||
break;
|
||||
|
||||
case EMBED_F: // emphasiis
|
||||
case EMBED_F: // emphasis
|
||||
general_amplitude = GetAmplitude();
|
||||
break;
|
||||
|
||||
@@ -1837,6 +1840,7 @@ int WavegenFill(int fill_zeros)
|
||||
echo_complete -= length;
|
||||
}
|
||||
wdata.n_mix_wavefile = 0;
|
||||
wdata.amplitude_fmt = 100;
|
||||
KlattReset(1);
|
||||
result = PlaySilence(length,resume);
|
||||
break;
|
||||
@@ -1907,6 +1911,11 @@ int WavegenFill(int fill_zeros)
|
||||
case WCMD_MBROLA_DATA:
|
||||
result = MbrolaFill(length, resume);
|
||||
break;
|
||||
|
||||
case WCMD_FMT_AMPLITUDE:
|
||||
if((wdata.amplitude_fmt = q[1]) == 0)
|
||||
wdata.amplitude_fmt = 100; // percentage, but value=0 means 100%
|
||||
break;
|
||||
}
|
||||
|
||||
if(result==0)
|
||||
|
||||
Reference in New Issue
Block a user