mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-17 10:32:15 +00:00
[1.41.08]
espeakedit, add menu item Help->Documentation. lang-hu: fix ordinal numbers. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@223 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
@@ -40,6 +40,8 @@ int HashDictionary(const char *string);
|
||||
static FILE *f_log = NULL;
|
||||
extern char *dir_dictionary;
|
||||
|
||||
extern char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
|
||||
|
||||
static int linenum;
|
||||
static int error_count;
|
||||
static int transpose_offset; // transpose character range for LookupDictList()
|
||||
@@ -220,6 +222,9 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
unsigned char bad_phoneme[4];
|
||||
static char nullstring[] = {0};
|
||||
|
||||
WORD_TAB winfo;
|
||||
char decoded_phonemes[128];
|
||||
|
||||
comment = NULL;
|
||||
text_not_phonemes = 0;
|
||||
phonetic = word = nullstring;
|
||||
@@ -434,6 +439,14 @@ step=1; // TEST
|
||||
|
||||
if(text_not_phonemes)
|
||||
{
|
||||
if(word[0] == '_')
|
||||
{
|
||||
// This is a special word, used by eSpeak. Translate this into phonemes now
|
||||
// memset(&winfo,0,sizeof(winfo));
|
||||
// TranslateWord(translator,phonetic,0,&winfo); // but *_dict is not loaded ?
|
||||
// DecodePhonemes(word_phonemes,decoded_phonemes);
|
||||
//printf("Translator %x %s [%s] [%s]\n",translator->translator_name,word,phonetic,decoded_phonemes);
|
||||
}
|
||||
// this is replacement text, so don't encode as phonemes. Restrict the length of the replacement word
|
||||
strncpy0(encoded_ph,phonetic,N_WORD_BYTES-4);
|
||||
}
|
||||
|
||||
@@ -645,7 +645,7 @@ void display_espeak_command( t_espeak_command* the_command)
|
||||
|
||||
case ET_KEY:
|
||||
{
|
||||
const char* data = the_command->u.my_key;
|
||||
const char* data = the_command->u.my_key.key_name;
|
||||
SHOW("display_espeak_command > (0x%x) KEY=%c\n", the_command, data);
|
||||
}
|
||||
break;
|
||||
@@ -662,7 +662,7 @@ void display_espeak_command( t_espeak_command* the_command)
|
||||
|
||||
case ET_CHAR:
|
||||
{
|
||||
const wchar_t data = the_command->u.my_char;
|
||||
const wchar_t data = the_command->u.my_char.character;
|
||||
SHOW("display_espeak_command > (0x%x) CHAR=%c\n", the_command, (char)data);
|
||||
}
|
||||
break;
|
||||
|
||||
+116
-9
@@ -28,6 +28,8 @@
|
||||
#include "wx/mdi.h"
|
||||
#include "wx/laywin.h"
|
||||
#include "wx/sashwin.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/html/htmlwin.h"
|
||||
#include <locale.h>
|
||||
|
||||
#include "speak_lib.h"
|
||||
@@ -42,12 +44,17 @@
|
||||
#include "prosodydisplay.h"
|
||||
|
||||
|
||||
#ifdef deleted
|
||||
static const char *about_string = "espeakedit: %s\nAuthor: Jonathan Duddington (c) 2007\n\n"
|
||||
"Licensed under GNU General Public License version 3\n"
|
||||
"http://espeak.sourceforge.net/";
|
||||
#endif
|
||||
|
||||
static const char *about_string = "<font size=0><b>espeakedit </b> %s<br>Author: Jonathan Duddington (c) 2007<br>"
|
||||
"<a href=\"http://espeak.sourceforge.net/\">http://espeak.sourceforge.net</a><br>"
|
||||
"Licensed under <a href=\"http://espeak.sourceforge.net/license.html\">GNU General Public License version 3</a></font>";
|
||||
|
||||
const char *path_data = "/home/jsd1/speechdata/phsource";
|
||||
const char *path_data;
|
||||
|
||||
extern void TestTest(int control);
|
||||
extern void CompareLexicon(int);
|
||||
@@ -88,8 +95,6 @@ wxString AppName = _T("espeakedit");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int MyApp::OnExit()
|
||||
{//================
|
||||
ConfigSave(1);
|
||||
@@ -164,6 +169,7 @@ extern void VoiceReset(int control);
|
||||
|
||||
myframe->CreateStatusBar();
|
||||
|
||||
myframe->Maximize();
|
||||
myframe->Show(TRUE);
|
||||
|
||||
SetTopWindow(myframe);
|
||||
@@ -175,6 +181,7 @@ extern void VoiceReset(int control);
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
EVT_CHAR(MyFrame::OnKey)
|
||||
EVT_MENU(MENU_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU(MENU_DOCS, MyFrame::OnAbout)
|
||||
EVT_MENU(MENU_SPECTRUM, MyFrame::OnNewWindow)
|
||||
EVT_MENU(MENU_SPECTRUM2, MyFrame::OnNewWindow)
|
||||
EVT_MENU(MENU_PROSODY, MyFrame::OnProsody)
|
||||
@@ -258,9 +265,9 @@ wxSashLayoutWindow *win;
|
||||
if((result = LoadPhData()) != 1)
|
||||
{
|
||||
if(result == -1)
|
||||
wxLogError(_T("Failed to load phoneme data,\nneeds espeak-data/phontab,phondata,phonindex\nPath = ")+wxString(path_home,wxConvLocal));
|
||||
wxLogError(_T("Failed to read espeak-data/phontab,phondata,phonindex\nPath = ")+wxString(path_home,wxConvLocal)+_T("\n\nThe 'eSpeak' package needs to be installed"));
|
||||
else
|
||||
wxLogError(_T("Wrong version of espeak-data: 0x%x (expects 0x%x)"),result,version_phdata);
|
||||
wxLogError(_T("Wrong version of espeak-data at:\n")+ wxString(path_home,wxConvLocal)+_T("\nVersion 0x%x (expects 0x%x)"),result,version_phdata);
|
||||
|
||||
error_flag = 1;
|
||||
}
|
||||
@@ -349,13 +356,113 @@ void MyFrame::OnQuit(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{//===================================================
|
||||
#ifdef deleted
|
||||
void MyFrame::OnAbout(wxCommandEvent& event)
|
||||
{//=========================================
|
||||
int result;
|
||||
char buf[300];
|
||||
wxString url_docs;
|
||||
|
||||
sprintf(buf,about_string,espeak_Info(NULL));
|
||||
(void)wxMessageBox(wxString(buf,wxConvLocal), _T("About eSpeak Editor"));
|
||||
switch(event.GetId())
|
||||
{
|
||||
case MENU_ABOUT:
|
||||
sprintf(buf,about_string,espeak_Info(NULL));
|
||||
(void)wxMessageBox(wxString(buf,wxConvLocal), _T("About eSpeak Editor"));
|
||||
break;
|
||||
|
||||
case MENU_DOCS:
|
||||
sprintf(buf,"%s/docs/docindex.html",path_home);
|
||||
url_docs = wxString(buf,wxConvLocal);
|
||||
result = wxLaunchDefaultBrowser(url_docs);
|
||||
if(result == 0)
|
||||
wxLogStatus(_T("Failed to launch browser"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
class HtmlWindow: public wxHtmlWindow
|
||||
{
|
||||
public:
|
||||
|
||||
HtmlWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
|
||||
void OnLinkClicked(const wxHtmlLinkInfo& link);
|
||||
};
|
||||
|
||||
HtmlWindow::HtmlWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
|
||||
wxHtmlWindow(parent, id, pos, size, style)
|
||||
{
|
||||
}
|
||||
|
||||
void HtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
|
||||
{
|
||||
if(wxLaunchDefaultBrowser(link.GetHref()) == FALSE)
|
||||
wxLogStatus(_T("Failed to launch default browser: "+link.GetHref()));
|
||||
}
|
||||
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& event)
|
||||
{//=========================================
|
||||
int result;
|
||||
char buf[300];
|
||||
wxString url_docs;
|
||||
|
||||
wxBoxSizer *topsizer;
|
||||
HtmlWindow *html;
|
||||
wxDialog dlg(this, wxID_ANY, wxString(_("About")));
|
||||
|
||||
topsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
switch(event.GetId())
|
||||
{
|
||||
case MENU_ABOUT:
|
||||
{
|
||||
sprintf(buf,about_string,espeak_Info(NULL));
|
||||
html = new HtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
|
||||
html -> SetBorders(0);
|
||||
html -> SetPage(wxString(buf,wxConvLocal));
|
||||
html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(),
|
||||
html -> GetInternalRepresentation() -> GetHeight());
|
||||
|
||||
topsizer -> Add(html, 1, wxALL, 10);
|
||||
|
||||
//#if wxUSE_STATLINE
|
||||
// topsizer -> Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
//#endif // wxUSE_STATLINE
|
||||
|
||||
wxButton *bu1 = new wxButton(&dlg, wxID_OK, _("OK"));
|
||||
bu1 -> SetDefault();
|
||||
|
||||
topsizer -> Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
|
||||
|
||||
dlg.SetSizer(topsizer);
|
||||
topsizer -> Fit(&dlg);
|
||||
|
||||
dlg.ShowModal();
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_DOCS:
|
||||
strcpy(buf,"/docs/docindex.html");
|
||||
url_docs = wxGetCwd() + wxString(buf,wxConvLocal); // look for "docs" in the current directory
|
||||
if(!wxFileExists(url_docs))
|
||||
{
|
||||
strcpy(buf,"http://espeak.sourceforge.net/docindex.html");
|
||||
url_docs = wxString(buf,wxConvLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
url_docs = _T("file://") + url_docs;
|
||||
}
|
||||
|
||||
result = wxLaunchDefaultBrowser(url_docs);
|
||||
if(result == 0)
|
||||
wxLogStatus(_T("Failed to launch default browser: "+url_docs));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OnOptions2(int event_id)
|
||||
|
||||
+31
-5
@@ -54,6 +54,9 @@ void FormantDlg::OnCommand(wxCommandEvent& event)
|
||||
{//=============================================
|
||||
int id;
|
||||
|
||||
if(currentcanvas == NULL)
|
||||
return;
|
||||
|
||||
switch(id = event.GetId())
|
||||
{
|
||||
case T_ZOOMIN:
|
||||
@@ -77,6 +80,9 @@ void FormantDlg::OnSpin(wxSpinEvent& event)
|
||||
{//=============================================
|
||||
int id;
|
||||
|
||||
if(currentcanvas == NULL)
|
||||
return;
|
||||
|
||||
switch(id = event.GetId())
|
||||
{
|
||||
case T_AMPFRAME:
|
||||
@@ -98,6 +104,26 @@ FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,w
|
||||
int id;
|
||||
wxString string;
|
||||
|
||||
int height;
|
||||
int width;
|
||||
int x;
|
||||
int y2 = 420;
|
||||
int y3 = 520;
|
||||
|
||||
wxClientDisplayRect(&x,&y,&width, &height);
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
if(height <= 768)
|
||||
{
|
||||
y2 = 410;
|
||||
y3 = 508;
|
||||
}
|
||||
#else
|
||||
if(height <= 800)
|
||||
{
|
||||
y2 = 378;
|
||||
y3 = 456;
|
||||
}
|
||||
#endif
|
||||
y = 24;
|
||||
xplace = 28;
|
||||
id = 201;
|
||||
@@ -188,10 +214,10 @@ FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,w
|
||||
|
||||
|
||||
|
||||
t_zoomout = new wxButton(this,T_ZOOMOUT,_T("Zoom-"),wxPoint(16,420));
|
||||
t_zoomin = new wxButton(this,T_ZOOMIN,_T("Zoom+"),wxPoint(106,420));
|
||||
t_zoomout = new wxButton(this,T_ZOOMOUT,_T("Zoom-"),wxPoint(16,y2));
|
||||
t_zoomin = new wxButton(this,T_ZOOMIN,_T("Zoom+"),wxPoint(106,y2));
|
||||
|
||||
y=468;
|
||||
y = y2 + 46;
|
||||
t_amplitude = new wxSpinCtrl(this,T_AMPLITUDE,_T(""),
|
||||
wxPoint(6,y),wxSize(52,24),wxTE_CENTRE,0,y+130);
|
||||
t_lab[2] = new wxStaticText(this,-1,_T("% amp - Sequence"),wxPoint(61,y+4));
|
||||
@@ -199,9 +225,9 @@ FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,w
|
||||
// wxPoint(6,400),wxSize(52,24),wxTE_CENTRE,0,500);
|
||||
t_orig_seq = new wxStaticText(this,-1,_T("mS"),wxPoint(61,y+30));
|
||||
|
||||
t_pitch = new wxStaticText(this,-1,_T(""),wxPoint(4,520),wxSize(192,24));
|
||||
t_pitch = new wxStaticText(this,-1,_T(""),wxPoint(4,y3),wxSize(192,24));
|
||||
|
||||
pitchgraph = new ByteGraph(this,wxPoint(0,538),wxSize(200,140));
|
||||
pitchgraph = new ByteGraph(this,wxPoint(0,y3+18),wxSize(200,140));
|
||||
pitchgraph->SetData(128,env_fall);
|
||||
pitchgraph->ShowSpectrum(1);
|
||||
pitchgraph->Show();
|
||||
|
||||
@@ -120,6 +120,7 @@ enum {
|
||||
MENU_SPECTRUM2,
|
||||
MENU_CLOSE_ALL,
|
||||
MENU_ABOUT,
|
||||
MENU_DOCS,
|
||||
|
||||
MENU_OPTIONS,
|
||||
MENU_PARAMS,
|
||||
|
||||
+3
-2
@@ -115,9 +115,9 @@ wxMenuBar *MakeMenu(int type)
|
||||
lexicon_menu->Append(MENU_LEXICON_IT2, _("Italian, pass 2"));
|
||||
|
||||
tools_menu = new wxMenu;
|
||||
tools_menu->Append(MENU_VOWELCHART, _("Make &Vowels Chart..."), vowelchart_menu);
|
||||
tools_menu->Append(MENU_VOWELCHART, _("Make &Vowels Chart"), vowelchart_menu);
|
||||
// tools_menu->Append(MENU_LOAD_WAV, _T("Analyse WAV file"));
|
||||
tools_menu->Append(MENU_LEXICON, _("Compare &Lexicon..."), lexicon_menu);
|
||||
tools_menu->Append(MENU_LEXICON, _("Compare &Lexicon"), lexicon_menu);
|
||||
tools_menu->Append(MENU_TO_UTF8, _("Convert file to &UTF8..."));
|
||||
tools_menu->Append(MENU_COUNT_WORDS, _("Count word &frequencies..."));
|
||||
tools_menu->Append(MENU_TEST , _("Test (temporary)"));
|
||||
@@ -125,6 +125,7 @@ wxMenuBar *MakeMenu(int type)
|
||||
|
||||
// HELP MENU
|
||||
help_menu = new wxMenu;
|
||||
help_menu->Append(MENU_DOCS, _("eSpeak &Documentation"));
|
||||
help_menu->Append(MENU_ABOUT, _("&About"));
|
||||
|
||||
|
||||
|
||||
+110
-49
@@ -761,6 +761,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out)
|
||||
int value;
|
||||
int subtract;
|
||||
int repeat = 0;
|
||||
int wflags = 0;
|
||||
unsigned int flags;
|
||||
char ph_roman[30];
|
||||
char number_chars[N_WORD_BYTES];
|
||||
@@ -823,7 +824,10 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out)
|
||||
}
|
||||
|
||||
sprintf(number_chars," %d ",acc);
|
||||
TranslateNumber(tr, &number_chars[1], p, &flags, 0);
|
||||
|
||||
if(tr->langopts.numbers & NUM_ROMAN_ORDINAL)
|
||||
wflags |= FLAG_ORDINAL;
|
||||
TranslateNumber(tr, &number_chars[1], p, &flags, wflags);
|
||||
|
||||
if(tr->langopts.numbers & NUM_ROMAN_AFTER)
|
||||
strcat(ph_out,ph_roman);
|
||||
@@ -859,47 +863,69 @@ static const char *M_Variant(int value)
|
||||
}
|
||||
|
||||
|
||||
static int LookupThousands(Translator *tr, int value, int thousandplex, char *ph_out)
|
||||
{//==================================================================================
|
||||
static int LookupThousands(Translator *tr, int value, int thousandplex, int thousands_exact, char *ph_out)
|
||||
{//=======================================================================================================
|
||||
int found;
|
||||
int found_value=0;
|
||||
char string[12];
|
||||
char ph_of[12];
|
||||
char ph_thousands[40];
|
||||
|
||||
ph_of[0] = 0;
|
||||
|
||||
// first look fora match with the exact value of thousands
|
||||
sprintf(string,"_%dM%d",value,thousandplex);
|
||||
// first look for a match with the exact value of thousands
|
||||
if(thousands_exact)
|
||||
{
|
||||
// is there a different pronunciation if there are no hundreds,tens,or units ? (LANG=ta)
|
||||
sprintf(string,"_%dM%dx",value,thousandplex);
|
||||
found_value = Lookup(tr, string, ph_thousands);
|
||||
}
|
||||
if(found_value == 0)
|
||||
{
|
||||
sprintf(string,"_%dM%d",value,thousandplex);
|
||||
found_value = Lookup(tr, string, ph_thousands);
|
||||
}
|
||||
|
||||
if((found = Lookup(tr, string, ph_thousands)) == 0)
|
||||
if(found_value == 0)
|
||||
{
|
||||
if((value % 100) >= 20)
|
||||
{
|
||||
Lookup(tr, "_0of", ph_of);
|
||||
}
|
||||
|
||||
sprintf(string,"_%s%d",M_Variant(value),thousandplex);
|
||||
|
||||
if(Lookup(tr, string, ph_thousands) == 0)
|
||||
found = 0;
|
||||
if(thousands_exact)
|
||||
{
|
||||
// repeat "thousand" if higher order names are not available
|
||||
sprintf(string,"_%dM1",value);
|
||||
if((found = Lookup(tr, string, ph_thousands)) == 0)
|
||||
Lookup(tr, "_0M1", ph_thousands);
|
||||
// is there a different pronunciation if there are no hundreds,tens,or units ?
|
||||
sprintf(string,"_%s%dx",M_Variant(value), thousandplex);
|
||||
found = Lookup(tr, string, ph_thousands);
|
||||
}
|
||||
if(found == 0)
|
||||
{
|
||||
sprintf(string,"_%s%d",M_Variant(value), thousandplex);
|
||||
|
||||
if(Lookup(tr, string, ph_thousands) == 0)
|
||||
{
|
||||
// repeat "thousand" if higher order names are not available
|
||||
sprintf(string,"_%dM1",value);
|
||||
if((found_value = Lookup(tr, string, ph_thousands)) == 0)
|
||||
Lookup(tr, "_0M1", ph_thousands);
|
||||
}
|
||||
}
|
||||
}
|
||||
sprintf(ph_out,"%s%s",ph_of,ph_thousands);
|
||||
return(found);
|
||||
return(found_value);
|
||||
}
|
||||
|
||||
|
||||
static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
{//========================================================================
|
||||
// Lookup a 2 digit number
|
||||
// control bit 0: tens and units (use special form of '1')
|
||||
// control bit 1: ordinal number
|
||||
// control bit 2: use feminine form of '2'
|
||||
// control bit 3: speak zero tens
|
||||
// control bit 0: ordinal number
|
||||
// control bit 1: tens and units (use special form of '1', LANG=de "eins")
|
||||
// control bit 2: tens and units only, no higher digits
|
||||
// control bit 3: use feminine form of '2' (for thousands
|
||||
// control bit 4: speak zero tens
|
||||
|
||||
int found;
|
||||
int ix;
|
||||
@@ -917,27 +943,34 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
found = 0;
|
||||
ph_ordinal[0] = 0;
|
||||
|
||||
if(control & 4)
|
||||
if(control & 8)
|
||||
{
|
||||
sprintf(string,"_%df",value);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
if(control & 2)
|
||||
else
|
||||
if(control & 1)
|
||||
{
|
||||
strcpy(ph_ordinal, ph_ordinal2);
|
||||
|
||||
sprintf(string,"_%do",value);
|
||||
if((found = Lookup(tr, string, ph_digits)) != 0)
|
||||
if(control & 4)
|
||||
{
|
||||
found_ordinal = 1;
|
||||
sprintf(string,"_%dox",value); // LANG=hu, special word for 1. 2. when there are no higher digits
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
if(found == 0)
|
||||
{
|
||||
sprintf(string,"_%do",value);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
found_ordinal = found;
|
||||
}
|
||||
|
||||
if(found == 0)
|
||||
{
|
||||
if((value == 1) && (control & 1))
|
||||
if((value == 1) && (control & 2))
|
||||
{
|
||||
if(Lookup(tr, "_1a", ph_out) != 0)
|
||||
if(Lookup(tr, "_1a", ph_out) != 0) // LANG=de, "eins"
|
||||
return(0);
|
||||
}
|
||||
sprintf(string,"_%d",value);
|
||||
@@ -946,7 +979,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
|
||||
// no, speak as tens+units
|
||||
|
||||
if((control & 8) && (value < 10))
|
||||
if((control & 0x10) && (value < 10))
|
||||
{
|
||||
// speak leading zero
|
||||
Lookup(tr, "_0", ph_tens);
|
||||
@@ -961,7 +994,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
{
|
||||
units = (value % 10);
|
||||
|
||||
if((control & 2) && ((units == 0) || (tr->langopts.numbers & 0x10)))
|
||||
if((control & 1) && ((units == 0) || (tr->langopts.numbers & 0x10)))
|
||||
{
|
||||
sprintf(string,"_%dXo",value / 10);
|
||||
if(Lookup(tr, string, ph_tens) != 0)
|
||||
@@ -987,13 +1020,13 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
if(units > 0)
|
||||
{
|
||||
found = 0;
|
||||
if(control & 4)
|
||||
if(control & 8)
|
||||
{
|
||||
// is there a variant form of this number?
|
||||
sprintf(string,"_%df",units);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
if((control & 2) && ((tr->langopts.numbers & 0x10) == 0))
|
||||
if((control & 1) && ((tr->langopts.numbers & 0x10) == 0))
|
||||
{
|
||||
// ordinal
|
||||
sprintf(string,"_%do",units);
|
||||
@@ -1011,7 +1044,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
}
|
||||
}
|
||||
|
||||
if((control & 2) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
|
||||
if((control & 1) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
|
||||
{
|
||||
if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & 0x10)))
|
||||
Lookup(tr, "_ord20", ph_ordinal);
|
||||
@@ -1071,7 +1104,9 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
// bit 1, ordinal number
|
||||
int found;
|
||||
int hundreds;
|
||||
int tensunits;
|
||||
int x;
|
||||
int exact;
|
||||
char string[12]; // for looking up entries in **_list
|
||||
char buf1[100];
|
||||
char buf2[100];
|
||||
@@ -1083,6 +1118,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
char ph_thousand_and[12];
|
||||
|
||||
hundreds = value / 100;
|
||||
tensunits = value % 100;
|
||||
buf1[0] = 0;
|
||||
|
||||
if(hundreds > 0)
|
||||
@@ -1091,7 +1127,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
ph_thousand_and[0] = 0;
|
||||
|
||||
found = 0;
|
||||
if((control & 2) && ((value % 100) == 0))
|
||||
if((control & 2) && (tensunits == 0))
|
||||
{
|
||||
// ordinal number, with no tens or units
|
||||
found = Lookup(tr, "_0Co", ph_100);
|
||||
@@ -1111,11 +1147,15 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
{
|
||||
ph_digits[0] = 0;
|
||||
|
||||
if(LookupThousands(tr, hundreds / 10, thousandplex+1, ph_10T) == 0)
|
||||
exact = 0;
|
||||
if ((value % 1000) == 0)
|
||||
exact = 1;
|
||||
|
||||
if(LookupThousands(tr, hundreds / 10, thousandplex+1, exact, ph_10T) == 0)
|
||||
{
|
||||
x = 0;
|
||||
if(tr->langopts.numbers2 & (1 << (thousandplex+1)))
|
||||
x = 4;
|
||||
x = 8; // use variant (feminine) for before thousands and millions
|
||||
LookupNum2(tr, hundreds/10, x, ph_digits);
|
||||
}
|
||||
|
||||
@@ -1141,10 +1181,11 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
suppress_null = 1;
|
||||
|
||||
found = 0;
|
||||
if((value % 1000) == 100)
|
||||
if(tensunits == 0)
|
||||
{
|
||||
// is there a special pronunciation for exactly 100 ?
|
||||
found = Lookup(tr, "_1C0", ph_digits);
|
||||
// is there a special pronunciation for exactly n00 ?
|
||||
sprintf(string,"_%dC0",hundreds);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
@@ -1158,7 +1199,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
}
|
||||
else
|
||||
{
|
||||
if((hundreds > 1) || ((tr->langopts.numbers & 0x400) == 0))
|
||||
if((hundreds > 1) || ((tr->langopts.numbers & NUM_OMIT_1_HUNDRED) == 0))
|
||||
{
|
||||
LookupNum2(tr, hundreds, 0, ph_digits);
|
||||
}
|
||||
@@ -1169,7 +1210,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
}
|
||||
|
||||
ph_hundred_and[0] = 0;
|
||||
if((tr->langopts.numbers & 0x40) && ((value % 100) != 0))
|
||||
if((tr->langopts.numbers & 0x40) && (tensunits != 0))
|
||||
{
|
||||
if((value > 100) || ((control & 1) && (thousandplex==0)))
|
||||
{
|
||||
@@ -1179,24 +1220,25 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
|
||||
|
||||
buf2[0] = 0;
|
||||
value = value % 100;
|
||||
|
||||
if((value != 0) || (suppress_null == 0))
|
||||
if((tensunits != 0) || (suppress_null == 0))
|
||||
{
|
||||
x = 0;
|
||||
if(thousandplex==0)
|
||||
{
|
||||
x = 1; // allow "eins" for 1 rather than "ein"
|
||||
x = 2; // allow "eins" for 1 rather than "ein"
|
||||
if(control & 2)
|
||||
x = 3; // ordinal number
|
||||
if((value < 100) && !(control & 1))
|
||||
x |= 4; // tens and units only, no higher digits
|
||||
}
|
||||
else
|
||||
{
|
||||
if(tr->langopts.numbers2 & (1 << thousandplex))
|
||||
x = 4; // use variant (feminine) for before thousands and millions
|
||||
x = 8; // use variant (feminine) for before thousands and millions
|
||||
}
|
||||
|
||||
if(LookupNum2(tr, value, x, buf2) != 0)
|
||||
if(LookupNum2(tr, tensunits, x, buf2) != 0)
|
||||
{
|
||||
if(tr->langopts.numbers & 0x80)
|
||||
ph_hundred_and[0] = 0; // don't put 'and' after 'hundred' if there's 'and' between tens and units
|
||||
@@ -1222,6 +1264,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
int suppress_null = 0;
|
||||
int decimal_point = 0;
|
||||
int thousandplex = 0;
|
||||
int thousands_exact = 1;
|
||||
int thousands_inc = 0;
|
||||
int prev_thousands = 0;
|
||||
int ordinal = 0;
|
||||
@@ -1238,6 +1281,8 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
char ph_buf[200];
|
||||
char ph_buf2[50];
|
||||
char suffix[20];
|
||||
char *wordptr;
|
||||
unsigned int dictflags[2];
|
||||
|
||||
static const char str_pause[2] = {phonPAUSE_NOLINK,0};
|
||||
|
||||
@@ -1253,6 +1298,16 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
// ordinal number is indicated by dot after the number
|
||||
ordinal = 2;
|
||||
word[ix] = ' ';
|
||||
|
||||
if(tr->translator_name == L('h','u'))
|
||||
{
|
||||
// lang=hu don't treat dot as ordinal indicator if the next word is a month name ($alt)
|
||||
dictflags[0] = 0;
|
||||
wordptr = &word[ix+2];
|
||||
LookupDictList(tr, &wordptr, ph_buf, dictflags, 0, NULL);
|
||||
if(dictflags[0] & FLAG_ALT_TRANS) // TEST
|
||||
ordinal = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1285,6 +1340,9 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
}
|
||||
}
|
||||
|
||||
if(wflags & FLAG_ORDINAL)
|
||||
ordinal = 2;
|
||||
|
||||
ph_append[0] = 0;
|
||||
ph_buf2[0] = 0;
|
||||
|
||||
@@ -1329,6 +1387,9 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
ix = n_digits + thousands_inc;
|
||||
while(isdigit(word[ix]) && isdigit(word[ix+1]) && isdigit(word[ix+2]))
|
||||
{
|
||||
if((word[ix] != '0') || (word[ix+1] != '0') || (word[ix+2] != '0'))
|
||||
thousands_exact = 0;
|
||||
|
||||
thousandplex++;
|
||||
if(word[ix+3] == tr->langopts.thousands_sep)
|
||||
ix += (3 + thousands_inc);
|
||||
@@ -1355,7 +1416,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
{
|
||||
if((thousandplex > 0) && (value < 1000))
|
||||
{
|
||||
if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex,ph_append)))
|
||||
if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex, thousands_exact, ph_append)))
|
||||
{
|
||||
// found an exact match for N thousand
|
||||
value = 0;
|
||||
@@ -1396,7 +1457,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
while(isdigit(word[n_digits+decimal_count]))
|
||||
decimal_count++;
|
||||
|
||||
if(decimal_count > 1)
|
||||
// if(decimal_count > 1)
|
||||
{
|
||||
max_decimal_count = 2;
|
||||
switch(decimal_mode = (tr->langopts.numbers & 0xe000))
|
||||
@@ -1420,9 +1481,8 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x2000:
|
||||
case 0xa000:
|
||||
// Italian decimal fractions
|
||||
case 0x2000: // italian, say "hundredths" is leading zero
|
||||
case 0xa000: // hungarian, always say "tenths" etc.
|
||||
if(decimal_count <= 4)
|
||||
{
|
||||
LookupNum3(tr, atoi(&word[n_digits]), ph_buf, 0,0,0);
|
||||
@@ -1454,8 +1514,9 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
|
||||
while(isdigit(c = word[n_digits]) && (strlen(ph_out) < (N_WORD_PHONEMES - 10)))
|
||||
{
|
||||
// speak any remaining decimal fraction digits individually
|
||||
value = word[n_digits++] - '0';
|
||||
LookupNum2(tr, value, 1, buf1);
|
||||
LookupNum2(tr, value, 2, buf1);
|
||||
strcat(ph_out,buf1);
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +247,9 @@ void SpectDisplay::RefreshDialogValues(int type)
|
||||
int ix;
|
||||
SpectFrame *sf;
|
||||
|
||||
if(spectseq == NULL)
|
||||
return;
|
||||
|
||||
sf = spectseq->frames[sframe];
|
||||
|
||||
spectseq->amplitude = formantdlg->t_amplitude->GetValue();
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.41.01 25.Aug.09";
|
||||
const char *version_string = "1.41.08 04.Oct.09";
|
||||
const int version_phdata = 0x014100;
|
||||
|
||||
int option_device_number = -1;
|
||||
|
||||
@@ -573,7 +573,7 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
|
||||
tr->langopts.param[LOPT_COMBINE_WORDS] = 99; // combine some prepositions with the following word
|
||||
|
||||
tr->langopts.numbers = 0x1009 + 0xa000 + NUM_ROMAN + 0x10000;
|
||||
tr->langopts.numbers = 0x1009 + 0xa000 + NUM_ROMAN + NUM_ROMAN_ORDINAL + NUM_ORDINAL_DOT + NUM_OMIT_1_HUNDRED;
|
||||
SetLetterVowel(tr,'y');
|
||||
tr->langopts.spelling_stress = 1;
|
||||
SetLengthMods(tr,3); // all equal
|
||||
@@ -946,8 +946,13 @@ SetLengthMods(tr,3); // all equal
|
||||
|
||||
tr->langopts.stress_rule = 0;
|
||||
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
|
||||
tr->letter_bits_offset = OFFSET_TAMIL;
|
||||
tr->langopts.numbers2 = NUM2_100000;
|
||||
|
||||
if(name2 == L('t','a'))
|
||||
{
|
||||
tr->letter_bits_offset = OFFSET_TAMIL;
|
||||
tr->langopts.numbers = 0x1;
|
||||
}
|
||||
if(name2 == L('m','r'))
|
||||
{
|
||||
tr->letter_bits_offset = OFFSET_DEVANAGARI;
|
||||
@@ -962,7 +967,6 @@ SetLengthMods(tr,3); // all equal
|
||||
{
|
||||
tr->letter_bits_offset = OFFSET_KANNADA;
|
||||
tr->langopts.numbers = 0x1;
|
||||
tr->langopts.numbers2 = NUM2_100000;
|
||||
}
|
||||
tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
|
||||
SetIndicLetters(tr); // call this after setting OFFSET_
|
||||
|
||||
+9
-1
@@ -615,7 +615,9 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
|
||||
ph_limit = &phonemes[N_WORD_PHONEMES];
|
||||
|
||||
// count the length of the word
|
||||
if(*word1 == ' ') word1++; // possibly a dot was replaced by space: $dot
|
||||
wordx = word1;
|
||||
|
||||
utf8_in(&first_char,wordx);
|
||||
word_length = 0;
|
||||
while((*wordx != 0) && (*wordx != ' '))
|
||||
@@ -641,6 +643,12 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
|
||||
else
|
||||
{
|
||||
found = LookupDictList(tr, &word1, phonemes, dictionary_flags, FLAG_ALLOW_TEXTMODE, wtab); // the original word
|
||||
|
||||
if((dictionary_flags[0] & FLAG_DOT) && (wordx[1] == '.'))
|
||||
{
|
||||
wordx[1] = ' '; // remove a Dot after this word
|
||||
}
|
||||
|
||||
if(dictionary_flags[0] & FLAG_TEXTMODE)
|
||||
{
|
||||
first_char = word1[0];
|
||||
@@ -1532,7 +1540,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
max_stress = -1;
|
||||
|
||||
found_dict_flag = 0;
|
||||
if(flags & FLAG_FOUND)
|
||||
if((flags & FLAG_FOUND) && !(flags & FLAG_TEXTMODE))
|
||||
found_dict_flag = SFLAG_DICTIONARY;
|
||||
|
||||
while((pre_pause > 0) && (n_ph_list2 < N_PHONEME_LIST-4))
|
||||
|
||||
+8
-2
@@ -101,6 +101,7 @@
|
||||
|
||||
#define FLAG_NO_TRACE 0x10000 // passed to TranslateRules() to suppress dictionary lookup printout
|
||||
#define FLAG_NO_PREFIX 0x20000
|
||||
#define FLAG_ORDINAL 0x40000 // passed to TranslateNumber() to indicate an ordinal number
|
||||
|
||||
// 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
|
||||
@@ -327,11 +328,15 @@ typedef struct {
|
||||
unsigned char *length_mods;
|
||||
unsigned char *length_mods0;
|
||||
|
||||
#define NUM_OMIT_1_HUNDRED 0x400
|
||||
#define NUM_19_HUNDRED 0x800
|
||||
#define NUM_ORDINAL_DOT 0x10000
|
||||
#define NUM_ROMAN 0x20000
|
||||
#define NUM_ROMAN_UC 0x40000
|
||||
#define NUM_NOPAUSE 0x80000
|
||||
#define NUM_ROMAN_AFTER 0x200000
|
||||
#define NUM_VIGESIMAL 0x400000
|
||||
#define NUM_ROMAN_AFTER 0x200000
|
||||
#define NUM_VIGESIMAL 0x400000
|
||||
#define NUM_ROMAN_ORDINAL 0x800000
|
||||
|
||||
// bits0-1=which numbers routine to use.
|
||||
// bit2= thousands separator must be space
|
||||
@@ -353,6 +358,7 @@ typedef struct {
|
||||
// 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
|
||||
int numbers;
|
||||
|
||||
#define NUM2_100000 0x800 // numbers for 100,000 and 10,000,000
|
||||
|
||||
+29
-5
@@ -277,14 +277,38 @@ void MakeWave2(PHONEME_LIST *p, int n_phonemes)
|
||||
TranslDlg::TranslDlg(wxWindow *parent) : wxPanel(parent)
|
||||
{//=====================================================
|
||||
|
||||
int height;
|
||||
int width;
|
||||
int x,y;
|
||||
int height_ph = 350;
|
||||
|
||||
wxTextAttr attr;
|
||||
wxFont font = wxFont(12,wxFONTFAMILY_ROMAN,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_LIGHT,false,_T(""),wxFONTENCODING_SYSTEM);
|
||||
|
||||
attr.SetFont(font);
|
||||
|
||||
wxClientDisplayRect(&x,&y,&width, &height);
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
if(height <= 768)
|
||||
height_ph = height - 416;
|
||||
#else
|
||||
if(height <= 800)
|
||||
height_ph = 280;
|
||||
#endif
|
||||
|
||||
|
||||
t_source = new wxTextCtrl(this,T_SOURCE,_T(""),wxPoint(0,4),
|
||||
wxSize(298,250),wxTE_MULTILINE);
|
||||
t_phonetic = new wxTextCtrl(this,T_PHONETIC,_T(""),wxPoint(0,262),
|
||||
wxSize(298,350),wxTE_MULTILINE);
|
||||
t_source->SetDefaultStyle(attr);
|
||||
|
||||
t_translate = new wxButton(this,T_TRANSLATE,_T("Translate"),wxPoint(4,620));
|
||||
t_translate = new wxButton(this,T_RULES,_T("Show Rules"),wxPoint(4,652));
|
||||
t_process = new wxButton(this,T_PROCESS,_T("Speak"),wxPoint(100,620));
|
||||
|
||||
t_phonetic = new wxTextCtrl(this,T_PHONETIC,_T(""),wxPoint(0,262),
|
||||
wxSize(298,height_ph),wxTE_MULTILINE | wxTE_READONLY);
|
||||
|
||||
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_process = new wxButton(this,T_PROCESS,_T("Speak"),wxPoint(100,y));
|
||||
|
||||
t_source->SetFocus();
|
||||
} // end of TransDlg::TransDlg
|
||||
|
||||
+5
-1
@@ -306,7 +306,11 @@ int wave_close(void* theHandler)
|
||||
int wave_is_busy(void* theHandler)
|
||||
{
|
||||
uint32_t time;
|
||||
wave_get_remaining_time(total_samples_sent - 1, &time);
|
||||
if (total_samples_sent >= 1) {
|
||||
wave_get_remaining_time(total_samples_sent - 1, &time);
|
||||
} else {
|
||||
time = 0;
|
||||
}
|
||||
return time != 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user