mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-11 08:30:31 +00:00
Use the error context API in espeak_ng_CompileMbrolaVoice.
This commit is contained in:
+10
-1
@@ -574,8 +574,17 @@ int main(int argc, char **argv)
|
||||
phonemes_separator = 0x200d; // ZWJ
|
||||
break;
|
||||
case 0x10e: // --compile-mbrola
|
||||
{
|
||||
espeak_ng_InitializePath(data_path);
|
||||
return (espeak_ng_CompileMbrolaVoice(optarg2, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
espeak_ng_ERROR_CONTEXT context = NULL;
|
||||
espeak_ng_STATUS result = espeak_ng_CompileMbrolaVoice(optarg2, stdout, &context);
|
||||
if (result != ENS_OK) {
|
||||
espeak_ng_PrintStatusCodeMessage(result, stderr, context);
|
||||
espeak_ng_ClearErrorContext(&context);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
case 0x10f: // --compile-intonations
|
||||
espeak_ng_InitializePath(data_path);
|
||||
return (espeak_ng_CompileIntonation(stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
||||
@@ -143,7 +143,8 @@ espeak_ng_CompileDictionary(const char *dsource,
|
||||
|
||||
ESPEAK_NG_API espeak_ng_STATUS
|
||||
espeak_ng_CompileMbrolaVoice(const char *path,
|
||||
FILE *log);
|
||||
FILE *log,
|
||||
espeak_ng_ERROR_CONTEXT *context);
|
||||
|
||||
ESPEAK_NG_API espeak_ng_STATUS
|
||||
espeak_ng_CompilePhonemeData(long rate,
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "speak_lib.h"
|
||||
#include "espeak_ng.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "phoneme.h"
|
||||
#include "speech.h"
|
||||
#include "synthesize.h"
|
||||
@@ -62,7 +63,7 @@ static unsigned int StringToWord(const char *string)
|
||||
}
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log)
|
||||
espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log, espeak_ng_ERROR_CONTEXT *context)
|
||||
{
|
||||
if (!log) log = stderr;
|
||||
|
||||
@@ -85,10 +86,8 @@ espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log)
|
||||
MBROLA_TAB data[N_PHONEME_TAB];
|
||||
|
||||
strcpy(buf, filepath);
|
||||
if ((f_in = fopen(buf, "r")) == NULL) {
|
||||
fprintf(log, "Can't read: %s\n", filepath);
|
||||
return errno;
|
||||
}
|
||||
if ((f_in = fopen(buf, "r")) == NULL)
|
||||
return create_file_error_context(context, errno, buf);
|
||||
|
||||
while (fgets(buf, sizeof(phoneme), f_in) != NULL) {
|
||||
buf[sizeof(phoneme)-1] = 0;
|
||||
@@ -126,10 +125,8 @@ espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log)
|
||||
|
||||
strcpy(mbrola_voice, basename(filepath));
|
||||
sprintf(buf, "%s/mbrola_ph/%s_phtrans", path_home, mbrola_voice);
|
||||
if ((f_out = fopen(buf, "wb")) == NULL) {
|
||||
fprintf(log, "Can't write to: %s\n", buf);
|
||||
return errno;
|
||||
}
|
||||
if ((f_out = fopen(buf, "wb")) == NULL)
|
||||
return create_file_error_context(context, errno, buf);
|
||||
|
||||
data[count].name = 0; // list terminator
|
||||
Write4Bytes(f_out, mbrola_ctrl);
|
||||
|
||||
+10
-1
@@ -561,8 +561,17 @@ int main(int argc, char **argv)
|
||||
phonemes_separator = 0x200d; // ZWJ
|
||||
break;
|
||||
case 0x10e: // --compile-mbrola
|
||||
{
|
||||
espeak_ng_InitializePath(data_path);
|
||||
return (espeak_ng_CompileMbrolaVoice(optarg2, stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
espeak_ng_ERROR_CONTEXT context = NULL;
|
||||
espeak_ng_STATUS result = espeak_ng_CompileMbrolaVoice(optarg2, stdout, &context);
|
||||
if (result != ENS_OK) {
|
||||
espeak_ng_PrintStatusCodeMessage(result, stderr, context);
|
||||
espeak_ng_ClearErrorContext(&context);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
case 0x10f: // --compile-intonations
|
||||
espeak_ng_InitializePath(data_path);
|
||||
return (espeak_ng_CompileIntonation(stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
||||
Reference in New Issue
Block a user