[1.27.04] tr_languages: replace_char substitution can do 2->1 and 1->2 characters.

espeakedit: set and save path for master phonemes file.
espeakedit: added delete_phoneme and import_phoneme actions in phoneme files.
espeakedit: improve data in log_espeakedit, include phoneme names.
espeakedit: only write to log_espeakedit for speak from text window, not when playing vowel files.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@59 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2007-07-04 22:59:40 +00:00
parent 3303246b80
commit 1a28202d00
29 changed files with 328 additions and 160 deletions
+66 -9
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -65,7 +65,8 @@
#define tSWITCHVOICING 21
#define tVOWELIN 22
#define tVOWELOUT 23
#define tAPPENDPH 24
#define tAPPENDPH 24 // always insert another phoneme (linkout) after this one
#define tIMPORTPH 25
#define tPHONEMENUMBER 29
#define tPHONEMETABLE 30
@@ -123,6 +124,7 @@ private:
void AddSpectList(int *list, int control);
void AddEnvelope(int *list);
void VowelTransition(int which, unsigned int *trans);
void ImportPhoneme(void);
FILE *f_in;
@@ -190,6 +192,7 @@ static keywtab_t keywords[] = {
{"fricative", 0x1000000+phFRICATIVE},
{"vstop", 0x1000000+phVSTOP},
{"vfricative",0x1000000+phVFRICATIVE},
{"delete_phoneme", 0x1000000+phDELETED},
// type of consonant
{"stop", 0x1000000+phSTOP},
@@ -226,6 +229,7 @@ static keywtab_t keywords[] = {
{"vowelin",22},
{"vowelout",23},
{"appendph",24},
{"import_phoneme",25},
// flags
{"wavef", 0x2000000+phWAVE},
@@ -1229,6 +1233,49 @@ void Compile::VowelTransition(int which, unsigned int *trans)
} // end of VowelTransition
void Compile::ImportPhoneme(void)
{//==============================
int ix;
unsigned int mnem;
unsigned int ph_mnem;
unsigned int ph_code;
PHONEME_TAB_LIST *phtab = NULL;
NextItem(tSTRING);
mnem = StringToWord(item_string);
NextItem(tSTRING);
for(ix=0; ix<n_phoneme_tabs; ix++)
{
if(strcmp(phoneme_tab_list2[ix].name,item_string) == 0)
{
phtab = &phoneme_tab_list2[ix];
break;
}
}
if(phtab == NULL)
{
Error("Unknown phoneme table",item_string);
return; // phoneme table not found
}
for(ix=1; ix<256; ix++)
{
if(mnem == phtab->phoneme_tab_ptr[ix].mnemonic)
{
ph_mnem = ph->mnemonic;
ph_code = ph->code;
memcpy(ph,&phtab->phoneme_tab_ptr[ix],sizeof(PHONEME_TAB));
ph->mnemonic = ph_mnem;
ph->code = ph_code;
break;
}
}
if(ix == 256)
{
Error("Import phoneme not found",WordToString(mnem));
}
}
int Compile::CPhoneme()
{//====================
@@ -1382,6 +1429,10 @@ int Compile::CPhoneme()
VowelTransition(2,vowel_out);
break;
case tIMPORTPH:
ImportPhoneme();
break;
default:
Error("Syntax error",item_string);
break;
@@ -1430,6 +1481,11 @@ int Compile::CPhoneme()
ph->std_length |= 0x8000; // 'locally declared' indicator
if(ph->type == phDELETED)
{
ph->mnemonic = 0x01; // will not be recognised
}
return(phindex);
} // end of Compile::CPhoneme
@@ -2030,22 +2086,23 @@ memset(markers_used,0,sizeof(markers_used));
f_errors = stderr;
strncpy0(current_fname,source,sizeof(current_fname));
sprintf(fname,"%s%s",path_source,source);
strncpy0(fname,path_phfile.mb_str(wxConvLocal),sizeof(fname));
f_in = fopen_log(f_errors,fname,"rb");
if(f_in == NULL)
{
if(gui_flag)
{
wxString dir = wxDirSelector(_T("Directory for 'phonemes' file"),path_phsource);
if(!dir.IsEmpty())
wxString phfile = wxFileSelector(_T("Master phonemes file"),path_phsource,
_T(""),_T(""),_T("*"),wxOPEN);
if(!phfile.IsEmpty())
{
path_phsource = dir;
strncpy0(path_source,path_phsource.mb_str(wxConvLocal),sizeof(path_source)-1);
strcat(path_source,"/");
path_phfile = phfile;
}
}
sprintf(fname,"%s%s",path_source,source);
strncpy0(fname,path_phfile.mb_str(wxConvLocal),sizeof(fname));
f_in = fopen_log(f_errors,fname,"rb");
if(f_in == NULL)
{
+12 -2
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -180,6 +180,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
EVT_MENU(MENU_SPECTRUM2, MyFrame::OnNewWindow)
EVT_MENU(MENU_PROSODY, MyFrame::OnProsody)
EVT_MENU(MENU_PARAMS, MyFrame::OnOptions)
EVT_MENU(MENU_PATH0, MyFrame::OnOptions)
EVT_MENU(MENU_PATH1, MyFrame::OnOptions)
EVT_MENU(MENU_PATH2, MyFrame::OnOptions)
EVT_MENU(MENU_PATH3, MyFrame::OnOptions)
@@ -366,6 +367,15 @@ void OnOptions2(int event_id)
}
break;
case MENU_PATH0:
string = wxFileSelector(_T("Master phonemes file"),wxFileName(path_phfile).GetPath(),
_T(""),_T(""),_T("*"),wxOPEN);
if(!string.IsEmpty())
{
path_phfile = string;
}
break;
case MENU_PATH1:
string = wxDirSelector(_T("Phoneme source directory"),path_phsource);
if(!string.IsEmpty())
@@ -393,7 +403,7 @@ void OnOptions2(int event_id)
case MENU_PATH4:
string = wxFileSelector(_T("Voice file to modify formant peaks"),wxFileName(path_speech).GetPath(),
_T(""),_T("WAV"),_T("*"),wxSAVE);
_T(""),_T(""),_T("*"),wxOPEN);
if(!string.IsEmpty())
{
path_modifiervoice = string;
+1
View File
@@ -123,6 +123,7 @@ enum {
MENU_OPTIONS,
MENU_PARAMS,
MENU_PATHS,
MENU_PATH0,
MENU_PATH1,
MENU_PATH2,
MENU_PATH3,
+3 -2
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -89,10 +89,11 @@ wxMenuBar *MakeMenu(int type)
// OPTIONS MENU
paths_menu = new wxMenu;
paths_menu->Append(MENU_PATH0, _("Master phonemes file"));
paths_menu->Append(MENU_PATH1, _("Phoneme data source"));
paths_menu->Append(MENU_PATH2, _("Dictionary data source"));
paths_menu->Append(MENU_PATH3, _("Synthesized sound WAV file"));
speak_menu->AppendSeparator();
paths_menu->AppendSeparator();
paths_menu->Append(MENU_PATH4, _("Voice file to modify formant peaks"));
option_menu = new wxMenu;
+18 -9
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -434,13 +434,22 @@ static char *M_Variant(int value)
{//==============================
// returns M, or perhaps MA for some cases
// for Polish language - two forms of plural!
if ((translator->langopts.numbers & 0x80000) &&
((value % 10)>=2) &&
((value % 10)<=4) &&
((value % 100)>20 || (value % 100)<10))
if(((value % 100)>20) || ((value % 100)<10)) // but not teens, 10 to 19
{
return("MA");
if ((translator->langopts.numbers2 & 0x40) &&
((value % 10)>=2) &&
((value % 10)<=4))
{
// for Polish language - two forms of plural!
return("0MA");
}
if((translator->langopts.numbers2 & 0x80) &&
((value % 10)==1))
{
return("1MA");
}
}
return("M");
}
@@ -465,7 +474,7 @@ int Translator::LookupThousands(int value, int thousandplex, char *ph_out)
Lookup("_0of",ph_of);
}
sprintf(string,"_0%s%d",M_Variant(value),thousandplex);
sprintf(string,"_%s%d",M_Variant(value),thousandplex);
if(Lookup(string,ph_thousands) == 0)
{
@@ -610,7 +619,7 @@ int Translator::TranslateNumber_1(char *word, char *ph_out, unsigned int *flags,
else
if((thousandplex > 1) && prev_thousands && (prev_value > 0))
{
sprintf(string,"_0%s%d",M_Variant(value),thousandplex+1);
sprintf(string,"_%s%d",M_Variant(value),thousandplex+1);
if(Lookup(string,buf1)==0)
{
// speak this thousandplex if there was no word for the previous thousandplex
+4 -1
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -45,6 +45,7 @@ wxString path_spectload2;
wxString path_pitches;
wxString path_wave;
wxString path_speech;
wxString path_phfile;
wxString path_phsource;
wxString path_dictsource;
wxString path_speaktext;
@@ -164,6 +165,7 @@ void ConfigInit()
pConfig->Read(_T("/voicename"),&string,wxEmptyString);
strcpy(voice_name,string.mb_str(wxConvLocal));
pConfig->Read(_T("/phsource"),&path_phsource,basedir+_T("/phsource"));
pConfig->Read(_T("/phfile"),&path_phfile,path_phsource+_T("/phonemes"));
pConfig->Read(_T("/dictsource"),&path_dictsource,basedir+_T("/dictsource"));
pConfig->Read(_T("/speaktext"),&path_speaktext,wxEmptyString);
pConfig->Read(_T("/modifiervoice"),&path_modifiervoice,basedir);
@@ -189,6 +191,7 @@ void ConfigSave(int exit)
pConfig->Write(_T("/speechpath"),path_speech);
pConfig->Write(_T("/voicename"),wxString(voice_name,wxConvLocal));
pConfig->Write(_T("/phsource"),path_phsource);
pConfig->Write(_T("/phfile"),path_phfile);
pConfig->Write(_T("/dictsource"),path_dictsource);
pConfig->Write(_T("/speaktext"),path_speaktext);
pConfig->Write(_T("/speed"),option_speed);
+2 -1
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -34,6 +34,7 @@ extern void ConfigSetPaths();
extern wxString path_spectload;
extern wxString path_spectload2;
extern wxString path_pitches;
extern wxString path_phfile;
extern wxString path_phsource;
extern wxString path_dictsource;
extern wxString path_modifiervoice;
+2 -1
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -30,6 +30,7 @@
#define phVFRICATIVE 7
#define phNASAL 8
#define phVIRTUAL 9
#define phDELETED 14
#define phINVALID 15
+8 -1
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -400,9 +400,16 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence)
if(alternative > 1)
{
PHONEME_TAB *ph2;
ph2 = ph;
ph = phoneme_tab[alternative];
if(ph->type == phVOWEL)
{
plist2->synthflags |= SFLAG_SYLLABLE;
if(ph2->type != phVOWEL)
plist2->stress = 0; // change from non-vowel to vowel, make sure it's unstressed
}
else
plist2->synthflags &= ~SFLAG_SYLLABLE;
}
+1 -1
View File
@@ -15,7 +15,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
+2 -2
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.27.03 03.Jul.07";
const char *version_string = "1.27.04 04.Jul.07";
const int version_phdata = 0x012701;
int option_device_number = -1;
+1 -1
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
+1
View File
@@ -236,6 +236,7 @@ extern unsigned char *out_end;
extern int event_list_ix;
extern espeak_EVENT *event_list;
extern t_espeak_callback* synth_callback;
extern int option_log_frames;
#define N_SOUNDICON_TAB 100
extern int n_soundicon_tab;
+37 -31
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -44,6 +44,22 @@
#define OFFSET_CYRILLIC 0x420
#define OFFSET_DEVANAGARI 0x900
static const unsigned int replace_cyrillic[] =
{0x430,0x431,0x446,0x45b,0x447,0x45f,0x455,0x434,0x452,
0x435,0x444,0x433,0x445,0x438,0x458,0x43a,0x459,
0x43b,0x43c,0x45a,0x43d,0x43e,0x43f,0x440,0x441,
0x448,0x442,0x443,0x432,0x437,0x436,
0x453,0x45c,0}; // ѓ ѕ ќ
static const unsigned int replace_cyrillic_latin[] =
{'a','b','c',0x107,0x10d,'d'+(0x17e<<16),'d'+('z'<<16),'d',0x111,
'e','f','g','h','i','j','k','l'+('j'<<16),
'l','m','n'+('j'<<16),'n','o','p','r','s',
0x161,'t','u','v','z',0x17e,
0x111,0x107,0};
void SetupTranslator(Translator *tr, int *lengths, int *amps)
{//==========================================================
if(lengths != NULL)
@@ -243,7 +259,7 @@ Translator *SelectTranslator(const char *name)
case L('h','i'):
{
static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f};
static const wchar_t replace_chars_hi[11] = {0x966,0x967,0x968,0x969,0x96a,0x96b,0x96c,0x96d,0x96e,0x96f,0}; // digits 0-9
static const unsigned int replace_chars_hi[11] = {0x966,0x967,0x968,0x969,0x96a,0x96b,0x96c,0x96d,0x96e,0x96f,0}; // digits 0-9
static const unsigned int replacement_chars_hi[11] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0};
static int stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250};
static int stress_amps_hi[8] = {17,14, 20,19, 20,24, 24,22 };
@@ -273,20 +289,6 @@ Translator *SelectTranslator(const char *name)
case L('h','r'): // Croatian
case L('s','r'): // Serbian
{
static const wchar_t replace_chars_hr[] =
{0x430,0x431,0x446,0x45b,0x447,0x434,0x452,0x45f,
0x435,0x444,0x433,0x445,0x438,0x458,0x43a,0x43b,
0x459,0x43c,0x43d,0x45a,0x43e,0x43f,0x440,0x441,
0x448,0x442,0x443,0x432,0x437,0x436,
0x453,0x455,0x45c,0}; // ѓ ѕ ќ
static const unsigned int replacement_chars_hr[] =
{'a','b','c',0x107,0x10d,'d',0x111,'d'+(0x17e<<16),
'e','f','g','h','i','j','k','l',
'l'+('j'<<16),'m','n','n'+('j'<<16),'o','p','r','s',
0x161,'t','u','v','z',0x17e,
0x111,'d'+('z'<<16),0x107,0};
static int stress_amps_hr[8] = {16,16, 20,20, 20,24, 24,22 };
static int stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230};
@@ -300,10 +302,10 @@ Translator *SelectTranslator(const char *name)
tr->langopts.max_initial_consonants = 5;
tr->langopts.spelling_stress = 1;
tr->langopts.numbers = 0x1c0d + 0x84000;
tr->langopts.numbers2 = 0xa; // variant numbers before thousands,milliards
tr->langopts.replace_chars = replace_chars_hr;
tr->langopts.replacement_chars = replacement_chars_hr;
tr->langopts.numbers = 0x1c0d + 0x4000;
tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
tr->langopts.replace_chars = replace_cyrillic;
tr->langopts.replacement_chars = replace_cyrillic_latin;
SetLetterVowel(tr,'y');
SetLetterVowel(tr,'r');
@@ -316,7 +318,7 @@ Translator *SelectTranslator(const char *name)
static int stress_amps_hu[8] = {17,17, 19,19, 20,24, 24,22 };
static int stress_lengths_hu[8] = {185,190, 190,190, 0,0, 210,220};
// static int stress_lengths_hu[8] = {180,180, 200,190, 0,0, 210,225};
static const wchar_t replace_chars_hu[] = {0xd4,0xf4,0xdb,0xfb,0};
static const unsigned int replace_chars_hu[] = {0xd4,0xf4,0xdb,0xfb,0};
static const unsigned int replacement_chars_hu[] = {0x150,0x151,0x170,0x171,0}; // allow o,u-circumflex for o,u-double-acute
tr = new Translator();
@@ -411,8 +413,11 @@ Translator *SelectTranslator(const char *name)
tr->letter_groups[0] = vowels_cyrillic;
tr->langopts.stress_rule = 4; // antipenultimate
tr->langopts.numbers = 0x0c29 + 0x84000;
tr->langopts.numbers2 = 0xa; // variant numbers before thousands,milliards
tr->langopts.numbers = 0x0c29 + 0x4000;
tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
tr->langopts.replace_chars = replace_cyrillic_latin;
tr->langopts.replacement_chars = replace_cyrillic;
}
break;
@@ -460,7 +465,8 @@ Translator *SelectTranslator(const char *name)
tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x8;
tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
tr->langopts.numbers=0x81809 + 0x4000;
tr->langopts.numbers=0x1809 + 0x4000;
tr->langopts.numbers2=0x40;
tr->langopts.param[LOPT_COMBINE_WORDS] = 2 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable words (marked with $alt)
SetLetterVowel(tr,'y');
}
@@ -487,7 +493,7 @@ Translator *SelectTranslator(const char *name)
{
static int stress_lengths_ro[8] = {170, 170, 180, 180, 0, 0, 240, 260};
static int stress_amps_ro[8] = {15,13, 18,18, 20,22, 22,22 };
static const wchar_t replace_chars_ro[5] = {0x218,0x219,0x21a,0x21b,0};
static const unsigned int replace_chars_ro[5] = {0x218,0x219,0x21a,0x21b,0};
static const unsigned int replacement_chars_ro[5] = {0x15e,0x15f,0x162,0x163,0}; // replace s-comma, t-comma by s-cedilla, t-cedilla
tr = new Translator();
@@ -526,8 +532,8 @@ Translator *SelectTranslator(const char *name)
tr->langopts.spelling_stress = 1;
tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
// tr->langopts.numbers = 0x1c0d + 0x84000;
tr->langopts.numbers = 0x1c01 + 0x84000;
tr->langopts.numbers = 0x1c01 + 0x4000;
tr->langopts.numbers2 = 0x40;
tr->langopts.thousands_sep = 0; //no thousands separator
tr->langopts.decimal_sep = ',';
@@ -706,8 +712,8 @@ Translator_Russian::Translator_Russian() : Translator()
langopts.stress_rule = 5;
langopts.stress_flags = 0x0020; // waas 0x1010
langopts.numbers = 0x80409;
langopts.numbers2 = 0x2; // variant numbers before thousands
langopts.numbers = 0x0409;
langopts.numbers2 = 0xc2; // variant numbers before thousands
langopts.phoneme_change = 1;
langopts.testing = 2;
@@ -941,8 +947,8 @@ Translator_Afrikaans::Translator_Afrikaans() : Translator()
}
int Translator_Afrikaans::TranslateChar(char *ptr, int prev_in, int c, int next_in, int *insert)
{//=============================================================================================
int Translator_Afrikaans::TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
{//===============================================================================================================
// look for 'n and replace by a special character (unicode: schwa)
if(!iswalpha(prev_in))
+1 -1
View File
@@ -51,7 +51,7 @@ class Translator_Afrikaans: public Translator
public:
Translator_Afrikaans();
private:
int TranslateChar(char *ptr, int prev_in, int c, int next_in, int *insert);
int TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert);
}; // end of class Translator_Afrikaans
+55 -29
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -1544,48 +1544,71 @@ static int EmbeddedCommand(unsigned int &source_index)
int Translator::TranslateChar(char *ptr, int prev_in, int c, int next_in, int *insert)
{//===================================================================================
int Translator::TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
{//=====================================================================================================
// To allow language specific examination and replacement of characters
const wchar_t *p;
int ix;
unsigned int word;
unsigned int new_c, c2;
int upper_case = 0;
static int ignore_next = 0;
if(ignore_next)
{
ignore_next = 0;
return(8);
}
if(c == 0) return(0);
if(langopts.replace_chars != NULL)
if(langopts.replace_chars == NULL)
return(c);
// there is a list of character codes to be substituted with alternative codes
if(iswupper(c))
{
// there is a list of character codes to be substituted with alternative codes
c = towlower(c);
upper_case = 1;
}
if((p = wcschr(langopts.replace_chars,c)) == NULL)
new_c = 0;
for(ix=0; (word = langopts.replace_chars[ix]) != 0; ix++)
{
if(c == (word & 0xffff))
{
// Try converting to lower case
if((p = wcschr(langopts.replace_chars,towlower(c))) != NULL)
upper_case =1;
}
if(p != NULL)
{
new_c = langopts.replacement_chars[p - langopts.replace_chars];
if(new_c & 0xffe00000)
if((word >> 16) == 0)
{
// there is a second character to be inserted
// don't convert the case of the second character unless the next letter is also upper case
c2 = new_c >> 16;
if(upper_case && iswupper(next_in))
c2 = towupper(c2);
*insert = c2;
new_c &= 0xffff;
new_c = langopts.replacement_chars[ix];
break;
}
if((word >> 16) == tolower(next_in))
{
new_c = langopts.replacement_chars[ix];
ignore_next = 1;
break;
}
#ifndef PLATFORM_RISCOS
if(upper_case)
new_c = towupper(new_c);
#endif
return(new_c);
}
}
return(c);
if(new_c == 0)
return(c); // no substitution
if(new_c & 0xffe00000)
{
// there is a second character to be inserted
// don't convert the case of the second character unless the next letter is also upper case
c2 = new_c >> 16;
if(upper_case && iswupper(next_in))
c2 = towupper(c2);
*insert = c2;
new_c &= 0xffff;
}
#ifndef PLATFORM_RISCOS
if(upper_case)
new_c = towupper(new_c);
#endif
return(new_c);
}
@@ -1823,6 +1846,9 @@ if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out)
}
c = TranslateChar(&source[source_index], prev_in,c, next_in, &char_inserted); // optional language specific function
if(c == 8)
continue; // ignore this character
if(char_inserted)
next_in = char_inserted;
+5 -4
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -290,11 +290,12 @@ typedef struct {
// bits13-15 post-decimal-digits 0=single digits, 1=(LANG=it) 2=(LANG=pl) 3=(LANG=ro)
// bit16=dot after number indicates ordinal
// bit18=special word for 100,000s LANG=sw
// bit19=(LANG=pl) two forms of plural, M or MA
int numbers;
// bits 1-4 use variant form of numbers before thousands,millions,etc.
// bit6=(LANG=pl) two forms of plural, M or MA
// bit7=(LANG-ru) use MB for 1 thousand, million, etc
int numbers2;
int thousands_sep;
@@ -307,7 +308,7 @@ typedef struct {
char tone_numbers;
char ideographs; // treat as separate words
int testing; // testing options: bit 1= specify stressed syllable in the form: "outdoor/2"
const wchar_t *replace_chars; // characters to be substitutes
const unsigned int *replace_chars; // characters to be substitutes
const unsigned int *replacement_chars; // substitutes for replace_chars
} LANGUAGE_OPTIONS;
@@ -404,7 +405,7 @@ protected:
virtual int Unpronouncable(char *word);
virtual void SetWordStress(char *output, unsigned int dictionary_flags, int tonic, int prev_stress);
virtual int RemoveEnding(char *word, int end_type, char *word_copy);
virtual int TranslateChar(char *ptr, int prev_in, int c, int next_in, int *insert);
virtual int TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert);
virtual int TranslateNumber(char *word1, char *ph_out, unsigned int *flags, int wflags);
virtual int ChangePhonemes(PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch);
+4 -1
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -348,7 +348,10 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
{
myframe->OnProsody(event);
}
option_phoneme_events = 1;
option_log_frames = 1;
MakeWave2(ph_list,n_ph_list);
option_log_frames = 0;
break;
}
} // end of TranslDlg::OnCommand
+46 -14
View File
@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* along with this program; if not, see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
@@ -59,6 +59,7 @@ static voice_t *wvoice;
FILE *f_log = NULL;
int option_waveout = 0;
int option_harmonic1 = 11; // 10
int option_log_frames = 0;
static int flutter_amp = 64;
static int general_amplitude = 60;
@@ -1529,12 +1530,15 @@ void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
int pitch_value;
#ifdef LOG_FRAMES
f_log=fopen("log-espeakedit","a");
if(f_log != NULL)
if(option_log_frames)
{
fprintf(f_log," %3d %3d\n",pitch1,pitch2);
fclose(f_log);
f_log=NULL;
f_log=fopen("log-espeakedit","a");
if(f_log != NULL)
{
fprintf(f_log," pitch %3d %3d %3dmS\n",pitch1,pitch2,(length*1000)/samplerate);
fclose(f_log);
f_log=NULL;
}
}
#endif
if((pitch_env = env)==NULL)
@@ -1592,14 +1596,18 @@ void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2)
static int glottal_reduce_tab2[4] = {0x90, 0xa0, 0xb0, 0xc0}; // vowel after [?], amp * 1/256
#ifdef LOG_FRAMES
f_log=fopen("log-espeakedit","a");
if(f_log != NULL)
if(option_log_frames)
{
fprintf(f_log,"%3dmS %4d/%3d %4d/%3d %4d/%3d %4d/%3d %4d/%3d %4d/%3d %4d/%3d %4d/%3d\n",length*1000/samplerate,
fr1->ffreq[0],fr1->fheight[0],fr1->ffreq[1],fr1->fheight[1], fr1->ffreq[2],fr1->fheight[2], fr1->ffreq[3],fr1->fheight[3],
fr2->ffreq[0],fr2->fheight[0],fr2->ffreq[1],fr2->fheight[1], fr2->ffreq[2],fr2->fheight[2], fr2->ffreq[3],fr2->fheight[3] );
fclose(f_log);
f_log=NULL;
f_log=fopen("log-espeakedit","a");
if(f_log != NULL)
{
fprintf(f_log,"%3dmS %3d %3d %4d %4d (%3d %3d %3d %3d) to %3d %3d %4d %4d (%3d %3d %3d %3d)\n",length*1000/samplerate,
fr1->ffreq[0],fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3], fr1->fheight[0],fr1->fheight[1],fr1->fheight[2],fr1->fheight[3],
fr2->ffreq[0],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3], fr2->fheight[0],fr2->fheight[1],fr2->fheight[2],fr2->fheight[3] );
fclose(f_log);
f_log=NULL;
}
}
#endif
@@ -1676,6 +1684,28 @@ f_log=NULL;
} // end of SetSynth
#ifdef LOG_FRAMES
static void LogMarker(int type, int value)
{//=======================================
if(option_log_frames == 0)
return;
if((type == espeakEVENT_PHONEME) || (type == espeakEVENT_SENTENCE))
{
f_log=fopen("log-espeakedit","a");
if(f_log)
{
if(type == espeakEVENT_PHONEME)
fprintf(f_log,"Phoneme [%s]\n",WordToString(value));
else
fprintf(f_log,"\n");
fclose(f_log);
f_log = NULL;
}
}
}
#endif
static int Wavegen2(int length, int modulation, int resume, frame_t *fr1, frame_t *fr2)
{//====================================================================================
if(resume==0)
@@ -1849,7 +1879,9 @@ int WavegenFill(int fill_zeros)
case WCMD_MARKER:
MarkerEvent(q[1],q[2],q[3],out_ptr);
#ifdef LOG_FRAMES
LogMarker(q[1],q[3]);
#endif
if(q[1] == 1)
{
current_source_index = q[2] & 0xffffff;