phonemes_separator = 0x200d; // ZWJ | phonemes_separator = 0x200d; // ZWJ | ||||
break; | break; | ||||
case 0x10e: // --compile-mbrola | case 0x10e: // --compile-mbrola | ||||
{ | |||||
espeak_ng_InitializePath(data_path); | 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 | 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; | return (espeak_ng_CompileIntonation(stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE; |
ESPEAK_NG_API espeak_ng_STATUS | ESPEAK_NG_API espeak_ng_STATUS | ||||
espeak_ng_CompileMbrolaVoice(const char *path, | espeak_ng_CompileMbrolaVoice(const char *path, | ||||
FILE *log); | |||||
FILE *log, | |||||
espeak_ng_ERROR_CONTEXT *context); | |||||
ESPEAK_NG_API espeak_ng_STATUS | ESPEAK_NG_API espeak_ng_STATUS | ||||
espeak_ng_CompilePhonemeData(long rate, | espeak_ng_CompilePhonemeData(long rate, |
#include "speak_lib.h" | #include "speak_lib.h" | ||||
#include "espeak_ng.h" | #include "espeak_ng.h" | ||||
#include "error.h" | |||||
#include "phoneme.h" | #include "phoneme.h" | ||||
#include "speech.h" | #include "speech.h" | ||||
#include "synthesize.h" | #include "synthesize.h" | ||||
} | } | ||||
#pragma GCC visibility push(default) | #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; | if (!log) log = stderr; | ||||
MBROLA_TAB data[N_PHONEME_TAB]; | MBROLA_TAB data[N_PHONEME_TAB]; | ||||
strcpy(buf, filepath); | 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) { | while (fgets(buf, sizeof(phoneme), f_in) != NULL) { | ||||
buf[sizeof(phoneme)-1] = 0; | buf[sizeof(phoneme)-1] = 0; | ||||
strcpy(mbrola_voice, basename(filepath)); | strcpy(mbrola_voice, basename(filepath)); | ||||
sprintf(buf, "%s/mbrola_ph/%s_phtrans", path_home, mbrola_voice); | 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 | data[count].name = 0; // list terminator | ||||
Write4Bytes(f_out, mbrola_ctrl); | Write4Bytes(f_out, mbrola_ctrl); |
phonemes_separator = 0x200d; // ZWJ | phonemes_separator = 0x200d; // ZWJ | ||||
break; | break; | ||||
case 0x10e: // --compile-mbrola | case 0x10e: // --compile-mbrola | ||||
{ | |||||
espeak_ng_InitializePath(data_path); | 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 | 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; | return (espeak_ng_CompileIntonation(stdout) == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE; |