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

#include "wx/progdlg.h" #include "wx/progdlg.h"


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

#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
extern char voice_name2[40]; extern char voice_name2[40];


extern void FindPhonemesUsed(void); extern void FindPhonemesUsed(void);
extern void DisplayErrorFile(const char *fname);
extern "C" int utf8_in(int *c, const char *buf); extern "C" int utf8_in(int *c, const char *buf);
extern "C" int utf8_out(unsigned int c, char *buf); extern "C" int utf8_out(unsigned int c, char *buf);
extern void DrawEnvelopes(); extern void DrawEnvelopes();
} }




void CompileIntonation()
espeak_ng_STATUS CompileIntonation(FILE *log)
{//===================== {//=====================
int ix; int ix;
char *p; char *p;




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


error_count = 0; 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); sprintf(buf,"%sintonation.txt",path_source);
if((f_in = fopen(buf, "r")) == NULL) if((f_in = fopen(buf, "r")) == NULL)
{ {
wxLogError(_T("Can't read file: ") + wxString(buf,wxConvLocal)); wxLogError(_T("Can't read file: ") + wxString(buf,wxConvLocal));
fclose(f_errors); fclose(f_errors);
return;
return ENE_READ_ERROR;
} }
} }


fprintf(f_errors, "Failed to allocate data for tunes\n"); fprintf(f_errors, "Failed to allocate data for tunes\n");
fclose(f_in); fclose(f_in);
fclose(f_errors); fclose(f_errors);
return;
return ENE_OUT_OF_MEMORY;
} }


sprintf(buf,"%s/intonations",path_home); sprintf(buf,"%s/intonations",path_home);
fclose(f_in); fclose(f_in);
fclose(f_errors); fclose(f_errors);
free(tune_data); free(tune_data);
return;
return ENE_WRITE_ERROR;
} }


while(!feof(f_in)) while(!feof(f_in))
report.Printf(_T("Compiled %d intonation tunes: %d errors."),n_tune_names, error_count); report.Printf(_T("Compiled %d intonation tunes: %d errors."),n_tune_names, error_count);
wxLogStatus(report); wxLogStatus(report);


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


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





+ 16
- 3
src/espeakedit.cpp View File

extern void init_z(); extern void init_z();
extern void CompilePhonemeData(void); extern void CompilePhonemeData(void);
extern void CompileSampleRate(void); extern void CompileSampleRate(void);
extern void CompileIntonation();
extern espeak_ng_STATUS CompileIntonation(FILE *log);
extern void InitSpectrumDisplay(); extern void InitSpectrumDisplay();
extern void InitProsodyDisplay(); extern void InitProsodyDisplay();
extern void InitWaveDisplay(); extern void InitWaveDisplay();
exit(1); exit(1);
} }
CompilePhonemeData(); CompilePhonemeData();
CompileIntonation();
CompileIntonation(stderr);
} }
exit(0); exit(0);
} }
break; break;


case MENU_COMPILE_INTONATION: 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; break;


case MENU_COMPILE_DICT_DEBUG: case MENU_COMPILE_DICT_DEBUG:

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



/* Error Codes (< 0) */ /* 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_STATUS;


ESPEAK_NG_API espeak_ng_STATUS ESPEAK_NG_API espeak_ng_STATUS

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

if((f_in = fopen(buf,"r")) == NULL) if((f_in = fopen(buf,"r")) == NULL)
{ {
fprintf(log, "Can't read: %s\n", filepath); fprintf(log, "Can't read: %s\n", filepath);
return ENE_NOT_FOUND;
return ENE_READ_ERROR;
} }


while(fgets(buf,sizeof(phoneme),f_in) != NULL) while(fgets(buf,sizeof(phoneme),f_in) != NULL)
if((f_out = fopen(buf,"wb")) == NULL) if((f_out = fopen(buf,"wb")) == NULL)
{ {
fprintf(log, "Can't write to: %s\n", buf); fprintf(log, "Can't write to: %s\n", buf);
return ENE_WRITE_FAILED;
return ENE_WRITE_ERROR;
} }


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

Loading…
Cancel
Save