Use the error context API in espeak_ng_CompileIntonation.

This commit is contained in:
Reece H. Dunn
2016-01-04 13:28:38 +00:00
parent 82681567e5
commit 57eb9628d6
4 changed files with 28 additions and 10 deletions
+10 -1
View File
@@ -586,8 +586,17 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
}
case 0x10f: // --compile-intonations
{
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
espeak_ng_InitializePath(data_path);
return (espeak_ng_CompilePhonemeData(22050, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
+2 -1
View File
@@ -151,7 +151,8 @@ espeak_ng_CompilePhonemeData(long rate,
FILE *log);
ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_CompileIntonation(FILE *log);
espeak_ng_CompileIntonation(FILE *log,
espeak_ng_ERROR_CONTEXT *context);
#ifdef __cplusplus
}
+6 -7
View File
@@ -33,6 +33,7 @@
#include "speak_lib.h"
#include "espeak_ng.h"
#include "error.h"
#include "speech.h"
#include "phoneme.h"
#include "synthesize.h"
@@ -2783,7 +2784,7 @@ int LookupEnvelopeName(const char *name)
#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;
@@ -2812,11 +2813,10 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log)
sprintf(buf, "%s/../phsource/intonation.txt", path_home);
if ((f_in = fopen(buf, "r")) == NULL) {
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;
fprintf(log, "Can't read file: %s\n", buf);
fclose(f_errors);
return error;
return create_file_error_context(context, error, buf);
}
}
@@ -2860,20 +2860,19 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log)
tune_data = (TUNE *)calloc(sizeof(TUNE), n_tune_names);
if (tune_data == NULL) {
fprintf(f_errors, "Failed to allocate data for tunes\n");
fclose(f_in);
fclose(f_errors);
return ENOMEM;
}
sprintf(buf, "%s/intonations", path_home);
f_out = fopen_log(f_errors, buf, "wb");
f_out = fopen(buf, "wb");
if (f_out == NULL) {
int error = errno;
fclose(f_in);
fclose(f_errors);
free(tune_data);
return error;
return create_file_error_context(context, error, buf);
}
while (!feof(f_in)) {
+10 -1
View File
@@ -573,8 +573,17 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
}
case 0x10f: // --compile-intonations
{
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
espeak_ng_InitializePath(data_path);
return (espeak_ng_CompilePhonemeData(22050, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;