This commit is contained in:
Reece H. Dunn
2012-10-08 16:11:15 +01:00
parent 105b237951
commit d3cc69259c
170 changed files with 871 additions and 648 deletions
+5 -5
View File
@@ -10,17 +10,17 @@ SRCS= compiledata.cpp compiledict.cpp debug.cpp dictionary.cpp espeak_command.cp
OBJS=$(patsubst %.cpp,%.o,$(SRCS))
WX_LIBS = -pthread -lwx_gtk2u_xrc-2.6 -lwx_gtk2u_qa-2.6 -lwx_gtk2u_html-2.6 \
-lwx_gtk2u_adv-2.6 -lwx_gtk2u_core-2.6 -lwx_baseu_xml-2.6 -lwx_baseu_net-2.6 -lwx_baseu-2.6
WX_LIBS = -pthread -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 \
-lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8
LIBS=-lstdc++ -lportaudio
CPPFLAGS = -Wall -g -fexceptions -I/usr/lib/wx/include/gtk2-unicode-release-2.6
-I/usr/include/wx-2.6 \
CPPFLAGS = -Wall -g -fexceptions -I/usr/lib/wx/include/gtk2-unicode-release-2.8
-I/usr/include/wx-2.8 \
-DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
-D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA -D_ESPEAKEDIT
CXXFLAGS = -O2 -Wall -fexceptions -I/usr/lib/wx/include/gtk2-unicode-release-2.6 -I/usr/include/wx-2.6 \
CXXFLAGS = -O2 -Wall -fexceptions -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 \
-DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA -D_ESPEAKEDIT
all: espeakedit
+16 -2
View File
@@ -71,6 +71,7 @@ typedef struct {
#define k_AND 1
#define k_OR 2
#define k_THEN 3
#define k_NOT 4
#define kTHISSTRESS 0x800
@@ -90,6 +91,7 @@ static keywtab_t k_conditions[] = {
{"AND", 0, k_AND},
{"OR", 0, k_OR},
{"THEN", 0, k_THEN},
{"NOT", 0, k_NOT},
{"prevPh", tWHICH_PHONEME, 0},
{"prevPhW", tWHICH_PHONEME, 5},
{"thisPh", tWHICH_PHONEME, 1},
@@ -2257,10 +2259,11 @@ int CompileIf(int elif)
int key;
int finish = 0;
int word = 0;
int word2 = 0;
int word2;
int data;
int bitmap;
int brackets;
int not_flag;
USHORT *prog_last_if = NULL;
then_count = 2;
@@ -2268,6 +2271,8 @@ int CompileIf(int elif)
while(!finish)
{
not_flag = 0;
word2 = 0;
if(prog_out >= prog_out_max)
{
error("Phoneme program too large", NULL);
@@ -2277,6 +2282,13 @@ int CompileIf(int elif)
if((key = NextItem(tCONDITION)) < 0)
error("Expected a condition, not '%s'",item_string);
if((item_type == 0) && (key == k_NOT))
{
not_flag = 1;
if((key = NextItem(tCONDITION)) < 0)
error("Expected a condition, not '%s'",item_string);
}
if(item_type == tWHICH_PHONEME)
{
// prevPh(), thisPh(), nextPh(), next2Ph() etc
@@ -2331,7 +2343,9 @@ int CompileIf(int elif)
*prog_out++ = word | i_CONDITION;
if(word2 != 0)
*prog_out++ = word2;
*prog_out++ = word2;
if(not_flag)
*prog_out++ = i_NOT;
// expect AND, OR, THEN
switch(NextItem(tCONDITION))
+1 -1
View File
@@ -521,7 +521,7 @@ sprintf(outptr,"* ");
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,
0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x29f,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,0x261,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x303,0x7f
+146 -124
View File
@@ -21,7 +21,6 @@
#include "wx/wfstream.h"
#include "wx/notebook.h"
#include "wx/image.h"
#include "wx/filename.h"
#include "wx/numdlg.h"
@@ -74,8 +73,6 @@ extern void VowelChart(int control, char *fname);
extern void MakeVowelLists(void);
extern void MakeWordFreqList();
extern const char *dict_name;
extern wxMenu *speak_menu;
extern wxMenu *data_menu;
@@ -83,15 +80,16 @@ extern wxMenu *data_menu;
MyFrame *myframe = NULL;
SpectDisplay *currentcanvas = NULL;
ChildFrProsody *prosodyframe = NULL;
ProsodyDisplay *prosodycanvas = NULL;
wxNotebook *notebook = NULL;
wxNotebook *screenpages = NULL;
wxProgressDialog *progress;
int progress_max;
int gui_flag = 0;
int frame_x, frame_y, frame_w, frame_h;
wxList my_children;
int adding_page = 0; // fix for wxWidgets (2,8,7) bug, adding first page to a wxNotebook gives emptystring for GetPageTex() in Notebook_Page_Changed event.
wxFont FONT_SMALL(8,wxSWISS,wxNORMAL,wxNORMAL);
wxFont FONT_MEDIUM(9,wxSWISS,wxNORMAL,wxNORMAL);
@@ -166,7 +164,7 @@ if(argc > 1)
if((frame_w == 0) || (frame_h == 0))
{
frame_w = 1024;
frame_w = 800;
frame_h = 768;
}
@@ -191,7 +189,7 @@ if(argc > 1)
return TRUE;
}
BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_CHAR(MyFrame::OnKey)
EVT_MENU(MENU_ABOUT, MyFrame::OnAbout)
EVT_MENU(MENU_DOCS, MyFrame::OnAbout)
@@ -213,7 +211,6 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
EVT_MENU(MENU_SORT_DICTIONARY, MyFrame::OnTools)
EVT_MENU(MENU_COMPILE_MBROLA, MyFrame::OnTools)
EVT_MENU(MENU_COMPILE_INTONATION, MyFrame::OnTools)
EVT_MENU(MENU_CLOSE_ALL, MyFrame::OnQuit)
EVT_MENU(MENU_QUIT, MyFrame::OnQuit)
EVT_MENU(MENU_SPEAK_TRANSLATE, MyFrame::OnSpeak)
EVT_MENU(MENU_SPEAK_RULES, MyFrame::OnSpeak)
@@ -238,14 +235,22 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
EVT_MENU(MENU_TEST, MyFrame::OnTools)
EVT_MENU(MENU_TEST2, MyFrame::OnTools)
EVT_MENU(SPECTSEQ_SAVE, MyFrame::PageCmd)
EVT_MENU(SPECTSEQ_SAVEAS, MyFrame::PageCmd)
EVT_MENU(SPECTSEQ_SAVESELECT, MyFrame::PageCmd)
EVT_MENU(SPECTSEQ_CLOSE, MyFrame::PageCmd)
EVT_MENU(SPECTSEQ_SAVEPITCH, MyFrame::PageCmd)
EVT_MENU(MENU_CLOSE_ALL, MyFrame::PageCmd)
EVT_NOTEBOOK_PAGE_CHANGED(ID_SCREENPAGES, MyFrame::OnPageChanged)
EVT_TIMER(1, MyFrame::OnTimer)
EVT_SIZE(MyFrame::OnSize)
EVT_SASH_DRAGGED(ID_WINDOW_LEFT, MyFrame::OnSashDrag)
END_EVENT_TABLE()
MyFrame::~MyFrame(void)
{//====================
myframe->Maximize(false);
myframe->Show(false);
myframe->Iconize(false); // os=Windows, get the non-iconsized size
myframe->GetPosition(&frame_x, &frame_y);
@@ -254,7 +259,7 @@ MyFrame::~MyFrame(void)
MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style):
wxMDIParentFrame(parent, id, title, pos, size, style)
wxFrame(parent, id, title, pos, size, style)
{//===================================================================================================================
// Main Frame constructor
@@ -262,16 +267,7 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
int result;
int param;
// Another window to the left of the client window
m_leftWindow = new wxSashLayoutWindow(this, ID_WINDOW_LEFT,
wxDefaultPosition, wxSize(298, 30),
wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN);
m_leftWindow->SetDefaultSize(wxSize(310, 1000));
m_leftWindow->SetOrientation(wxLAYOUT_VERTICAL);
m_leftWindow->SetAlignment(wxLAYOUT_LEFT);
m_leftWindow->SetSashVisible(wxSASH_RIGHT, TRUE);
notebook = new wxNotebook(m_leftWindow,-1);
notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxSize(312,760));
// notebook->AddPage(voicedlg,_T("Voice"),FALSE);
formantdlg = new FormantDlg(notebook);
notebook->AddPage(formantdlg,_T(" Spect"),FALSE);
@@ -281,6 +277,29 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
notebook->AddPage(transldlg,_T("Text"),TRUE);
screenpages = new wxNotebook(this, ID_SCREENPAGES, wxDefaultPosition, wxSize(554,702));
wxBoxSizer *framesizer = new wxBoxSizer( wxHORIZONTAL );
framesizer->Add(
notebook,
0, // make horizontally stretchable
wxEXPAND | // make vertically stretchable
wxALL, // and make border all around
4 ); // set border width
framesizer->Add(
screenpages,
1, // make horizontally stretchable
wxEXPAND | // make vertically stretchable
wxALL, // and make border all around
4 ); // set border width
SetSizer( framesizer ); // use the sizer for layout
framesizer->SetSizeHints( this ); // set size hints to honour minimum size
SetSize(pos.x, pos.y, size.GetWidth(), size.GetHeight());
LoadConfig();
WavegenInitSound();
@@ -310,7 +329,7 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
for(param=0; param<N_SPEECH_PARAM; param++)
param_stack[0].parameter[param] = param_defaults[param];
SetParameter(espeakRATE,option_speed,0);
SetSpeed(3);
@@ -345,6 +364,110 @@ void MyFrame::SetVoiceTitle(char *voice_name)
void MyFrame::PageCmd(wxCommandEvent& event)
{//=========================================
int pagenum;
int ix;
int n_pages;
SpectDisplay *page;
// if(currentcanvas != NULL)
{
pagenum = screenpages->GetSelection();
switch(event.GetId())
{
case SPECTSEQ_SAVE:
currentcanvas->Save(currentcanvas->savepath);
break;
case SPECTSEQ_SAVEAS:
currentcanvas->Save();
break;
case SPECTSEQ_SAVESELECT:
currentcanvas->Save(_T(""), 1);
break;
case SPECTSEQ_CLOSE:
if(screenpages->GetPageText(pagenum) != _T("Prosody"))
{
currentcanvas->OnActivate(0);
}
screenpages->DeletePage(pagenum);
if((n_pages = screenpages->GetPageCount()) > 0)
{
if(pagenum >= n_pages)
pagenum--;
page = (SpectDisplay *)screenpages->GetPage(pagenum);
if(screenpages->GetPageText(pagenum) == _T("Prosody"))
{
MakeMenu(3, NULL);
}
else
{
page->OnActivate(1);
MakeMenu(2, NULL);
}
}
else
{
MakeMenu(1, NULL);
}
break;
case MENU_CLOSE_ALL:
n_pages = screenpages->GetPageCount();
for(ix=n_pages-1; ix>=0; ix--)
{
screenpages->DeletePage(ix);
}
currentcanvas = NULL;
MakeMenu(1, NULL);
break;
case SPECTSEQ_SAVEPITCH:
currentcanvas->SavePitchenv(currentcanvas->spectseq->pitchenv);
break;
}
}
}
void MyFrame::OnPageChanged(wxNotebookEvent& event)
{//=================================================
int pagenum;
wxString title;
SpectDisplay *page;
pagenum = event.GetSelection();
if(event.GetId() == ID_SCREENPAGES)
{
title = screenpages->GetPageText(pagenum);
if((title != _T("Prosody")) && (adding_page != 2))
{
page = (SpectDisplay *)screenpages->GetPage(pagenum);
if(page != currentcanvas)
{
if(currentcanvas != NULL)
{
currentcanvas->OnActivate(0);
}
page->OnActivate(1);
}
MakeMenu(2, NULL);
}
else
{
MakeMenu(3, NULL);
}
}
adding_page = 0; // work around for wxNotebook bug (version 2.8.7)
}
void MyFrame::OnKey(wxKeyEvent& event)
{
int key;
@@ -624,7 +747,7 @@ void MyFrame::OnTools(wxCommandEvent& event)
case MENU_COMPILE_INTONATION:
CompileIntonation();
break;
case MENU_COMPILE_DICT_DEBUG:
debug_flag =1; // and drop through to next case
case MENU_COMPILE_DICT:
@@ -729,105 +852,4 @@ void MyFrame::OnSpeak(wxCommandEvent& event)
}
void MyFrame::OnSashDrag(wxSashEvent& event)
{
int w, h;
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
return;
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();
}
void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event))
{
wxLayoutAlgorithm layout;
layout.LayoutMDIFrame(this);
}
// Note that SASHTEST_NEW_WINDOW and SASHTEST_ABOUT commands get passed
// to the parent window for processing, so no need to
// duplicate event handlers here.
BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
EVT_MENU(SPECTSEQ_CLOSE, MyChild::OnQuit)
EVT_MENU(SPECTSEQ_SAVE, MyChild::OnSave)
EVT_MENU(SPECTSEQ_SAVEAS, MyChild::OnSaveAs)
EVT_MENU(SPECTSEQ_SAVESELECT, MyChild::OnSaveSelect)
EVT_MENU(SPECTSEQ_SAVEPITCH, MyChild::OnSavePitchenv)
EVT_ACTIVATE(MyChild::OnActivate)
END_EVENT_TABLE()
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style):
wxMDIChildFrame(parent, -1, title, pos, size, style)
{
canvas = NULL;
my_children.Append(this);
}
MyChild::~MyChild(void)
{
canvas = NULL;
#ifndef PLATFORM_WINDOWS
wxWindow *w;
// bug in wxMDIChildFrame, we need to explicitly remove the ChildFrame from the ClientWindow
w = myframe->GetClientWindow();
w->RemoveChild(this);
#endif
my_children.DeleteObject(this);
}
//extern void CloseCanvas();
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Destroy();
}
void MyChild::OnSave(wxCommandEvent& WXUNUSED(event))
{
canvas->Save(canvas->savepath);
}
void MyChild::OnSaveAs(wxCommandEvent& WXUNUSED(event))
{
canvas->Save();
}
void MyChild::OnSaveSelect(wxCommandEvent& WXUNUSED(event))
{
canvas->Save(_T(""),1);
}
void MyChild::OnSavePitchenv(wxCommandEvent& WXUNUSED(event))
{
canvas->SavePitchenv(canvas->spectseq->pitchenv);
}
void MyChild::OnActivate(wxActivateEvent& event)
{
if(canvas)
canvas->OnActivate(event.GetActive());
}
+6 -6
View File
@@ -97,7 +97,7 @@ void FormantDlg::OnSpin(wxSpinEvent& event)
currentcanvas->SetFocus();
}
FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,wxSize(400,1000))
FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,wxSize(400,800))
{//=============================================================================================
int ix;
int y;
@@ -395,7 +395,7 @@ void FormantDlg::ShowFrame(SpectSeq *spectseq, int frame, int pk, int field)
{
value.Printf(_T("%3d"),peak->klt_bp);
t_klt_bp[ix]->SetValue(value);
}
}
}
}
@@ -469,12 +469,12 @@ void ByteGraph::DrawSpectrum(wxDC& dc)
numframes = seq->numframes;
if(numframes == 0) return;
GetClientSize(&width,&height);
if(((length = seq->frames[numframes-1]->time)==0) && (numframes>1))
length = seq->frames[numframes-2]->time;
length = length - seq->frames[0]->time;
yscale = height/3000.0;
@@ -518,7 +518,7 @@ void ByteGraph::OnDraw(wxDC &dc)
double xscale, yscale;
if(show_spectrum) DrawSpectrum(dc);
if(npoints==0) return;
GetClientSize(&width,&height);
@@ -559,7 +559,7 @@ void ByteGraph::OnMouse(wxMouseEvent& event)
wxPoint pt(event.GetLogicalPosition(dc));
t0 = t2 = seq->frames[0]->time;
time = (double(pt.x) / spectrum_scale) + t0;
for(ix=1; ix<seq->numframes; ix++)
{
t1=t2;
+17 -12
View File
@@ -2,6 +2,7 @@
#include "wx/toolbar.h"
#include "wx/laywin.h"
#include "wx/progdlg.h"
#include "wx/notebook.h"
typedef unsigned short USHORT;
typedef unsigned char UCHAR;
@@ -32,44 +33,45 @@ class MyApp: public wxApp
};
// Define a new frame
class MyFrame: public wxMDIParentFrame
class MyFrame: public wxFrame
{
public:
MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
~MyFrame(void);
void OnSize(wxSizeEvent& event);
void OnAbout(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void OnOptions(wxCommandEvent& event);
void OnSpeak(wxCommandEvent& event);
void OnSpeak(wxCommandEvent& event);
void OnTools(wxCommandEvent& event);
void OnSashDrag(wxSashEvent& event);
void OnKey(wxKeyEvent& event);
void OnTimer(wxTimerEvent& event);
void LoadWavFile(void);
void OnNewWindow(wxCommandEvent& event);
void OnProsody(wxCommandEvent& event);
void PageCmd(wxCommandEvent& event);
void SetVoiceTitle(char *voice_name);
void OnPageChanged(wxNotebookEvent& event);
protected:
wxSashLayoutWindow* m_leftWindow;
wxTimer m_timer;
DECLARE_EVENT_TABLE()
};
class MyChild: public wxMDIChildFrame
#ifdef deleted
class MyChild: public wxPanel
{
public:
SpectDisplay *canvas;
MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
MyChild(wxNotebook *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
~MyChild(void);
void OnActivate(wxActivateEvent& event);
void OnQuit(wxCommandEvent& event);
void OnSave(wxCommandEvent& event);
void OnSaveAs(wxCommandEvent& event);
@@ -79,7 +81,7 @@ class MyChild: public wxMDIChildFrame
DECLARE_EVENT_TABLE()
};
#endif
class TranslDlg : public wxPanel
@@ -103,6 +105,7 @@ private:
};
extern MyFrame *myframe;
extern wxNotebook* screenpages;
extern TranslDlg *transldlg;
extern wchar_t ipa1[256];
@@ -171,10 +174,12 @@ enum {
SPECTSEQ_SAVEAS,
SPECTSEQ_SAVESELECT,
SPECTSEQ_SAVEPITCH,
SPECTSEQ_VOICEDLG
SPECTSEQ_VOICEDLG,
ID_SCREENPAGES,
ID_NOTEBOOK
};
#define ID_WINDOW_LEFT 101
+101 -90
View File
@@ -24,10 +24,13 @@
wxMenu *speak_menu;
wxMenu *data_menu = NULL;
wxMenuBar *menu_bar = NULL;
wxMenuBar *MakeMenu(int type, const char *dict_name)
{//=================================================
{//===================================================
char buf[100];
wxMenu *old_menu;
wxMenu *file_menu;
wxMenu *help_menu;
wxMenu *option_menu = NULL;
@@ -42,118 +45,126 @@ wxMenuBar *MakeMenu(int type, const char *dict_name)
file_menu->Append(MENU_SPECTRUM, _("&Open..."));
file_menu->Append(MENU_SPECTRUM2, _("O&pen2..."));
// file_menu->Append(MENU_PROSODY, _T("&Prosody window"));
if(type==0)
if(type<=1)
{
}
else
if(type==1)
{
file_menu->Append(SPECTSEQ_SAVE, _("&Save"));
file_menu->Append(SPECTSEQ_SAVEAS, _("Save &As..."));
file_menu->Append(SPECTSEQ_SAVESELECT, _("Save Selection"));
file_menu->Append(SPECTSEQ_SAVEPITCH, _T("Save Pitch &Envelope"));
file_menu->Append(SPECTSEQ_CLOSE, _("&Close"));
// file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
}
else
if(type==2)
{
file_menu->Append(SPECTSEQ_SAVE, _("&Save"));
file_menu->Append(SPECTSEQ_SAVEAS, _("Save &As..."));
// file_menu->Append(SPECTSEQ_SAVEPITCH, _T("Save Pitch &Envelope"));
file_menu->Append(SPECTSEQ_SAVESELECT, _("Save Selection"));
file_menu->Append(SPECTSEQ_SAVEPITCH, _T("Save Pitch &Envelope"));
file_menu->Append(SPECTSEQ_CLOSE, _("&Close"));
// file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
}
else
if(type==3)
{
// file_menu->Append(SPECTSEQ_SAVE, _("&Save"));
// file_menu->Append(SPECTSEQ_SAVEAS, _("Save &As..."));
file_menu->Append(SPECTSEQ_CLOSE, _("&Close"));
file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
}
file_menu->Append(MENU_QUIT, _("&Quit"));
// SPEAK_MENU
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..."));
speak_menu->Append(MENU_SPEAK_PAUSE, _("&Pause"));
speak_menu->Append(MENU_SPEAK_STOP, _("St&op"));
if(type==0)
{
// Initialization, make all the menus
// SPEAK_MENU
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..."));
speak_menu->Append(MENU_SPEAK_PAUSE, _("&Pause"));
speak_menu->Append(MENU_SPEAK_STOP, _("St&op"));
// VOICE MENU
voice_menu = new wxMenu;
voice_menu->Append(MENU_SPEAK_VOICE, _("Select &Voice.."));
voice_menu->Append(MENU_SPEAK_VOICE_VARIANT, _("Select Voice Va&riant..."));
// VOICE MENU
voice_menu = new wxMenu;
voice_menu->Append(MENU_SPEAK_VOICE, _("Select &Voice.."));
voice_menu->Append(MENU_SPEAK_VOICE_VARIANT, _("Select Voice Va&riant..."));
// DATA MENU
data_menu = new wxMenu;
data_menu->Append(MENU_COMPILE_PH, _("Compile &phoneme data"));
data_menu->Append(MENU_COMPILE_DICT, _("Compile &dictionary"));
data_menu->Append(MENU_COMPILE_DICT_DEBUG, _("Compile dictionary (debu&g)"));
data_menu->AppendSeparator();
data_menu->Append(MENU_COMPILE_MBROLA, _("Compile &mbrola phonemes list..."));
data_menu->Append(MENU_COMPILE_INTONATION, _("Compile &intonation data"));
data_menu->AppendSeparator();
data_menu->Append(MENU_FORMAT_DICTIONARY, _("&Layout *_rules file"));
data_menu->Append(MENU_SORT_DICTIONARY, _("&Sort *_rules file"));
// DATA MENU
data_menu = new wxMenu;
data_menu->Append(MENU_COMPILE_PH, _("Compile &phoneme data"));
data_menu->Append(MENU_COMPILE_DICT, _("Compile &dictionary"));
data_menu->Append(MENU_COMPILE_DICT_DEBUG, _("Compile dictionary (debu&g)"));
data_menu->AppendSeparator();
data_menu->Append(MENU_COMPILE_MBROLA, _("Compile &mbrola phonemes list..."));
data_menu->Append(MENU_COMPILE_INTONATION, _("Compile &intonation data"));
data_menu->AppendSeparator();
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));
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..."));
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..."));
paths_menu->AppendSeparator();
paths_menu->Append(MENU_PATH4, _("Voice file to modify formant peaks..."));
// 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..."));
paths_menu->AppendSeparator();
paths_menu->Append(MENU_PATH4, _("Voice file to modify formant peaks..."));
option_menu = new wxMenu;
option_menu->Append(MENU_PATHS, _("Set &paths"), paths_menu);
option_menu->Append(MENU_OPT_SPEED, _("Speed..."));
option_menu->Append(MENU_OPT_PUNCT, _("Speak punctiation"));
option_menu->Append(MENU_OPT_SPELL, _("Speak character names"));
option_menu = new wxMenu;
option_menu->Append(MENU_PATHS, _("Set &paths"), paths_menu);
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;
vowelchart_menu->Append(MENU_VOWELCHART1, _("From compiled phoneme data"));
// vowelchart_menu->Append(MENU_VOWELCHART2, _("From list of formants..."));
vowelchart_menu->Append(MENU_VOWELCHART3, _("From directory of vowel files..."));
// TOOLS
vowelchart_menu = new wxMenu;
vowelchart_menu->Append(MENU_VOWELCHART1, _("From compiled phoneme data"));
// vowelchart_menu->Append(MENU_VOWELCHART2, _("From list of formants..."));
vowelchart_menu->Append(MENU_VOWELCHART3, _("From directory of vowel files..."));
lexicon_menu = new wxMenu;
lexicon_menu->Append(MENU_LEXICON_RU, _("Russian"));
lexicon_menu->Append(MENU_LEXICON_BG, _("Bulgarian"));
lexicon_menu->Append(MENU_LEXICON_DE, _("German"));
lexicon_menu->Append(MENU_LEXICON_IT, _("Italian"));
// lexicon_menu->Append(MENU_LEXICON_TEST, _("Test"));
lexicon_menu = new wxMenu;
lexicon_menu->Append(MENU_LEXICON_RU, _("Russian"));
lexicon_menu->Append(MENU_LEXICON_BG, _("Bulgarian"));
lexicon_menu->Append(MENU_LEXICON_DE, _("German"));
lexicon_menu->Append(MENU_LEXICON_IT, _("Italian"));
// lexicon_menu->Append(MENU_LEXICON_TEST, _("Test"));
tools_menu = new wxMenu;
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, _("Process &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)"));
// tools_menu->Append(MENU_TEST2 , _T("Test2"));
tools_menu = new wxMenu;
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, _("Process &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)"));
// tools_menu->Append(MENU_TEST2 , _T("Test2"));
// HELP MENU
help_menu = new wxMenu;
help_menu->Append(MENU_DOCS, _("eSpeak &Documentation"));
help_menu->Append(MENU_ABOUT, _("&About"));
// HELP MENU
help_menu = new wxMenu;
help_menu->Append(MENU_DOCS, _("eSpeak &Documentation"));
help_menu->Append(MENU_ABOUT, _("&About"));
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, _("&File"));
menu_bar->Append(speak_menu, _("&Speak"));
menu_bar->Append(voice_menu, _("&Voice"));
menu_bar->Append(option_menu, _("&Options"));
menu_bar->Append(tools_menu, _("&Tools"));
menu_bar->Append(data_menu, _("&Compile"));
menu_bar->Append(help_menu, _("&Help"));
menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, _("&File"));
menu_bar->Append(speak_menu, _("&Speak"));
menu_bar->Append(voice_menu, _("&Voice"));
menu_bar->Append(option_menu, _("&Options"));
menu_bar->Append(tools_menu, _("&Tools"));
menu_bar->Append(data_menu, _("&Compile"));
menu_bar->Append(help_menu, _("&Help"));
}
else
{
// Just replace the File menu
old_menu = menu_bar->Replace(0, file_menu, _("&File"));
delete old_menu;
}
return(menu_bar);
} // end of MakeMenu
+64 -18
View File
@@ -1137,8 +1137,8 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou
} // end f LookupThousands
static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
{//========================================================================
static int LookupNum2(Translator *tr, int value, const int control, char *ph_out)
{//=============================================================================
// Lookup a 2 digit number
// control bit 0: ordinal number
// control bit 1: final tens and units (not number of thousands) (use special form of '1', LANG=de "eins")
@@ -1151,6 +1151,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
int ix;
int units;
int tens;
int is_ordinal;
int used_and=0;
int found_ordinal = 0;
int next_phtype;
@@ -1175,6 +1176,8 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
ord_type = 'q';
}
is_ordinal = control & 1;
if((control & 2) && (n_digit_lookup == 2))
{
// pronunciation of the final 2 digits has already been found
@@ -1187,11 +1190,12 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
// is there a special pronunciation for this 2-digit number
if(control & 8)
{
// is there a feminine form?
sprintf(string,"_%df",value);
found = Lookup(tr, string, ph_digits);
}
else
if(control & 1)
if(is_ordinal)
{
strcpy(ph_ordinal, ph_ordinal2);
@@ -1229,8 +1233,15 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
if(!found)
{
sprintf(string,"_%d",value);
found = Lookup(tr, string, ph_digits);
if((is_ordinal) && (tr->langopts.numbers2 & NUM2_NO_TEEN_ORDINALS))
{
// don't use numbers 10-99 to make ordinals, always use _1Xo etc (lang=pt)
}
else
{
sprintf(string,"_%d",value);
found = Lookup(tr, string, ph_digits);
}
}
}
}
@@ -1251,7 +1262,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
else
{
if((control & 1) &&
if((is_ordinal) &&
((units == 0) || (tr->langopts.numbers & NUM_SWAP_TENS) || (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL)))
{
sprintf(string,"_%dX%c", tens, ord_type);
@@ -1300,7 +1311,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
sprintf(string,"_%df",units);
found = Lookup(tr, string, ph_digits);
}
if((control & 1) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
if((is_ordinal) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
{
// ordinal
sprintf(string,"_%d%c",units,ord_type);
@@ -1335,7 +1346,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
}
}
if((control & 1) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
if((is_ordinal) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
{
if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
Lookup(tr, "_ord20", ph_ordinal);
@@ -1347,7 +1358,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
{
Lookup(tr, "_0and", ph_and);
if((control & 1) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
if((is_ordinal) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
ph_and[0] = 0;
if(tr->langopts.numbers & NUM_SWAP_TENS)
@@ -1406,6 +1417,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
int ix;
int exact;
int ordinal;
int tplex;
int say_zero_hundred=0;
char string[12]; // for looking up entries in **_list
char buf1[100];
@@ -1465,10 +1477,16 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
if ((value % 1000) == 0)
exact = 1;
if(LookupThousands(tr, hundreds / 10, thousandplex+1, exact | ordinal, ph_10T) == 0)
tplex = thousandplex+1;
if(tr->langopts.numbers2 & NUM2_MYRIADS)
{
tplex = 0;
}
if(LookupThousands(tr, hundreds / 10, tplex, exact | ordinal, ph_10T) == 0)
{
x = 0;
if(tr->langopts.numbers2 & (1 << (thousandplex+1)))
if(tr->langopts.numbers2 & (1 << tplex))
x = 8; // use variant (feminine) for before thousands and millions
LookupNum2(tr, hundreds/10, x, ph_digits);
}
@@ -1615,6 +1633,23 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
} // end of LookupNum3
bool CheckThousandsGroup(char *word, int group_len)
{//================================================
// Is this a group of 3 digits which looks like a thousands group?
int ix;
if(isdigit(word[group_len]) || isdigit(-1))
return(false);
for(ix=0; ix < group_len; ix++)
{
if(!isdigit(word[ix]))
return(false);
}
return(true);
}
static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control)
{//=====================================================================================================================
// Number translation with various options
@@ -1640,6 +1675,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
int decimal_mode;
int suffix_ix;
int skipwords = 0;
int group_len;
char *p;
char string[32]; // for looking up entries in **_list
char buf1[100];
@@ -1662,8 +1698,12 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
n_digits = ix;
value = this_value = atoi(word);
group_len = 3;
if(tr->langopts.numbers2 & NUM2_MYRIADS)
group_len = 4;
// is there a previous thousands part (as a previous "word") ?
if((n_digits == 3) && (word[-2] == tr->langopts.thousands_sep) && isdigit(word[-3]))
if((n_digits == group_len) && (word[-2] == tr->langopts.thousands_sep) && isdigit(word[-3]))
{
prev_thousands = 1;
}
@@ -1777,14 +1817,19 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
// a "thousand"/"million" suffix to this one
digix = n_digits + thousands_inc;
while(((wtab[thousandplex+1].flags & FLAG_MULTIPLE_SPACES) == 0) &&
isdigit(word[digix]) && isdigit(word[digix+1]) && isdigit(word[digix+2]) && !isdigit(word[digix+3]) && !isdigit(word[digix-1]))
while(((wtab[thousandplex+1].flags & FLAG_MULTIPLE_SPACES) == 0) && CheckThousandsGroup(&word[digix], group_len))
{
if((word[digix] != '0') || (word[digix+1] != '0') || (word[digix+2] != '0'))
thousands_exact = 0;
for(ix=0; ix<group_len; ix++)
{
if(word[digix+ix] != '0')
{
thousands_exact = 0;
break;
}
}
thousandplex++;
digix += 3;
digix += group_len;
if((word[digix] == tr->langopts.thousands_sep) || ((tr->langopts.numbers & NUM_ALLOW_SPACE) && (word[digix] == ' ')))
{
suffix_ix = digix+2;
@@ -1820,7 +1865,8 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
{
if(thousands_inc > 0)
{
if((thousandplex > 0) && (value < 1000))
if(thousandplex > 0)
// if((thousandplex > 0) && (value < 1000))
{
if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex, thousands_exact, ph_append)))
{
+38 -79
View File
@@ -31,7 +31,6 @@
#include "translate.h"
extern MyFrame *myframe;
extern ChildFrProsody *prosodyframe;
extern ProsodyDisplay *prosodycanvas;
wxMenu *menu_prosody;
@@ -60,6 +59,7 @@ ProsodyDisplay::ProsodyDisplay(wxWindow *parent, const wxPoint& pos, const wxSiz
scalex = 0.5;
scaley = double(LINESEP*6)/150.0;
selected_ph = -1;
SetBackgroundColour(wxColour(245,245,245));
} // end of ProsodyDisplay::ProsodyDisplay
@@ -119,7 +119,7 @@ void ProsodyDisplay::RefreshLine(int line)
int ProsodyDisplay::GetWidth(PHONEME_LIST *p)
{//========================================
int w;
if(p->ph == NULL)
return(0);
@@ -279,7 +279,7 @@ void ProsodyDisplay::OnKey(wxKeyEvent& event)
{//========================================
PHONEME_LIST *p;
int display=1;
if(selected_ph < 0)
selected_ph = 0;
@@ -301,7 +301,7 @@ void ProsodyDisplay::OnKey(wxKeyEvent& event)
if(selected_ph < (numph-2))
selected_ph++;
break;
case WXK_UP:
if(event.ControlDown())
ChangePh(-1,2);
@@ -360,7 +360,7 @@ void ProsodyDisplay::DrawEnv(wxDC& dc, int x1, int y1, int width, PHONEME_LIST *
PHONEME_DATA phdata_tone;
if(width <= 0) return;
if((pitchr = ph->pitch2 - ph->pitch1) < 0)
{
pitchr = -pitchr;
@@ -425,6 +425,7 @@ void ProsodyDisplay::DrawPitchline(wxDC& dc, int line, int x1, int x2)
y = LINEBASE+LINESEP;
dc.SetPen(*wxLIGHT_GREY_PEN);
// dc.SetPen(*wxCYAN_PEN);
for(ix=0; ix<5; ix++)
{
dc.DrawLine(0,offy-y,linewidth,offy-y);
@@ -520,6 +521,12 @@ void ProsodyDisplay::OnDraw(wxDC& dc)
int line, start, end;
GetClientSize(&x1, &y1);
if(x1 != linewidth)
{
LayoutData(NULL, 0);
}
wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
while (upd)
@@ -549,15 +556,18 @@ void ProsodyDisplay::LayoutData(PHONEME_LIST *ph_list, int n_ph)
int xpos;
int w;
int ix;
int height;
PHONEME_LIST *p;
numph = n_ph;
phlist = ph_list;
if(ph_list != NULL)
{
numph = n_ph;
phlist = ph_list;
}
num_lines = 0;
linetab[0] = 1;
GetClientSize(&linewidth, &height);
xpos = linewidth;
// could improve this to do 'wordwrap' - only split on word boundary
@@ -584,86 +594,35 @@ void ProsodyDisplay::LayoutData(PHONEME_LIST *ph_list, int n_ph)
} // end of ProsodyDisplay::LayoutData
extern int adding_page;
void MyFrame::OnProsody(wxCommandEvent& WXUNUSED(event))
{//=====================================================
// Open the Prosody display window
// Make another frame, containing a canvas
int width, height;
int ix, npages;
int h, w, w2;
if(prosodyframe != NULL)
if(prosodycanvas != NULL)
{
// The Prosody window is already open
prosodyframe->Activate();
// ?? select the prosody page ??
npages = screenpages->GetPageCount();
for(ix=0; ix<npages; ix++)
{
if(screenpages->GetPage(ix) == (wxWindow*)prosodycanvas)
{
screenpages->ChangeSelection(ix);
break;
}
}
return;
}
m_leftWindow->GetSize(&w2, &h);
GetClientSize(&w, &h);
prosodyframe = new ChildFrProsody(myframe, _T(""),
wxPoint(0, 100), wxSize(w-w2, 420),
wxDEFAULT_FRAME_STYLE |
wxNO_FULL_REPAINT_ON_RESIZE);
prosodyframe->SetTitle(_T("Prosody"));
// Give it a status line
prosodyframe->CreateStatusBar();
int width, height;
wxMDIClientWindow *clientwin = (wxMDIClientWindow *)this->GetClientWindow();
clientwin->GetClientSize(&width, &height);
#ifdef deleted
wxPanel *panel = new wxPanel(prosodyframe,-1,wxPoint(0,0), wxSize(width,50));
ProsodyDisplay *canvas = new ProsodyDisplay(prosodyframe, wxPoint(0, 50), wxSize(width-2, height-50));
#else
ProsodyDisplay *canvas = new ProsodyDisplay(prosodyframe, wxPoint(0, 50), wxSize(width-10, height));
#endif
prosodycanvas = canvas;
// Associate the menu bar with the frame
prosodyframe->SetMenuBar(MakeMenu(2,translator->dictionary_name));
prosodyframe->prosodycanvas = canvas;
prosodyframe->Show(TRUE);
screenpages->GetClientSize(&width, &height);
prosodycanvas = new ProsodyDisplay(screenpages, wxPoint(0, 50), wxSize(width-10, height));
adding_page = 2; // work around for wxNotebook bug (version 2.8.7)
screenpages->AddPage(prosodycanvas, _T("Prosody"), true);
}
BEGIN_EVENT_TABLE(ChildFrProsody, wxMDIChildFrame)
EVT_MENU(SPECTSEQ_CLOSE, ChildFrProsody::OnQuit)
// EVT_ACTIVATE(ChildFrProsody::OnActivate)
END_EVENT_TABLE()
extern wxList my_children;
ChildFrProsody::ChildFrProsody(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style):
wxMDIChildFrame(parent, -1, title, pos, size, style)
{
my_children.Append(this);
}
ChildFrProsody::~ChildFrProsody(void)
{
wxWindow *w;
my_children.DeleteObject(this);
prosodycanvas = NULL;
prosodyframe = NULL;
#ifndef PLATFORM_WINDOWS
// bug in wxMDIChildFrame, we need to explicitly remove the ChildFrame from the ClientWindow
w = myframe->GetClientWindow();
w->RemoveChild(this);
#endif
}
void ChildFrProsody::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
+2 -16
View File
@@ -15,7 +15,7 @@ class ProsodyDisplay: public wxScrolledWindow
public:
ProsodyDisplay(wxWindow *parent, const wxPoint& pos, const wxSize& size);
~ProsodyDisplay();
virtual void OnDraw(wxDC& dc);
void OnMouse(wxMouseEvent& event);
void OnKey(wxKeyEvent& event);
@@ -32,7 +32,7 @@ class ProsodyDisplay: public wxScrolledWindow
int GetWidth(PHONEME_LIST *p);
void ChangePh(int pitch1, int pitch2);
void SelectPh(int index);
int linewidth; // height for drawing pitch
double scalex; // scale length values
double scaley; // scale pitch values
@@ -47,18 +47,4 @@ class ProsodyDisplay: public wxScrolledWindow
}; // end class ProsodyDisplay
class ChildFrProsody: public wxMDIChildFrame
{
public:
ProsodyDisplay *prosodycanvas;
ChildFrProsody(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
~ChildFrProsody(void);
void OnActivate(wxActivateEvent& event);
void OnQuit(wxCommandEvent& event);
void OnSave(wxCommandEvent& event);
void OnSaveAs(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
+2 -2
View File
@@ -121,7 +121,7 @@ typedef struct {
PEAKS7 peak_data[7];
unsigned char data[1]; /* firstly harmonic data, then f3,f4,f5 data */
} CYCLE; /* VARIABLE LENGTH Structure */
extern int SPC2_size_cycle(CYCLE *cy);
//==============================================================================================
@@ -142,7 +142,7 @@ public:
void CopyPeaks(SpectFrame *sf);
void ToggleMarker(int n);
void ApplyVoiceMods();
void MakeWaveF(int peaks, PitchEnvelope &pitch, int amplitude, int duration);
void MakeHtab(int numh, int *htab, int pitch);
double GetRms(int amp);
+18 -57
View File
@@ -42,9 +42,6 @@
extern MyFrame *frame ;
#define SCROLLUNITS 20
#define N_CANVASLIST 50
static int canvaslistix=0;
static SpectDisplay *canvaslist[N_CANVASLIST];
SpectSeq *clipboard_spect=NULL;
wxMenu *menu_spectdisplay=NULL;
@@ -77,37 +74,14 @@ SpectDisplay::SpectDisplay(wxWindow *parent, const wxPoint& pos, const wxSize& s
pk_num = 1;
SetExtent();
if(canvaslistix < N_CANVASLIST-1)
canvaslist[canvaslistix++] = this;
// WavegenInitPkData(0);
} // end of SpectDisplay::SpectDisplay
SpectDisplay::~SpectDisplay()
{//==========================
// delete this from the canvaslist
int ix;
for(ix=0; ix<canvaslistix; ix++)
{
if(canvaslist[ix] == this)
{
for(ix=ix+1; ix<canvaslistix; ix++)
canvaslist[ix-1] = canvaslist[ix];
canvaslistix--;
break;
}
}
if(currentcanvas==this)
{
if(canvaslistix > 0)
currentcanvas = canvaslist[0];
else
currentcanvas = NULL;
}
// ?? change currentcanvas
}
@@ -174,6 +148,7 @@ void SpectDisplay::OnActivate(int active)
{
formantdlg->GetValues(spectseq, sframe);
ReadDialogValues();
currentcanvas = NULL;
}
}
@@ -209,7 +184,7 @@ int GetNumeric(wxTextCtrl *t)
void SpectDisplay::WriteDialogLength()
{//===================================
wxString string;
string.Printf(_T("%d mS"),int(spectseq->GetKeyedLength()+0.5));
formantdlg->t_orig_seq->SetLabel(string);
}
@@ -220,7 +195,7 @@ void SpectDisplay::WriteDialogValues()
//{===============================
{
wxString string;
SetSpinCtrl(formantdlg->t_amplitude,spectseq->amplitude);
string.Printf(_T("%d - %d Hz %d mS"),
@@ -229,7 +204,7 @@ void SpectDisplay::WriteDialogValues()
pitchgraph->SetData(128,spectseq->pitchenv.env);
voicedlg->SetFromSpect(spectseq);
WriteDialogLength();
}
@@ -456,15 +431,13 @@ void SpectDisplay::SavePitchenv(PitchEnvelope &pitch)
} // end of SpectDisplay::SavePitchenv
// WX_DECLARE_LIST(MyChild,ChildList);
// WX_DEFINE_LIST(ChildList);
void SpectDisplay::PlayChild(int number, PitchEnvelope pitchenv)
{//=========================================================
#ifdef deleted
SpectSeq *seq;
if(number >= canvaslistix) return;
if((seq = canvaslist[number]->spectseq) == NULL)
@@ -472,6 +445,7 @@ void SpectDisplay::PlayChild(int number, PitchEnvelope pitchenv)
ReadDialogValues();
seq->MakeWave(0,seq->numframes-1,pitchenv);
#endif
} // end of PlayChild
@@ -481,7 +455,7 @@ void SpectDisplay::SetKeyframe(SpectFrame *sf, int yes)
sf->keyframe = yes;
pitchgraph->Refresh();
WriteDialogLength();
}
@@ -731,7 +705,7 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
spectseq->bass_reduction ^= 1;
Refresh();
break;
case 0x1043: // CTRL-C
spectseq->ClipboardCopy();
break;
@@ -923,6 +897,7 @@ void SpectDisplay::OnMouse(wxMouseEvent& event)
int frame;
int ix;
SetFocus();
if(event.RightDown())
{
PopupMenu(menu_spectdisplay);
@@ -935,7 +910,7 @@ void SpectDisplay::OnMouse(wxMouseEvent& event)
wxPoint pt(event.GetLogicalPosition(dc));
if(spectseq->numframes==0) return;
frame = (int)(pt.y/(FRAME_HEIGHT*zoomy));
if(!event.ControlDown())
@@ -1018,30 +993,16 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
else
path_spectload2 = path.GetPath();
// Make another frame, containing a canvas
GetClientSize(&width, &height);
MyChild *subframe = new MyChild(myframe, _T("Spectrum"),
wxPoint(10, 0), wxSize(500, height),
wxDEFAULT_FRAME_STYLE |
wxNO_FULL_REPAINT_ON_RESIZE);
subframe->SetTitle(leaf);
// Give it a status line
subframe->CreateStatusBar();
subframe->GetClientSize(&width, &height);
SpectDisplay *canvas = new SpectDisplay(subframe, wxPoint(0, 0), wxSize(width, height), spectseq);
SpectDisplay *canvas = new SpectDisplay(screenpages, wxDefaultPosition, wxSize(width, height), spectseq);
screenpages->AddPage(canvas, leaf, true);
canvas->savepath = filename;
currentcanvas = canvas;
// Associate the menu bar with the frame
subframe->SetMenuBar(MakeMenu(1,translator->dictionary_name));
subframe->canvas = canvas;
subframe->Show(TRUE);
currentcanvas = canvas;
}
void InitSpectrumDisplay()
{//=======================
wxMenu *menu_markers = new wxMenu;
+48 -23
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.46.24 11.Sep.12";
const char *version_string = "1.46.26 17.Sep.12";
const int version_phdata = 0x014624;
int option_device_number = -1;
@@ -881,39 +881,57 @@ static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT
} // end of SwitchVowelType
static int NumInstnWords(USHORT *prog)
{//===================================
int NumInstnWords(USHORT *prog)
{//============================
int instn;
int instn2;
int instn_type;
int n;
static const char n_words[16] = {1,1,0,0,1,1,1,1,1,2,4,0,0,0,0,0};
int type2;
static const char n_words[16] = {0,1,0,0,1,1,0,1,1,2,4,0,0,0,0,0};
instn = *prog;
instn_type = instn >> 12;
if((n = n_words[instn_type]) > 0)
return(n);
if(instn_type < 4)
switch(instn_type)
{
case 0:
if(((instn & 0xf00) >> 8) == i_IPA_NAME)
{
n = ((instn & 0xff) + 1) / 2;
return(n+1);
}
return(1);;
case 6:
type2 = (instn & 0xf00) >> 9;
if((type2 == 5) || (type2 == 6))
return(12); // switch on vowel type
return(1);
case 2:
case 3:
// a condition, check for a 2-word instruction
if(((n = instn & 0x0f00) == 0x600) || (n == 0x0d00))
return(2);
return(1);
}
// instn_type 11 to 15, 2 words
instn2 = prog[2];
if((instn2 >> 12) == 0xf)
{
// This instruction is followed by addWav(), 2 more words
return(4);
default:
// instn_type 11 to 15, 2 words
instn2 = prog[2];
if((instn2 >> 12) == 0xf)
{
// This instruction is followed by addWav(), 2 more words
return(4);
}
if(instn2 == i_CONTINUE)
{
return(3);
}
return(2);
}
if(instn2 == i_CONTINUE)
{
return(3);
}
return(2);
} // end of NumInstnWords
@@ -929,6 +947,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
int instn2;
int or_flag;
bool truth;
bool truth2;
int data;
int end_flag;
int ix;
@@ -1044,14 +1063,20 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
while((instn & 0xe000) == 0x2000)
{
// process a sequence of conditions, using boolean accumulator
if(or_flag)
truth = (truth || InterpretCondition(tr, control, plist, prog, worddata));
else
truth = (truth && InterpretCondition(tr, control, plist, prog, worddata));
or_flag = instn & 0x1000;
truth2 = InterpretCondition(tr, control, plist, prog, worddata);
prog += NumInstnWords(prog);
if(*prog == i_NOT)
{
truth2 = truth2 ^ 1;
prog++;
}
if(or_flag)
truth = truth || truth2;
else
truth = truth && truth2;
or_flag = instn & 0x1000;
instn = *prog;
// instn = *(++prog);
}
if(truth == false)
+2
View File
@@ -273,6 +273,7 @@ typedef struct {
#define i_RETURN 0x0001
#define i_CONTINUE 0x0002
#define i_NOT 0x0003
// Group 0 instrcutions with 8 bit operand. These values go into bits 8-15 of the instruction
#define i_CHANGE_PHONEME 0x01
@@ -570,6 +571,7 @@ int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_L
int PauseLength(int pause, int control);
int LookupPhonemeTable(const char *name);
unsigned char *GetEnvelope(int index);
int NumInstnWords(USHORT *prog);
void InitBreath(void);
+4 -1
View File
@@ -957,6 +957,9 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
tr->langopts.numbers2 = NUM2_MYRIADS;
tr->langopts.break_numbers = 0x1111110;
tr->langopts.max_digits = 20;
}
break;
@@ -1113,7 +1116,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
tr->langopts.stress_flags = 0x6 | 0x10 | 0x2000 | 0x20000;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN;
tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL;
tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS;
SetLetterVowel(tr,'y');
ResetLetterBits(tr,0x2);
SetLetterBits(tr,1,"bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
+2 -1
View File
@@ -3206,7 +3206,8 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
break;
*pn++ = c;
if((--nx > 0) && (tr->langopts.break_numbers & (1 << nx)))
nx--;
if((nx > 0) && (tr->langopts.break_numbers & (1 << nx)))
{
memcpy(&num_wtab[nw++], &words[ix], sizeof(WORD_TAB)); // copy the 'words' entry for each word of numbers
+6 -2
View File
@@ -445,7 +445,9 @@ typedef struct {
int numbers;
#define NUM2_MULTIPLE_ORDINAL 0x1000
#define NUM2_ENGLISH_NUMERALS 0x2000
#define NUM2_NO_TEEN_ORDINALS 0x2000
#define NUM2_MYRIADS 0x4000
#define NUM2_ENGLISH_NUMERALS 0x8000
#define NUM2_THOUSANDS_VAR1 0x40
#define NUM2_THOUSANDS_VAR2 0x80
#define NUM2_THOUSANDS_VAR3 0xc0
@@ -455,7 +457,9 @@ typedef struct {
// bits 6-8 use different forms of thousand, million, etc (M MA MB)
// bit9=(LANG=rw) say "thousand" and "million" before its number, not after
// bit12=(LANG=el,es) use ordinal form of hundreds and tens as well as units
// bit13=(LANG=ne) speak (non-replaced) English numerals in English
// bit13=(LANG=pt) don't use 11-19 numbers to make ordinals
// bit14=(LANG=ko) use myriads (groups of 4 digits) not thousands (groups of 3)
// bit15=(LANG=ne) speak (non-replaced) English numerals in English
int numbers2;
#define BREAK_THOUSANDS 0x49249248
+6 -8
View File
@@ -325,12 +325,12 @@ void TranslDlg::SpeakFile(void)
wxFileName fname;
FILE *f_text;
char buf[200];
fname = wxFileName(path_speaktext);
file = wxFileSelector(_T("Text file to speak"),fname.GetPath(),fname.GetName(),_T(""),_T("*"),wxOPEN);
if(file == wxEmptyString) return;
strcpy(buf,file.mb_str(wxConvLocal));
f_text = fopen(buf,"r");
if(f_text == NULL)
@@ -338,9 +338,9 @@ void TranslDlg::SpeakFile(void)
wxLogError(_T("Failed to read: ")+file);
return;
}
path_speaktext = file;
InitText(0);
SpeakNextClause(f_text,NULL,0);
return;
@@ -465,11 +465,9 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
case T_PROCESS:
case MENU_SPEAK_TEXT:
if(prosodycanvas == NULL)
{
myframe->OnProsody(event);
}
myframe->OnProsody(event);
prosodycanvas->LayoutData(ph_list,n_ph_list);
myframe->Refresh();
option_phoneme_events = espeakINITIALIZE_PHONEME_EVENTS;
option_log_frames = 1;
MakeWave2(ph_list,n_ph_list);
+3 -28
View File
@@ -525,42 +525,17 @@ static void FindVowelFmt(int prog_start, int length)
prog_end = prog_start + length;
n_vowelfmt_addr = 0;
for(prog = &phoneme_index[prog_start]; prog < &phoneme_index[prog_end]; prog++)
for(prog = &phoneme_index[prog_start]; prog < &phoneme_index[prog_end]; prog += NumInstnWords(prog))
{
instn = *prog;
switch(instn >> 12)
if((instn >> 12) == 11)
{
case 2:
case 3:
// conditions
while((instn & 0xe000) == 0x2000)
{
instn = *(++prog);
}
prog--;
break;
case 10: // Vowelin, Vowelout
prog += 3;
break;
case 9:
case 12: // WAV
case 13: // VowelStart
case 14: // VowelEnd
case 15: // addWav
prog++;
break;
case 11: // FMT
// FMT instruction
if(n_vowelfmt_addr < N_VOWELFMT_ADDR)
{
vowelfmt_addr[n_vowelfmt_addr++] = ((instn & 0xf) << 18) + (prog[1] << 2);
}
prog++;
break;
}
}
} // end of FindVowelFmt