Browse Source

Use the error context API in espeak_ng_CompileIntonation.

master
Reece H. Dunn 9 years ago
parent
commit
57eb9628d6
4 changed files with 28 additions and 10 deletions
  1. 10
    1
      src/espeak-ng.c
  2. 2
    1
      src/include/espeak-ng/espeak_ng.h
  3. 6
    7
      src/libespeak-ng/compiledata.c
  4. 10
    1
      src/speak-ng.c

+ 10
- 1
src/espeak-ng.c View File

return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
case 0x10f: // --compile-intonations case 0x10f: // --compile-intonations
{
espeak_ng_InitializePath(data_path); espeak_ng_InitializePath(data_path);
return (espeak_ng_CompileIntonation(stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
espeak_ng_ERROR_CONTEXT context = NULL;
espeak_ng_STATUS result = espeak_ng_CompileIntonation(stdout, &context);
if (result != ENS_OK) {
espeak_ng_PrintStatusCodeMessage(result, stderr, context);
espeak_ng_ClearErrorContext(&context);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
case 0x110: // --compile-phonemes case 0x110: // --compile-phonemes
espeak_ng_InitializePath(data_path); espeak_ng_InitializePath(data_path);
return (espeak_ng_CompilePhonemeData(22050, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE; return (espeak_ng_CompilePhonemeData(22050, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;

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

FILE *log); FILE *log);


ESPEAK_NG_API espeak_ng_STATUS ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_CompileIntonation(FILE *log);
espeak_ng_CompileIntonation(FILE *log,
espeak_ng_ERROR_CONTEXT *context);


#ifdef __cplusplus #ifdef __cplusplus
} }

+ 6
- 7
src/libespeak-ng/compiledata.c View File

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


#include "error.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"


#pragma GCC visibility push(default) #pragma GCC visibility push(default)


espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log)
espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log, espeak_ng_ERROR_CONTEXT *context)
{ {
if (!log) log = stderr; if (!log) log = stderr;


sprintf(buf, "%s/../phsource/intonation.txt", path_home); sprintf(buf, "%s/../phsource/intonation.txt", path_home);
if ((f_in = fopen(buf, "r")) == NULL) { if ((f_in = fopen(buf, "r")) == NULL) {
sprintf(buf, "%s/../phsource/intonation", path_home); sprintf(buf, "%s/../phsource/intonation", path_home);
if ((f_in = fopen_log(f_errors, buf, "r")) == NULL) {
if ((f_in = fopen(buf, "r")) == NULL) {
int error = errno; int error = errno;
fprintf(log, "Can't read file: %s\n", buf);
fclose(f_errors); fclose(f_errors);
return error;
return create_file_error_context(context, error, buf);
} }
} }




tune_data = (TUNE *)calloc(sizeof(TUNE), n_tune_names); tune_data = (TUNE *)calloc(sizeof(TUNE), n_tune_names);
if (tune_data == NULL) { if (tune_data == NULL) {
fprintf(f_errors, "Failed to allocate data for tunes\n");
fclose(f_in); fclose(f_in);
fclose(f_errors); fclose(f_errors);
return ENOMEM; return ENOMEM;
} }


sprintf(buf, "%s/intonations", path_home); sprintf(buf, "%s/intonations", path_home);
f_out = fopen_log(f_errors, buf, "wb");
f_out = fopen(buf, "wb");
if (f_out == NULL) { if (f_out == NULL) {
int error = errno; int error = errno;
fclose(f_in); fclose(f_in);
fclose(f_errors); fclose(f_errors);
free(tune_data); free(tune_data);
return error;
return create_file_error_context(context, error, buf);
} }


while (!feof(f_in)) { while (!feof(f_in)) {

+ 10
- 1
src/speak-ng.c View File

return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
case 0x10f: // --compile-intonations case 0x10f: // --compile-intonations
{
espeak_ng_InitializePath(data_path); espeak_ng_InitializePath(data_path);
return (espeak_ng_CompileIntonation(stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
espeak_ng_ERROR_CONTEXT context = NULL;
espeak_ng_STATUS result = espeak_ng_CompileIntonation(stdout, &context);
if (result != ENS_OK) {
espeak_ng_PrintStatusCodeMessage(result, stderr, context);
espeak_ng_ClearErrorContext(&context);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
case 0x110: // --compile-phonemes case 0x110: // --compile-phonemes
espeak_ng_InitializePath(data_path); espeak_ng_InitializePath(data_path);
return (espeak_ng_CompilePhonemeData(22050, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE; return (espeak_ng_CompilePhonemeData(22050, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;

Loading…
Cancel
Save