Browse Source

espeakedit: remove wxWidgets from compiledata.cpp

master
Reece H. Dunn 9 years ago
parent
commit
56ddf6c339
4 changed files with 37 additions and 81 deletions
  1. 18
    74
      src/compiledata.cpp
  2. 2
    3
      src/espeakedit.cpp
  3. 15
    2
      src/spect.cpp
  4. 2
    2
      src/spect.h

+ 18
- 74
src/compiledata.cpp View File

#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>


#include "wx/wx.h"
#include "wx/wfstream.h"
#include "wx/dir.h"
#include "wx/filename.h"
#include <wx/numdlg.h>
#include "wx/progdlg.h"

#include "speak_lib.h" #include "speak_lib.h"
#include "espeak_ng.h" #include "espeak_ng.h"


#include "voice.h" #include "voice.h"
#include "spect.h" #include "spect.h"


#include <sys/stat.h>
#ifdef PLATFORM_POSIX #ifdef PLATFORM_POSIX
#include <unistd.h> #include <unistd.h>
#endif #endif


// wxWidgets 3 name changes
#if wxCHECK_VERSION(3, 0, 0)
#define wxOPEN wxFD_OPEN
#endif

typedef struct { typedef struct {
unsigned int value; unsigned int value;
char *name; char *name;
int klatt_flag=0; int klatt_flag=0;
SpectFrame *fr; SpectFrame *fr;
frame_t *fr_out; frame_t *fr_out;
wxString path_sep = _T("/");
char filename[sizeof(path_home)+20];


SPECT_SEQ seq_out; SPECT_SEQ seq_out;
SPECT_SEQK seqk_out; SPECT_SEQK seqk_out;
return(0); return(0);
} }


wxString filename = wxString(path_source,wxConvLocal) + path_sep + wxString(path,wxConvLocal);
wxFileInputStream stream(filename);

if(stream.Ok() == FALSE)
{
error("Failed to open: '%s'",path);
SpectSeqDestroy(spectseq);
return(0);
}
LoadSpectSeq(spectseq, stream);
snprintf(filename, sizeof(filename), "%s/%s", path_source, path);
LoadSpectSeq(spectseq, filename);


if(spectseq->frames == NULL) if(spectseq->frames == NULL)
{ {






static void CompilePhonemeData2(const char *source)
static void CompilePhonemeData2(const char *source, FILE *log)
{//================================================ {//================================================
char fname[sizeof(path_source)+40]; char fname[sizeof(path_source)+40];
wxString report;
wxString report_dict;


#ifdef MAKE_ENVELOPES #ifdef MAKE_ENVELOPES
make_envs(); make_envs();
#endif #endif


wxLogStatus(_T("Compiling phoneme data: ")+wxString(path_source,wxConvLocal));
fprintf(log,"Compiling phoneme data: %s\n",path_source);
n_envelopes = 0; n_envelopes = 0;
error_count = 0; error_count = 0;
resample_count = 0; resample_count = 0;
memset(markers_used,0,sizeof(markers_used)); memset(markers_used,0,sizeof(markers_used));


f_errors = stderr;
f_errors = log;


if(!wxDirExists(path_source))
if(!access(path_source, 755))
{ {
fprintf(stderr,"Can't find phoneme source directory: %s\n",path_source);
fprintf(log,"Can't find phoneme source directory: %s\n",path_source);
return; return;
} }


f_in = fopen_log(f_errors,fname,"rb"); f_in = fopen_log(f_errors,fname,"rb");
if(f_in == NULL) if(f_in == NULL)
{ {
wxLogError(_T("Can't read master phonemes file:\n") + wxString(fname,wxConvLocal));
fprintf(log,"Can't read master phonemes file: %s\n",fname);
return; return;
} }


sprintf(fname,"%scompile_prog_log",path_source); sprintf(fname,"%scompile_prog_log",path_source);
f_prog_log = fopen_log(f_errors,fname,"wb"); f_prog_log = fopen_log(f_errors,fname,"wb");


fprintf(stderr,"Compiling phoneme data: %s\n",path_source);
fprintf(log,"Compiling phoneme data: %s\n",path_source);


// write a word so that further data doesn't start at displ=0 // write a word so that further data doesn't start at displ=0
Write4Bytes(f_phdata,version_phdata); Write4Bytes(f_phdata,version_phdata);
if(resample_count > 0) if(resample_count > 0)
{ {
fprintf(f_errors, "\n%d WAV files resampled to %d Hz\n", resample_count, samplerate_native); fprintf(f_errors, "\n%d WAV files resampled to %d Hz\n", resample_count, samplerate_native);
report.Printf(_T("Compiled phonemes: %d errors, %d files resampled to %d Hz. "),error_count, resample_count, samplerate_native);
fprintf(log,"Compiled phonemes: %d errors, %d files resampled to %d Hz.\n",error_count, resample_count, samplerate_native);
} }
else else
{ {
report.Printf(_T("Compiled phonemes: %d errors."),error_count);
fprintf(log,"Compiled phonemes: %d errors.\n",error_count);
} }


if(f_errors != stderr) if(f_errors != stderr)
fclose(f_errors); fclose(f_errors);


if(error_count > 0)
{
report += _T(" See file: '")+wxString(path_source,wxConvLocal)+_T("phsource/error_log'.");
wxLogError(report);
}
wxLogStatus(report + report_dict);

if(gui_flag == 0)
{
strncpy0(fname,(report+report_dict).mb_str(wxConvLocal),sizeof(fname));
fprintf(stderr,"%s\n",fname);

}

ReadPhondataManifest(); ReadPhondataManifest();
} // end of CompilePhonemeData } // end of CompilePhonemeData


int found; int found;
int tune_number = 0; int tune_number = 0;
FILE *f_out; FILE *f_out;
wxString report;
TUNE *tune_data; TUNE *tune_data;
TUNE new_tune; TUNE new_tune;


sprintf(buf,"%sintonation",path_source); sprintf(buf,"%sintonation",path_source);
if((f_in = fopen_log(f_errors, buf, "r")) == NULL) if((f_in = fopen_log(f_errors, buf, "r")) == NULL)
{ {
wxLogError(_T("Can't read file: ") + wxString(buf,wxConvLocal));
fprintf(log,"Can't read file: %s\n",buf);
fclose(f_errors); fclose(f_errors);
return ENE_READ_ERROR; return ENE_READ_ERROR;
} }
fclose(f_in); fclose(f_in);
fclose(f_out); fclose(f_out);


report.Printf(_T("Compiled %d intonation tunes: %d errors."),n_tune_names, error_count);
wxLogStatus(report);
fprintf(log,"Compiled %d intonation tunes: %d errors.\n",n_tune_names, error_count);


LoadPhData(NULL); LoadPhData(NULL);








void CompilePhonemeData()
void CompilePhonemeData(long rate, FILE *log)
{ {
WavegenInit(22050, 0);
WavegenInit(rate, 0);
WavegenSetVoice(voice); WavegenSetVoice(voice);
CompilePhonemeData2("phonemes");
CompilePhonemeData2("phonemes", log);
} }


void CompileSampleRate()
{
long value;
#ifndef PLATFORM_POSIX
wxLogError(_T("Change Sample Rate needs the 'sox' program. It probably doesn't work on Windows"));
#endif

value = wxGetNumberFromUser(_T("Compile phoneme data with a specified sample rate"), _T("Sample rate"), _T("Resample (needs 'sox' program)"), 22050, 5000, 48000);

if(value > 1000)
{
WavegenInit(value, 0);
WavegenSetVoice(voice);
CompilePhonemeData2("phonemes");
}
}


+ 2
- 3
src/espeakedit.cpp View File

"<a href=\"http://espeak.sourceforge.net/\">http://espeak.sourceforge.net</a><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>"; "Licensed under <a href=\"http://espeak.sourceforge.net/license.html\">GNU General Public License version 3</a></font>";


extern void CompilePhonemeData(void);
extern void CompileSampleRate(void);
extern void CompilePhonemeData(long rate, FILE *log);
extern espeak_ng_STATUS CompileIntonation(FILE *log); extern espeak_ng_STATUS CompileIntonation(FILE *log);


int progress_max; int progress_max;
fprintf(stderr, "Failed to load default voice\n"); fprintf(stderr, "Failed to load default voice\n");
exit(1); exit(1);
} }
CompilePhonemeData();
CompilePhonemeData(22050, stderr);
CompileIntonation(stderr); CompileIntonation(stderr);
} }
exit(0); exit(0);

