if (flag_compile) { | if (flag_compile) { | ||||
// This must be done after the voice is set | // This must be done after the voice is set | ||||
return (espeak_ng_CompileDictionary("", NULL, stderr, flag_compile & 0x1) == ENS_OK) | |||||
? EXIT_SUCCESS : EXIT_FAILURE; | |||||
espeak_ng_ERROR_CONTEXT context = NULL; | |||||
espeak_ng_STATUS result = espeak_ng_CompileDictionary("", NULL, stderr, flag_compile & 0x1, &context); | |||||
if (result != ENS_OK) { | |||||
espeak_ng_PrintStatusCodeMessage(result, stderr, context); | |||||
espeak_ng_ClearErrorContext(&context); | |||||
return EXIT_FAILURE; | |||||
} | |||||
return EXIT_SUCCESS; | |||||
} | } | ||||
// set any non-default values of parameters. This must be done after espeak_Initialize() | // set any non-default values of parameters. This must be done after espeak_Initialize() |
espeak_ng_CompileDictionary(const char *dsource, | espeak_ng_CompileDictionary(const char *dsource, | ||||
const char *dict_name, | const char *dict_name, | ||||
FILE *log, | FILE *log, | ||||
int flags); | |||||
int flags, | |||||
espeak_ng_ERROR_CONTEXT *context); | |||||
ESPEAK_NG_API espeak_ng_STATUS | ESPEAK_NG_API espeak_ng_STATUS | ||||
espeak_ng_CompileMbrolaVoice(const char *path, | espeak_ng_CompileMbrolaVoice(const char *path, |
} | } | ||||
#pragma GCC visibility push(default) | #pragma GCC visibility push(default) | ||||
ESPEAK_NG_API espeak_ng_STATUS espeak_ng_CompileDictionary(const char *dsource, const char *dict_name, FILE *log, int flags) | |||||
ESPEAK_NG_API espeak_ng_STATUS espeak_ng_CompileDictionary(const char *dsource, const char *dict_name, FILE *log, int flags, espeak_ng_ERROR_CONTEXT *context) | |||||
{ | { | ||||
if (!log) log = stderr; | if (!log) log = stderr; | ||||
if (!dict_name) dict_name = dictionary_name; | if (!dict_name) dict_name = dictionary_name; | ||||
sprintf(fname_in, "%srules.txt", path); | sprintf(fname_in, "%srules.txt", path); | ||||
if ((f_in = fopen(fname_in, "r")) == NULL) { | if ((f_in = fopen(fname_in, "r")) == NULL) { | ||||
sprintf(fname_in, "%srules", path); | sprintf(fname_in, "%srules", path); | ||||
if ((f_in = fopen_log(fname_in, "r")) == NULL) | |||||
return errno; | |||||
if ((f_in = fopen(fname_in, "r")) == NULL) | |||||
return create_file_error_context(context, errno, fname_in); | |||||
} | } | ||||
sprintf(fname_out, "%s%c%s_dict", path_home, PATHSEP, dict_name); | sprintf(fname_out, "%s%c%s_dict", path_home, PATHSEP, dict_name); | ||||
if ((f_out = fopen_log(fname_out, "wb+")) == NULL) { | |||||
if ((f_out = fopen(fname_out, "wb+")) == NULL) { | |||||
int error = errno; | int error = errno; | ||||
fclose(f_in); | fclose(f_in); | ||||
return error; | |||||
return create_file_error_context(context, errno, fname_out); | |||||
} | } | ||||
sprintf(fname_temp, "%s%ctemp", path_home, PATHSEP); | sprintf(fname_temp, "%s%ctemp", path_home, PATHSEP); | ||||
ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags) | ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags) | ||||
{ | { | ||||
espeak_ng_CompileDictionary(path, dictionary_name, log, flags); | |||||
espeak_ng_ERROR_CONTEXT context = NULL; | |||||
espeak_ng_STATUS result = espeak_ng_CompileDictionary(path, dictionary_name, log, flags, &context); | |||||
if (result != ENS_OK) { | |||||
espeak_ng_PrintStatusCodeMessage(result, stderr, context); | |||||
espeak_ng_ClearErrorContext(&context); | |||||
} | |||||
} | } | ||||
#pragma GCC visibility pop | #pragma GCC visibility pop |
} | } | ||||
if (flag_compile) { | if (flag_compile) { | ||||
espeak_ng_ERROR_CONTEXT context = NULL; | |||||
#if defined(PLATFORM_DOS) || defined(PLATFORM_WINDOWS) | #if defined(PLATFORM_DOS) || defined(PLATFORM_WINDOWS) | ||||
char path_dsource[sizeof(path_home)+20]; | char path_dsource[sizeof(path_home)+20]; | ||||
strcpy(path_dsource, path_home); | strcpy(path_dsource, path_home); | ||||
path_dsource[strlen(path_home)-11] = 0; // remove "espeak-data" from the end | path_dsource[strlen(path_home)-11] = 0; // remove "espeak-data" from the end | ||||
strcat(path_dsource, "dictsource\\"); | strcat(path_dsource, "dictsource\\"); | ||||
espeak_ng_STATUS status = espeak_ng_CompileDictionary(path_dsource, dictionary_name, NULL, flag_compile & 0x1); | |||||
espeak_ng_STATUS status = espeak_ng_CompileDictionary(path_dsource, dictionary_name, NULL, flag_compile & 0x1, &context); | |||||
#else | #else | ||||
espeak_ng_STATUS status = espeak_ng_CompileDictionary(NULL, dictionary_name, NULL, flag_compile & 0x1); | |||||
espeak_ng_STATUS status = espeak_ng_CompileDictionary(NULL, dictionary_name, NULL, flag_compile & 0x1, &context); | |||||
#endif | #endif | ||||
return (status == ENS_OK) ? EXIT_SUCCESS : EXIT_FAILURE; | |||||
if (status != ENS_OK) { | |||||
espeak_ng_PrintStatusCodeMessage(status, stderr, context); | |||||
espeak_ng_ClearErrorContext(&context); | |||||
return EXIT_FAILURE; | |||||
} | |||||
return EXIT_SUCCESS; | |||||
} | } | ||||
SetParameter(espeakRATE, speed, 0); | SetParameter(espeakRATE, speed, 0); |