Browse Source

Merge pull request #587

master
Valdis Vitolins 6 years ago
parent
commit
c38cb18de3

+ 12
- 2
src/espeak-ng.c View File

#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h>
#include <time.h> #include <time.h>


#include <espeak-ng/espeak_ng.h> #include <espeak-ng/espeak_ng.h>
"--voices=<language>\n" "--voices=<language>\n"
"\t List the available voices for the specified language.\n" "\t List the available voices for the specified language.\n"
"\t If <language> is omitted, then list all voices.\n" "\t If <language> is omitted, then list all voices.\n"
"--load Load voice from a file in current directory by name.\n"
"-h, --help Show this help.\n"; "-h, --help Show this help.\n";


int samplerate; int samplerate;
{ "compile-mbrola", optional_argument, 0, 0x10e }, { "compile-mbrola", optional_argument, 0, 0x10e },
{ "compile-intonations", no_argument, 0, 0x10f }, { "compile-intonations", no_argument, 0, 0x10f },
{ "compile-phonemes", optional_argument, 0, 0x110 }, { "compile-phonemes", optional_argument, 0, 0x110 },
{ "load", no_argument, 0, 0x111 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };


int value; int value;
int flag_stdin = 0; int flag_stdin = 0;
int flag_compile = 0; int flag_compile = 0;
int flag_load = 0;
int filesize = 0; int filesize = 0;
int synth_flags = espeakCHARS_AUTO | espeakPHONEMES | espeakENDPAUSE; int synth_flags = espeakCHARS_AUTO | espeakPHONEMES | espeakENDPAUSE;


int phoneme_options = 0; int phoneme_options = 0;
int option_linelength = 0; int option_linelength = 0;
int option_waveout = 0; int option_waveout = 0;
espeak_VOICE voice_select; espeak_VOICE voice_select;
char filename[200]; char filename[200];
char voicename[40]; char voicename[40];
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
case 0x111: // --load
flag_load = 1;
break;
default: default:
exit(0); exit(0);
} }
if (voicename[0] == 0) if (voicename[0] == 0)
strcpy(voicename, ESPEAKNG_DEFAULT_VOICE); strcpy(voicename, ESPEAKNG_DEFAULT_VOICE);


result = espeak_ng_SetVoiceByName(voicename);
if(flag_load)
result = espeak_ng_SetVoiceByFile(voicename);
else
result = espeak_ng_SetVoiceByName(voicename);
if (result != ENS_OK) { if (result != ENS_OK) {
memset(&voice_select, 0, sizeof(voice_select)); memset(&voice_select, 0, sizeof(voice_select));
voice_select.languages = voicename; voice_select.languages = voicename;

+ 3
- 0
src/include/espeak-ng/espeak_ng.h View File

ESPEAK_NG_API espeak_ng_STATUS ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SetVoiceByName(const char *name); espeak_ng_SetVoiceByName(const char *name);


ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SetVoiceByFile(const char *filename);

ESPEAK_NG_API espeak_ng_STATUS ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SetVoiceByProperties(espeak_VOICE *voice_selector); espeak_ng_SetVoiceByProperties(espeak_VOICE *voice_selector);



+ 13
- 0
src/include/espeak-ng/speak_lib.h View File

are listed, and they are listed in preference order. are listed, and they are listed in preference order.
*/ */


#ifdef __cplusplus
extern "C"
#endif
ESPEAK_API espeak_ERROR espeak_SetVoiceByFile(const char *filename);
/* Loads a voice given the file path. Language is not considered.
"filename" is a UTF8 string.

Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/

#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif

+ 5
- 0
src/libespeak-ng/espeak_api.c View File

return status_to_espeak_error(espeak_ng_SetVoiceByName(name)); return status_to_espeak_error(espeak_ng_SetVoiceByName(name));
} }


ESPEAK_API espeak_ERROR espeak_SetVoiceByFile(const char *filename)
{
return status_to_espeak_error(espeak_ng_SetVoiceByFile(filename));
}

ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_selector) ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_selector)
{ {
return status_to_espeak_error(espeak_ng_SetVoiceByProperties(voice_selector)); return status_to_espeak_error(espeak_ng_SetVoiceByProperties(voice_selector));

+ 39
- 0
src/libespeak-ng/voices.c View File



#pragma GCC visibility push(default) #pragma GCC visibility push(default)



ESPEAK_NG_API espeak_ng_STATUS espeak_ng_SetVoiceByFile(const char *filename)
{
espeak_VOICE *v;
int ix;
espeak_VOICE voice_selector;
char *variant_name;
static char buf[60];

strncpy0(buf, filename, sizeof(buf));

variant_name = ExtractVoiceVariantName(buf, 0, 1);

for (ix = 0;; ix++) {
// convert voice name to lower case (ascii)
if ((buf[ix] = tolower(buf[ix])) == 0)
break;
}

memset(&voice_selector, 0, sizeof(voice_selector));
voice_selector.name = (char *)filename; // include variant name in voice stack ??

// first check for a voice with this filename
// This may avoid the need to call espeak_ListVoices().

if (LoadVoice(buf, 0x10) != NULL) {
if (variant_name[0] != 0)
LoadVoice(variant_name, 2);

DoVoiceChange(voice);
voice_selector.languages = voice->language_name;
SetVoiceStack(&voice_selector, variant_name);
return ENS_OK;
}

return ENS_VOICE_NOT_FOUND;
}


ESPEAK_NG_API espeak_ng_STATUS espeak_ng_SetVoiceByName(const char *name) ESPEAK_NG_API espeak_ng_STATUS espeak_ng_SetVoiceByName(const char *name)
{ {
espeak_VOICE *v; espeak_VOICE *v;

Loading…
Cancel
Save