Browse Source

CompileIntonation: pass the file to log errors to as a parameter

master
Reece H. Dunn 9 years ago
parent
commit
bd608a8451
4 changed files with 30 additions and 21 deletions
  1. 8
    14
      src/compiledata.cpp
  2. 16
    3
      src/espeakedit.cpp
  3. 4
    2
      src/include/espeak-ng/espeak_ng.h
  4. 2
    2
      src/libespeak-ng/compilembrola.c

+ 8
- 14
src/compiledata.cpp View File

@@ -32,6 +32,8 @@
#include "wx/progdlg.h"

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

#include "speech.h"
#include "phoneme.h"
#include "synthesize.h"
@@ -58,7 +60,6 @@ extern int gui_flag;
extern char voice_name2[40];

extern void FindPhonemesUsed(void);
extern void DisplayErrorFile(const char *fname);
extern "C" int utf8_in(int *c, const char *buf);
extern "C" int utf8_out(unsigned int c, char *buf);
extern void DrawEnvelopes();
@@ -3778,7 +3779,7 @@ int LookupEnvelope(const char *name)
}


void CompileIntonation()
espeak_ng_STATUS CompileIntonation(FILE *log)
{//=====================
int ix;
char *p;
@@ -3799,15 +3800,11 @@ void CompileIntonation()


char name[12];
char fname_errors[sizeof(path_source)+120];
char tune_names[N_TUNE_NAMES][12];
char buf[sizeof(path_source)+120];

error_count = 0;

sprintf(fname_errors,"%s%s",path_source,"error_intonation");
if((f_errors = fopen(fname_errors,"w")) == NULL)
f_errors = stderr;
f_errors = log;

sprintf(buf,"%sintonation.txt",path_source);
if((f_in = fopen(buf, "r")) == NULL)
@@ -3817,7 +3814,7 @@ void CompileIntonation()
{
wxLogError(_T("Can't read file: ") + wxString(buf,wxConvLocal));
fclose(f_errors);
return;
return ENE_READ_ERROR;
}
}

@@ -3875,7 +3872,7 @@ void CompileIntonation()
fprintf(f_errors, "Failed to allocate data for tunes\n");
fclose(f_in);
fclose(f_errors);
return;
return ENE_OUT_OF_MEMORY;
}

sprintf(buf,"%s/intonations",path_home);
@@ -3885,7 +3882,7 @@ void CompileIntonation()
fclose(f_in);
fclose(f_errors);
free(tune_data);
return;
return ENE_WRITE_ERROR;
}

while(!feof(f_in))
@@ -4078,12 +4075,9 @@ void CompileIntonation()
report.Printf(_T("Compiled %d intonation tunes: %d errors."),n_tune_names, error_count);
wxLogStatus(report);

if(error_count > 0)
{
DisplayErrorFile(fname_errors);
}
LoadPhData(NULL);

return error_count > 0 ? ENE_COMPILE_ERRORS : ENS_OK;
} // end of CompileIntonation



+ 16
- 3
src/espeakedit.cpp View File

@@ -65,7 +65,7 @@ extern void DictionarySort(const char *dictname);
extern void init_z();
extern void CompilePhonemeData(void);
extern void CompileSampleRate(void);
extern void CompileIntonation();
extern espeak_ng_STATUS CompileIntonation(FILE *log);
extern void InitSpectrumDisplay();
extern void InitProsodyDisplay();
extern void InitWaveDisplay();
@@ -147,7 +147,7 @@ if(argc > 1)
exit(1);
}
CompilePhonemeData();
CompileIntonation();
CompileIntonation(stderr);
}
exit(0);
}
@@ -787,7 +787,20 @@ void MyFrame::OnTools(wxCommandEvent& event)
break;

case MENU_COMPILE_INTONATION:
CompileIntonation();
{
FILE *f_errors;
char fname_errors[sizeof(path_source)+120];
sprintf(fname_errors,"%s%s",path_source,"error_intonation");
if((f_errors = fopen(fname_errors,"w")) == NULL)
f_errors = stderr;

espeak_ng_STATUS status = CompileIntonation(f_errors);
if (f_errors != stderr)
fclose(f_errors);

if (status == ENE_COMPILE_ERRORS)
DisplayErrorFile(fname_errors);
}
break;

case MENU_COMPILE_DICT_DEBUG:

+ 4
- 2
src/include/espeak-ng/espeak_ng.h View File

@@ -39,8 +39,10 @@ typedef enum {

/* Error Codes (< 0) */

ENE_NOT_FOUND = -1,
ENE_WRITE_FAILED = -2,
ENE_READ_ERROR = -1,
ENE_WRITE_ERROR = -2,
ENE_OUT_OF_MEMORY = -3,
ENE_COMPILE_ERRORS = -4,
} espeak_ng_STATUS;

ESPEAK_NG_API espeak_ng_STATUS

+ 2
- 2
src/libespeak-ng/compilembrola.c View File

@@ -80,7 +80,7 @@ espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log)
if((f_in = fopen(buf,"r")) == NULL)
{
fprintf(log, "Can't read: %s\n", filepath);
return ENE_NOT_FOUND;
return ENE_READ_ERROR;
}

while(fgets(buf,sizeof(phoneme),f_in) != NULL)
@@ -126,7 +126,7 @@ espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log)
if((f_out = fopen(buf,"wb")) == NULL)
{
fprintf(log, "Can't write to: %s\n", buf);
return ENE_WRITE_FAILED;
return ENE_WRITE_ERROR;
}

data[count].name = 0; // list terminator

Loading…
Cancel
Save