mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-01 14:30:37 +00:00
[1.43] Release
git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@237 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
@@ -132,6 +132,7 @@ static keywtab_t k_properties[] = {
|
||||
{"isAfterStress",0, i_isAfterStress},
|
||||
{"isNotVowel", 0, i_isNotVowel},
|
||||
{"isFinalVowel", 0, i_isFinalVowel},
|
||||
{"isVoiced", 0, i_isVoiced}, // voiced consonant, or vowel
|
||||
|
||||
{NULL, 0, 0}
|
||||
};
|
||||
|
||||
+2
-2
@@ -1127,8 +1127,8 @@ static char *compile_rule(char *input)
|
||||
} // end of compile_rule
|
||||
|
||||
|
||||
static int __cdecl string_sorter(char **a, char **b)
|
||||
{//=================================================
|
||||
int __cdecl string_sorter(char **a, char **b)
|
||||
{//===========================================
|
||||
char *pa, *pb;
|
||||
int ix;
|
||||
|
||||
|
||||
+9
-3
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -59,7 +59,8 @@ const char *path_data;
|
||||
extern void TestTest(int control);
|
||||
extern void CompareLexicon(int);
|
||||
extern void ConvertToUtf8();
|
||||
extern void FormatDictionary(const char *dictname);
|
||||
extern void DictionaryFormat(const char *dictname);
|
||||
extern void DictionarySort(const char *dictname);
|
||||
|
||||
extern void init_z();
|
||||
extern void CompilePhonemeData(void);
|
||||
@@ -200,6 +201,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
EVT_MENU(MENU_COMPILE_DICT, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_COMPILE_DICT_DEBUG, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_FORMAT_DICTIONARY, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_SORT_DICTIONARY, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_COMPILE_MBROLA, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_CLOSE_ALL, MyFrame::OnQuit)
|
||||
EVT_MENU(MENU_QUIT, MyFrame::OnQuit)
|
||||
@@ -592,7 +594,11 @@ void MyFrame::OnTools(wxCommandEvent& event)
|
||||
break;
|
||||
|
||||
case MENU_FORMAT_DICTIONARY:
|
||||
FormatDictionary(dictionary_name);
|
||||
DictionaryFormat(dictionary_name);
|
||||
break;
|
||||
|
||||
case MENU_SORT_DICTIONARY:
|
||||
DictionarySort(dictionary_name);
|
||||
break;
|
||||
|
||||
case MENU_VOWELCHART1:
|
||||
|
||||
+162
-7
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 to 2007 by Jonathan Duddington *
|
||||
* Copyright (C) 2006 to 2010 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "options.h"
|
||||
|
||||
extern char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
|
||||
extern int __cdecl string_sorter(char **a, char **b);
|
||||
|
||||
//******************************************************************************************************
|
||||
|
||||
@@ -1312,7 +1313,156 @@ void ConvertToUtf8()
|
||||
|
||||
//******************************************************************************************************
|
||||
|
||||
void FormatDictionary(const char *dictname)
|
||||
#define N_SORT_LIST 10000
|
||||
|
||||
void DictionarySort(const char *dictname)
|
||||
{//======================================
|
||||
// Sort rules in *_rules file between lines which begin with //sort and //endsort
|
||||
FILE *f_in;
|
||||
FILE *f_out;
|
||||
int ix;
|
||||
char *p;
|
||||
char *p_end;
|
||||
char *p_pre;
|
||||
int sorting;
|
||||
int sort_ix=0;
|
||||
int sort_count=0;
|
||||
int line_len;
|
||||
int key_len;
|
||||
char buf[200];
|
||||
char key[200];
|
||||
char fname_in[200];
|
||||
char fname_out[200];
|
||||
char *sort_list[N_SORT_LIST];
|
||||
|
||||
wxLogMessage(_T("Sorts the *_rules file, between lines which begin with\n//sort\n and\n//endsort"));
|
||||
|
||||
// try with and without '.txt' extension
|
||||
sprintf(fname_in,"%s%s_rules.txt",path_dsource,dictname);
|
||||
if((f_in = fopen(fname_in,"r")) == NULL)
|
||||
{
|
||||
sprintf(fname_in,"%s%s_rules",path_dsource,dictname);
|
||||
if((f_in = fopen(fname_in,"r")) == NULL)
|
||||
{
|
||||
wxLogError(_T("Can't open rules file: ") + wxString(fname_in,wxConvLocal));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(fname_out,"%s%s_rules_sorted",path_dsource,dictname);
|
||||
if((f_out = fopen(fname_out,"w")) == NULL)
|
||||
{
|
||||
wxLogError(_T("Can't write to file: ") + wxString(fname_out,wxConvLocal));
|
||||
fclose(f_in);
|
||||
return;
|
||||
}
|
||||
|
||||
sorting = 0;
|
||||
while(fgets(buf, sizeof(buf)-1, f_in) != NULL)
|
||||
{
|
||||
buf[sizeof(buf)-1] = 0; // ensure zero byte terminator
|
||||
|
||||
line_len = strlen(buf);
|
||||
|
||||
if(memcmp(buf,"//endsort",9)==0)
|
||||
{
|
||||
sort_count++;
|
||||
sorting = 0;
|
||||
qsort((void *)sort_list, sort_ix, sizeof(char *), (int(*)(const void *, const void *))string_sorter);
|
||||
|
||||
// write out the sorted lines
|
||||
for(ix=0; ix<sort_ix; ix++)
|
||||
{
|
||||
key_len = strlen(sort_list[ix]);
|
||||
p = &sort_list[ix][key_len+1]; // the original line is after the key
|
||||
fprintf(f_out,"%s",p);
|
||||
free(sort_list[ix]);
|
||||
}
|
||||
}
|
||||
|
||||
if(sorting == 0)
|
||||
{
|
||||
if(memcmp(buf,"//sort",6)==0)
|
||||
{
|
||||
sorting = 1;
|
||||
sort_ix = 0;
|
||||
}
|
||||
|
||||
fwrite(buf, line_len, 1, f_out);
|
||||
continue;
|
||||
}
|
||||
|
||||
p_end = strstr(buf,"//");
|
||||
if(p_end == NULL)
|
||||
p_end = &buf[line_len];
|
||||
|
||||
// add to the list of lines to be sorted
|
||||
p = buf;
|
||||
while((*p==' ') || (*p == '\t')) p++; // skip leading spaces
|
||||
if(*p == '?')
|
||||
{
|
||||
// conditional rule, skip the condition
|
||||
while(!isspace(*p) && (*p != 0)) p++;
|
||||
}
|
||||
|
||||
// skip any pre -condition
|
||||
p_pre = p;
|
||||
while(p < p_end)
|
||||
{
|
||||
if(*p == ')')
|
||||
{
|
||||
p_pre = p+1;
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
p = p_pre;
|
||||
while((*p==' ') || (*p == '\t')) p++; // skip spaces
|
||||
|
||||
ix = 0;
|
||||
while(!isspace(*p) && (*p != 0))
|
||||
{
|
||||
key[ix++] = *p++;
|
||||
}
|
||||
while((*p==' ') || (*p == '\t')) p++; // skip spaces
|
||||
if(*p == '(')
|
||||
{
|
||||
// post-condition
|
||||
p++; // skip '('
|
||||
while(!isspace(*p) && (*p != 0) && (p < p_end))
|
||||
{
|
||||
key[ix++] = *p++;
|
||||
}
|
||||
}
|
||||
key[ix] = 0;
|
||||
key_len = strlen(key);
|
||||
|
||||
p = (char *)malloc(key_len + line_len + 8);
|
||||
sprintf(p,"%s%6d",key,sort_ix); // include the line number (within the sort section) in case the keys are otherwise equal
|
||||
strcpy(p, key);
|
||||
strcpy(&p[key_len+1], buf);
|
||||
sort_list[sort_ix++] = p;
|
||||
|
||||
if(sort_ix >= N_SORT_LIST)
|
||||
{
|
||||
wxLogError(_T("Too many lines to sort, > %d"), N_SORT_LIST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f_in);
|
||||
fclose(f_out);
|
||||
|
||||
if(sorting != 0)
|
||||
{
|
||||
wxLogError(_T("Missing //$endsort"));
|
||||
}
|
||||
wxLogStatus(_T("Sorted %d sections. Written to file: ") + wxString(fname_out,wxConvLocal),sort_count);
|
||||
|
||||
} // end of DictionarySort
|
||||
|
||||
|
||||
void DictionaryFormat(const char *dictname)
|
||||
{//========================================
|
||||
// Format the *_rules file for the current voice
|
||||
|
||||
@@ -1345,10 +1495,10 @@ void FormatDictionary(const char *dictname)
|
||||
const int tab3 = 28;
|
||||
|
||||
// try with and without '.txt' extension
|
||||
sprintf(fname_in,"%s/%s_rules.txt",path_dsource,dictname);
|
||||
sprintf(fname_in,"%s%s_rules.txt",path_dsource,dictname);
|
||||
if((f_in = fopen(fname_in,"r")) == NULL)
|
||||
{
|
||||
sprintf(fname_in,"%s/%s_rules",path_dsource,dictname);
|
||||
sprintf(fname_in,"%s%s_rules",path_dsource,dictname);
|
||||
if((f_in = fopen(fname_in,"r")) == NULL)
|
||||
{
|
||||
wxLogError(_T("Can't open rules file: ") + wxString(fname_in,wxConvLocal));
|
||||
@@ -1356,7 +1506,7 @@ void FormatDictionary(const char *dictname)
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(fname_out,"%s/%s_rules_formatted",path_dsource,dictname);
|
||||
sprintf(fname_out,"%s%s_rules_formatted",path_dsource,dictname);
|
||||
if((f_out = fopen(fname_out,"w")) == NULL)
|
||||
{
|
||||
wxLogError(_T("Can't write to file: ") + wxString(fname_out,wxConvLocal));
|
||||
@@ -1569,8 +1719,13 @@ void FormatDictionary(const char *dictname)
|
||||
|
||||
fclose(f_in);
|
||||
fclose(f_out);
|
||||
wxLogStatus(_("Written to file: ") + wxString(fname_out,wxConvLocal));
|
||||
} // end of FormatDictionary
|
||||
|
||||
remove(fname_in);
|
||||
if(rename(fname_out, fname_in) == 0)
|
||||
wxLogStatus(_("Written to file: ") + wxString(fname_in,wxConvLocal));
|
||||
else
|
||||
wxLogStatus(_("Failed to rename: ") + wxString(fname_out,wxConvLocal));
|
||||
} // end of DictionaryFormat
|
||||
|
||||
|
||||
//******************************************************************************************************
|
||||
|
||||
@@ -136,6 +136,7 @@ enum {
|
||||
MENU_COMPILE_DICT,
|
||||
MENU_COMPILE_DICT_DEBUG,
|
||||
MENU_FORMAT_DICTIONARY,
|
||||
MENU_SORT_DICTIONARY,
|
||||
MENU_COMPILE_MBROLA,
|
||||
|
||||
MENU_SPEAK_TRANSLATE,
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -90,7 +90,8 @@ wxMenuBar *MakeMenu(int type)
|
||||
data_menu->Append(MENU_COMPILE_MBROLA, _("Compile &mbrola phonemes list..."));
|
||||
data_menu->AppendSeparator();
|
||||
data_menu->Append(MENU_FORMAT_DICTIONARY, _("&Layout *_rules file"));
|
||||
|
||||
data_menu->Append(MENU_SORT_DICTIONARY, _("&Sort *_rules file"));
|
||||
|
||||
// OPTIONS MENU
|
||||
paths_menu = new wxMenu;
|
||||
paths_menu->Append(MENU_PATH0, _("Master phonemes file..."));
|
||||
|
||||
+13
-5
@@ -970,10 +970,11 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
|
||||
#define SSML_BREAK 13
|
||||
#define SSML_IGNORE_TEXT 14
|
||||
#define HTML_BREAK 15
|
||||
#define SSML_CLOSE 0x10 // for a closing tag, OR this with the tag type
|
||||
#define HTML_NOSPACE 16 // don't insert a space for this element, so it doesn't break a word
|
||||
#define SSML_CLOSE 0x20 // for a closing tag, OR this with the tag type
|
||||
|
||||
// these tags have no effect if they are self-closing, eg. <voice />
|
||||
static char ignore_if_self_closing[] = {0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0};
|
||||
static char ignore_if_self_closing[] = {0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,0,0};
|
||||
|
||||
|
||||
static MNEM_TAB ssmltags[] = {
|
||||
@@ -994,6 +995,7 @@ static MNEM_TAB ssmltags[] = {
|
||||
|
||||
{"br", HTML_BREAK},
|
||||
{"li", HTML_BREAK},
|
||||
{"dd", HTML_BREAK},
|
||||
{"img", HTML_BREAK},
|
||||
{"td", HTML_BREAK},
|
||||
{"h1", SSML_PARAGRAPH},
|
||||
@@ -1003,6 +1005,12 @@ static MNEM_TAB ssmltags[] = {
|
||||
{"hr", SSML_PARAGRAPH},
|
||||
{"script", SSML_IGNORE_TEXT},
|
||||
{"style", SSML_IGNORE_TEXT},
|
||||
{"font", HTML_NOSPACE},
|
||||
{"b", HTML_NOSPACE},
|
||||
{"i", HTML_NOSPACE},
|
||||
{"strong", HTML_NOSPACE},
|
||||
{"em", HTML_NOSPACE},
|
||||
{"code", HTML_NOSPACE},
|
||||
{NULL,0}};
|
||||
|
||||
|
||||
@@ -1637,7 +1645,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
|
||||
if(tag_name[0] == '/')
|
||||
{
|
||||
// closing tag
|
||||
if((tag_type = LookupMnem(ssmltags,&tag_name[1])) != 0)
|
||||
if((tag_type = LookupMnem(ssmltags,&tag_name[1])) != HTML_NOSPACE)
|
||||
{
|
||||
outbuf[outix++] = ' ';
|
||||
}
|
||||
@@ -1645,9 +1653,9 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
|
||||
}
|
||||
else
|
||||
{
|
||||
if((tag_type = LookupMnem(ssmltags,tag_name)) != 0)
|
||||
if((tag_type = LookupMnem(ssmltags,tag_name)) != HTML_NOSPACE)
|
||||
{
|
||||
// separate SSML tags from the previous word (but not unknown HMTL tags such as <b> <font> which can occur inside a word)
|
||||
// separate SSML tags from the previous word (but not HMTL tags such as <b> <font> which can occur inside a word)
|
||||
outbuf[outix++] = ' ';
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.42.42 12.Feb.10";
|
||||
const char *version_string = "1.43 17.Feb.10";
|
||||
const int version_phdata = 0x014220;
|
||||
|
||||
int option_device_number = -1;
|
||||
@@ -706,6 +706,9 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
|
||||
return(false);
|
||||
}
|
||||
break;
|
||||
|
||||
case 12: // isVoiced
|
||||
return((ph->type == phVOWEL) || (ph->phflags & phVOICED));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -343,11 +343,13 @@ typedef struct {
|
||||
#define i_isAfterStress 0x89
|
||||
#define i_isNotVowel 0x8a
|
||||
#define i_isFinalVowel 0x8b
|
||||
#define i_isVoiced 0x8c
|
||||
|
||||
|
||||
#define i_isPalatal 0x49 // bit 9 in phflags
|
||||
#define i_isRhotic 0x56 // bit 22 in phflags
|
||||
|
||||
|
||||
#define i_StressLevel 0x800
|
||||
|
||||
|
||||
|
||||
+9
-2
@@ -377,6 +377,7 @@ void VoiceReset(int tone_only)
|
||||
// default is: pitch 80,118
|
||||
voice->pitch_base = 0x47000;
|
||||
voice->pitch_range = 4104;
|
||||
|
||||
// default is: pitch 80,117
|
||||
// voice->pitch_base = 0x47000;
|
||||
// voice->pitch_range = 3996;
|
||||
@@ -571,8 +572,14 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
|
||||
if(GetFileLength(buf) <= 0)
|
||||
{
|
||||
// look in "test" sub-directory
|
||||
sprintf(buf,"%stest%c%s",path_voices,PATHSEP,voicename);
|
||||
// look in "extra" sub-directory
|
||||
sprintf(buf,"%sextra%c%s",path_voices,PATHSEP,voicename);
|
||||
|
||||
if(GetFileLength(buf) <= 0)
|
||||
{
|
||||
// look in "test" sub-directory
|
||||
sprintf(buf,"%stest%c%s",path_voices,PATHSEP,voicename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user