|
|
|
|
|
|
|
|
// bit 1 1 = change tone only, not language |
|
|
// bit 1 1 = change tone only, not language |
|
|
// bit 2 1 = don't report error on LoadDictionary |
|
|
// bit 2 1 = don't report error on LoadDictionary |
|
|
// bit 4 1 = vname = full path |
|
|
// bit 4 1 = vname = full path |
|
|
|
|
|
// bit 8 1 = INTERNAL: compiling phonemes; do not try to |
|
|
|
|
|
// load the phoneme table |
|
|
|
|
|
// bit 16 1 = UNDOCUMENTED |
|
|
|
|
|
|
|
|
FILE *f_voice = NULL; |
|
|
FILE *f_voice = NULL; |
|
|
char *p; |
|
|
char *p; |
|
|
|
|
|
|
|
|
if (GetFileLength(buf) <= 0) |
|
|
if (GetFileLength(buf) <= 0) |
|
|
return NULL; |
|
|
return NULL; |
|
|
} else { |
|
|
} else { |
|
|
if (voicename[0] == 0) |
|
|
|
|
|
|
|
|
if (voicename[0] == 0 && !(control & 8)/*compiling phonemes*/) |
|
|
strcpy(voicename, ESPEAKNG_DEFAULT_VOICE); |
|
|
strcpy(voicename, ESPEAKNG_DEFAULT_VOICE); |
|
|
|
|
|
|
|
|
sprintf(path_voices, "%s%cvoices%c", path_home, PATHSEP, PATHSEP); |
|
|
sprintf(path_voices, "%s%cvoices%c", path_home, PATHSEP, PATHSEP); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f_voice = fopen(buf, "r"); |
|
|
f_voice = fopen(buf, "r"); |
|
|
|
|
|
|
|
|
language_type = "en"; // default |
|
|
|
|
|
|
|
|
if (!(control & 8)/*compiling phonemes*/) |
|
|
|
|
|
language_type = "en"; // default |
|
|
|
|
|
else |
|
|
|
|
|
language_type = ""; |
|
|
|
|
|
|
|
|
if (f_voice == NULL) { |
|
|
if (f_voice == NULL) { |
|
|
if (control & 3) |
|
|
if (control & 3) |
|
|
return NULL; // can't open file |
|
|
return NULL; // can't open file |
|
|
|
|
|
|
|
|
if (tone_only) |
|
|
if (tone_only) |
|
|
new_translator = translator; |
|
|
new_translator = translator; |
|
|
else { |
|
|
else { |
|
|
if ((ix = SelectPhonemeTableName(phonemes_name)) < 0) { |
|
|
|
|
|
|
|
|
if (!!(control & 8/*compiling phonemes*/)) { |
|
|
|
|
|
/* Set by espeak_ng_CompilePhonemeDataPath when it |
|
|
|
|
|
* calls LoadVoice("", 8) to set up a dummy(?) voice. |
|
|
|
|
|
* As phontab may not yet exist this avoids the spurious |
|
|
|
|
|
* error message and guarantees consistent results by |
|
|
|
|
|
* not actually reading a potentially bogus phontab... |
|
|
|
|
|
*/ |
|
|
|
|
|
ix = 0; |
|
|
|
|
|
} else if ((ix = SelectPhonemeTableName(phonemes_name)) < 0) { |
|
|
fprintf(stderr, "Unknown phoneme table: '%s'\n", phonemes_name); |
|
|
fprintf(stderr, "Unknown phoneme table: '%s'\n", phonemes_name); |
|
|
ix = 0; |
|
|
ix = 0; |
|
|
} |
|
|
} |
|
|
voice->phoneme_tab_ix = ix; |
|
|
voice->phoneme_tab_ix = ix; |
|
|
new_translator->phoneme_tab_ix = ix; |
|
|
new_translator->phoneme_tab_ix = ix; |
|
|
new_translator->dict_min_size = dict_min; |
|
|
new_translator->dict_min_size = dict_min; |
|
|
LoadDictionary(new_translator, new_dictionary, control & 4); |
|
|
|
|
|
if (dictionary_name[0] == 0) { |
|
|
|
|
|
DeleteTranslator(new_translator); |
|
|
|
|
|
return NULL; // no dictionary loaded |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (!(control & 8/*compiling phonemes*/)) { |
|
|
|
|
|
LoadDictionary(new_translator, new_dictionary, control & 4); |
|
|
|
|
|
if (dictionary_name[0] == 0) { |
|
|
|
|
|
DeleteTranslator(new_translator); |
|
|
|
|
|
return NULL; // no dictionary loaded |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
new_translator->dict_condition = conditional_rules; |
|
|
new_translator->dict_condition = conditional_rules; |
|
|
|
|
|
|