mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-09 07:52:27 +00:00
Share the initialise implementation between libespeak-ng and speak-ng.
This commit is contained in:
@@ -47,6 +47,9 @@ typedef enum {
|
||||
ESPEAK_NG_API void
|
||||
espeak_ng_InitializePath(const char *path);
|
||||
|
||||
ESPEAK_NG_API espeak_ng_STATUS
|
||||
espeak_ng_Initialize(void);
|
||||
|
||||
ESPEAK_NG_API espeak_ng_STATUS
|
||||
espeak_ng_CompileDictionary(const char *dsource,
|
||||
const char *dict_name,
|
||||
|
||||
@@ -303,26 +303,28 @@ ESPEAK_NG_API void espeak_ng_InitializePath(const char *path)
|
||||
strcpy(path_home, PATH_ESPEAK_DATA);
|
||||
#endif
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
||||
static int initialise(int control)
|
||||
ESPEAK_NG_API espeak_ng_STATUS espeak_ng_Initialize(void)
|
||||
{
|
||||
int param;
|
||||
int srate = 22050; // default sample rate 22050 Hz
|
||||
|
||||
err = EE_OK;
|
||||
LoadConfig();
|
||||
// It seems that the wctype functions don't work until the locale has been set
|
||||
// to something other than the default "C". Then, not only Latin1 but also the
|
||||
// other characters give the correct results with iswalpha() etc.
|
||||
if (setlocale(LC_CTYPE, "C.UTF-8") == NULL) {
|
||||
if (setlocale(LC_CTYPE, "UTF-8") == NULL) {
|
||||
if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
|
||||
setlocale(LC_CTYPE, "");
|
||||
}
|
||||
}
|
||||
|
||||
espeak_ng_STATUS result = LoadPhData(&srate);
|
||||
if (result != ENS_OK) {
|
||||
if (result == ENE_READ_ERROR) {
|
||||
fprintf(stderr, "Failed to load espeak-data\n");
|
||||
if ((control & espeakINITIALIZE_DONT_EXIT) == 0)
|
||||
exit(1);
|
||||
} else
|
||||
fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home);
|
||||
}
|
||||
if (result != ENS_OK)
|
||||
return result;
|
||||
|
||||
WavegenInit(srate, 0);
|
||||
LoadConfig();
|
||||
|
||||
memset(¤t_voice_selected, 0, sizeof(current_voice_selected));
|
||||
SetVoiceStack(NULL, "");
|
||||
@@ -334,6 +336,7 @@ static int initialise(int control)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
||||
static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text, int flags)
|
||||
{
|
||||
@@ -603,17 +606,16 @@ ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length
|
||||
{
|
||||
int param;
|
||||
|
||||
// It seems that the wctype functions don't work until the locale has been set
|
||||
// to something other than the default "C". Then, not only Latin1 but also the
|
||||
// other characters give the correct results with iswalpha() etc.
|
||||
if (setlocale(LC_CTYPE, "C.UTF-8") == NULL) {
|
||||
if (setlocale(LC_CTYPE, "UTF-8") == NULL)
|
||||
if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
|
||||
setlocale(LC_CTYPE, "");
|
||||
}
|
||||
|
||||
espeak_ng_InitializePath(path);
|
||||
initialise(options);
|
||||
espeak_ng_STATUS result = espeak_ng_Initialize();
|
||||
if (result != ENS_OK) {
|
||||
if (result == ENE_READ_ERROR) {
|
||||
fprintf(stderr, "Failed to load espeak-data\n");
|
||||
if ((options & espeakINITIALIZE_DONT_EXIT) == 0)
|
||||
exit(1);
|
||||
} else
|
||||
fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home);
|
||||
}
|
||||
select_output(output_type);
|
||||
|
||||
if (f_logespeak)
|
||||
|
||||
+8
-33
@@ -284,38 +284,6 @@ static int WavegenFile(void)
|
||||
return finished;
|
||||
}
|
||||
|
||||
static int initialise(void)
|
||||
{
|
||||
int param;
|
||||
int srate = 22050; // default sample rate
|
||||
|
||||
// It seems that the wctype functions don't work until the locale has been set
|
||||
// to something other than the default "C". Then, not only Latin1 but also the
|
||||
// other characters give the correct results with iswalpha() etc.
|
||||
if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) {
|
||||
if (setlocale(LC_CTYPE, "UTF-8") == NULL)
|
||||
setlocale(LC_CTYPE, "");
|
||||
}
|
||||
|
||||
espeak_ng_STATUS result = LoadPhData(&srate);
|
||||
if (result != ENS_OK) {
|
||||
if (result == ENE_READ_ERROR) {
|
||||
fprintf(stderr, "Failed to load espeak-data\n");
|
||||
exit(1);
|
||||
} else
|
||||
fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home);
|
||||
}
|
||||
WavegenInit(srate, 0);
|
||||
LoadConfig();
|
||||
SetVoiceStack(NULL, "");
|
||||
SynthesizeInit();
|
||||
|
||||
for (param = 0; param < N_SPEECH_PARAM; param++)
|
||||
param_stack[0].parameter[param] = param_defaults[param];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef NEED_GETOPT
|
||||
struct option {
|
||||
char *name;
|
||||
@@ -607,7 +575,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
espeak_ng_InitializePath(data_path);
|
||||
initialise();
|
||||
espeak_ng_STATUS result = espeak_ng_Initialize();
|
||||
if (result != ENS_OK) {
|
||||
if (result == ENE_READ_ERROR)
|
||||
fprintf(stderr, "Failed to load espeak-data\n");
|
||||
else
|
||||
fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (voicename[0] == 0)
|
||||
strcpy(voicename, "default");
|
||||
|
||||
Reference in New Issue
Block a user