| #ifndef ESPEAK_NG_H | #ifndef ESPEAK_NG_H | ||||
| #define ESPEAK_NG_H | #define ESPEAK_NG_H | ||||
| #include <wchar.h> | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" | extern "C" | ||||
| { | { | ||||
| ESPEAK_NG_API int | ESPEAK_NG_API int | ||||
| espeak_ng_GetSampleRate(void); | espeak_ng_GetSampleRate(void); | ||||
| ESPEAK_NG_API espeak_ng_STATUS | |||||
| espeak_ng_SpeakCharacter(wchar_t character); | |||||
| ESPEAK_NG_API espeak_ng_STATUS | ESPEAK_NG_API espeak_ng_STATUS | ||||
| espeak_ng_CompileDictionary(const char *dsource, | espeak_ng_CompileDictionary(const char *dsource, | ||||
| const char *dict_name, | const char *dict_name, |
| #include "speak_lib.h" | #include "speak_lib.h" | ||||
| #include "espeak_ng.h" | #include "espeak_ng.h" | ||||
| #include <errno.h> | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #if HAVE_STDINT_H | #if HAVE_STDINT_H | ||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #include "synthesize.h" | #include "synthesize.h" | ||||
| #include "translate.h" | #include "translate.h" | ||||
| static espeak_ERROR status_to_espeak_error(espeak_ng_STATUS status) | |||||
| { | |||||
| switch (status) | |||||
| { | |||||
| case ENS_OK: return EE_OK; | |||||
| case ENOENT: return EE_NOT_FOUND; | |||||
| case ENS_FIFO_BUFFER_FULL: return EE_BUFFER_FULL; | |||||
| default: return EE_INTERNAL_ERROR; | |||||
| } | |||||
| } | |||||
| #pragma GCC visibility push(default) | #pragma GCC visibility push(default) | ||||
| ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options) | ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options) | ||||
| return espeak_ng_GetSampleRate(); | return espeak_ng_GetSampleRate(); | ||||
| } | } | ||||
| ESPEAK_API espeak_ERROR espeak_Char(wchar_t character) | |||||
| { | |||||
| return status_to_espeak_error(espeak_ng_SpeakCharacter(character)); | |||||
| } | |||||
| 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_CompileDictionary(path, dictionary_name, log, flags); |
| return a_error; | return a_error; | ||||
| } | } | ||||
| ESPEAK_API espeak_ERROR espeak_Char(wchar_t character) | |||||
| ESPEAK_NG_API espeak_ng_STATUS espeak_ng_SpeakCharacter(wchar_t character) | |||||
| { | { | ||||
| // is there a system resource of character names per language? | // is there a system resource of character names per language? | ||||
| if (f_logespeak) | |||||
| fprintf(f_logespeak, "\nCHAR U+%x\n", character); | |||||
| #ifdef USE_ASYNC | #ifdef USE_ASYNC | ||||
| espeak_ERROR a_error; | |||||
| if (my_mode & ENOUTPUT_MODE_SYNCHRONOUS) { | if (my_mode & ENOUTPUT_MODE_SYNCHRONOUS) { | ||||
| sync_espeak_Char(character); | sync_espeak_Char(character); | ||||
| return EE_OK; | |||||
| return ENS_OK; | |||||
| } | } | ||||
| t_espeak_command *c = create_espeak_char(character, NULL); | t_espeak_command *c = create_espeak_char(character, NULL); | ||||
| a_error = status_to_espeak_error(fifo_add_command(c)); | |||||
| if (a_error != EE_OK) | |||||
| espeak_ng_STATUS status = fifo_add_command(c); | |||||
| if (status != ENS_OK) | |||||
| delete_espeak_command(c); | delete_espeak_command(c); | ||||
| return a_error; | |||||
| return status; | |||||
| #else | #else | ||||
| sync_espeak_Char(character); | sync_espeak_Char(character); | ||||
| return EE_OK; | |||||
| return ENS_OK; | |||||
| #endif | #endif | ||||
| } | } | ||||