From 4e5bc190477c8b4690ec4c20e6ed7ae83b190fc6 Mon Sep 17 00:00:00 2001 From: Yury Popov Date: Fri, 28 Oct 2022 12:31:56 +0300 Subject: [PATCH] Allow out-of-tree intonations compilation --- src/include/espeak-ng/espeak_ng.h | 7 +++++++ src/libespeak-ng/compiledata.c | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/include/espeak-ng/espeak_ng.h b/src/include/espeak-ng/espeak_ng.h index e240281c..0bf2309b 100644 --- a/src/include/espeak-ng/espeak_ng.h +++ b/src/include/espeak-ng/espeak_ng.h @@ -191,6 +191,13 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log, espeak_ng_ERROR_CONTEXT *context); + +ESPEAK_NG_API espeak_ng_STATUS +espeak_ng_CompileIntonationPath(const char *source_path, + const char *destination_path, + FILE *log, + espeak_ng_ERROR_CONTEXT *context); + /* eSpeak NG 1.49.1 */ ESPEAK_NG_API espeak_ng_STATUS diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 62bbb30b..4c692b76 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -2697,8 +2697,20 @@ static int LookupEnvelopeName(const char *name) #pragma GCC visibility push(default) espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log, espeak_ng_ERROR_CONTEXT *context) +{ + return espeak_ng_CompileIntonationPath(NULL, NULL, log, context); +} + +espeak_ng_STATUS +espeak_ng_CompileIntonationPath(const char *source_path, + const char *destination_path, + FILE *log, + espeak_ng_ERROR_CONTEXT *context + ) { if (!log) log = stderr; + if (!source_path) source_path = path_home; + if (!destination_path) destination_path = path_home; int ix; char *p; @@ -2722,9 +2734,9 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log, espeak_ng_ERROR_CONTEXT error_count = 0; f_errors = log; - sprintf(buf, "%s/../phsource/intonation.txt", path_home); + sprintf(buf, "%s/../phsource/intonation.txt", source_path); if ((f_in = fopen(buf, "r")) == NULL) { - sprintf(buf, "%s/../phsource/intonation", path_home); + sprintf(buf, "%s/../phsource/intonation", source_path); if ((f_in = fopen(buf, "r")) == NULL) { int error = errno; fclose(f_errors); @@ -2777,7 +2789,7 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log, espeak_ng_ERROR_CONTEXT return ENOMEM; } - sprintf(buf, "%s/intonations", path_home); + sprintf(buf, "%s/intonations", destination_path); f_out = fopen(buf, "wb"); if (f_out == NULL) { int error = errno;