+ 15
- 2
src/spect.cpp View File

#include "synthesize.h" #include "synthesize.h"
#include "voice.h" #include "voice.h"
#include "spect.h" #include "spect.h"
#include "wx/wfstream.h"
#include "wx/txtstrm.h" #include "wx/txtstrm.h"
#include "wx/datstrm.h" #include "wx/datstrm.h"




spect->numframes = 0; spect->numframes = 0;
spect->frames = NULL; spect->frames = NULL;
spect->name = NULL;
pk_select = 1; pk_select = 1;
spect->grid = 1; spect->grid = 1;
} }
delete spect->frames; delete spect->frames;
} }
free(spect->name);
delete spect; delete spect;
} }








int LoadSpectSeq(SpectSeq *spect, wxInputStream & stream)
int LoadSpectSeq(SpectSeq *spect, const char *filename)
{//======================================= {//=======================================
int n; int n;
int ix; int ix;
int set_max_y=0; int set_max_y=0;
float time_offset; float time_offset;


wxFileInputStream stream(filename);
if(stream.Ok() == FALSE)
{
fprintf(stderr, "Failed to open: '%s'", filename);
return(0);
}

wxDataInputStream s(stream); wxDataInputStream s(stream);


id1 = s.Read32(); id1 = s.Read32();
return(1); return(1);
} }


spect->name = s.ReadString();
wxString name = s.ReadString();
n = s.Read16(); n = s.Read16();
spect->amplitude = s.Read16(); spect->amplitude = s.Read16();
spect->max_y = s.Read16(); spect->max_y = s.Read16();
s.Read16(); s.Read16();


free(spect->name);
spect->name = strdup(name.mb_str(wxConvLocal));

if(n==0) return(0); if(n==0) return(0);


if(spect->frames != NULL) if(spect->frames != NULL)

+ 2
- 2
src/spect.h View File

int numframes; int numframes;
int amplitude; int amplitude;
int spare; int spare;
wxString name;
char *name;


SpectFrame **frames; SpectFrame **frames;
PitchEnvelope pitchenv; PitchEnvelope pitchenv;


SpectSeq *SpectSeqCreate(); SpectSeq *SpectSeqCreate();
void SpectSeqDestroy(SpectSeq *spect); void SpectSeqDestroy(SpectSeq *spect);
int LoadSpectSeq(SpectSeq *spect, wxInputStream& stream);
int LoadSpectSeq(SpectSeq *spect, const char *filename);

Loading…
Cancel
Save