This will make it easier to set a default voice other than English. This is important for cases when a language will fall back to the default voice. Some references to L('e', 'n') still need to be changed.master
} | } | ||||
*outptr = 0; | *outptr = 0; | ||||
if (c == 0) { | if (c == 0) { | ||||
if (strcmp(p_lang, "en") == 0) { | |||||
*p_lang = 0; // don't need "en", it's assumed by default | |||||
if (strcmp(p_lang, ESPEAKNG_DEFAULT_VOICE) == 0) { | |||||
*p_lang = 0; // don't need ESPEAKNG_DEFAULT_VOICE, it's assumed by default | |||||
return p; | return p; | ||||
} | } | ||||
} else | } else |
if (tr->translator_name == L('e', 'n')) | if (tr->translator_name == L('e', 'n')) | ||||
return; // we are already using English | return; // we are already using English | ||||
SetTranslator2("en"); | |||||
SetTranslator2(ESPEAKNG_DEFAULT_VOICE); | |||||
if (Lookup(translator2, &single_letter[2], ph_buf3) != 0) { | if (Lookup(translator2, &single_letter[2], ph_buf3) != 0) { | ||||
// yes, switch to English and re-translate the word | // yes, switch to English and re-translate the word | ||||
sprintf(ph_buf1, "%c", phonSWITCH); | sprintf(ph_buf1, "%c", phonSWITCH); | ||||
// don't say "superscript" during normal text reading | // don't say "superscript" during normal text reading | ||||
Lookup(tr, modifier, capital); | Lookup(tr, modifier, capital); | ||||
if (capital[0] == 0) { | if (capital[0] == 0) { | ||||
capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2 | |||||
capital[2] = SetTranslator2(ESPEAKNG_DEFAULT_VOICE); // overwrites previous contents of translator2 | |||||
Lookup(translator2, modifier, &capital[3]); | Lookup(translator2, modifier, &capital[3]); | ||||
if (capital[3] != 0) { | if (capital[3] != 0) { | ||||
capital[0] = phonPAUSE; | capital[0] = phonPAUSE; | ||||
ph_buf2[0] = 0; | ph_buf2[0] = 0; | ||||
if (Lookup(translator, alphabet->name, ph_alphabet) == 0) { // the original language for the current voice | if (Lookup(translator, alphabet->name, ph_alphabet) == 0) { // the original language for the current voice | ||||
// Can't find the local name for this alphabet, use the English name | // Can't find the local name for this alphabet, use the English name | ||||
ph_alphabet[2] = SetTranslator2("en"); // overwrites previous contents of translator2 | |||||
ph_alphabet[2] = SetTranslator2(ESPEAKNG_DEFAULT_VOICE); // overwrites previous contents of translator2 | |||||
Lookup(translator2, alphabet->name, ph_buf2); | Lookup(translator2, alphabet->name, ph_buf2); | ||||
} else if (translator != tr) { | } else if (translator != tr) { | ||||
phontab_1 = tr->phoneme_tab_ix; | phontab_1 = tr->phoneme_tab_ix; |
if ((only == 0) && ((phonemes[0] == 0) || (phonemes[0] == phonSWITCH)) && (tr->translator_name != L('e', 'n'))) { | if ((only == 0) && ((phonemes[0] == 0) || (phonemes[0] == phonSWITCH)) && (tr->translator_name != L('e', 'n'))) { | ||||
// not found, try English | // not found, try English | ||||
SetTranslator2("en"); | |||||
SetTranslator2(ESPEAKNG_DEFAULT_VOICE); | |||||
string = &single_letter[1]; | string = &single_letter[1]; | ||||
single_letter[1] = '_'; | single_letter[1] = '_'; | ||||
if (LookupDictList(translator2, &string, phonemes, flags, 0, NULL) == 0) { | if (LookupDictList(translator2, &string, phonemes, flags, 0, NULL) == 0) { | ||||
LookupDictList(translator2, &string, phonemes, flags, 0, NULL); | LookupDictList(translator2, &string, phonemes, flags, 0, NULL); | ||||
} | } | ||||
if (phonemes[0]) | if (phonemes[0]) | ||||
lang_name = "en"; | |||||
lang_name = ESPEAKNG_DEFAULT_VOICE; | |||||
else | else | ||||
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table | SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table | ||||
} | } | ||||
if (lang_name) { | if (lang_name) { | ||||
SetWordStress(translator2, phonemes, flags, -1, 0); | SetWordStress(translator2, phonemes, flags, -1, 0); | ||||
DecodePhonemes(phonemes, phonemes2); | DecodePhonemes(phonemes, phonemes2); | ||||
sprintf(buf, "[\002_^_%s %s _^_%s]]", "en", phonemes2, WordToString2(tr->translator_name)); | |||||
sprintf(buf, "[\002_^_%s %s _^_%s]]", ESPEAKNG_DEFAULT_VOICE, phonemes2, WordToString2(tr->translator_name)); | |||||
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table | SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table | ||||
} else { | } else { | ||||
SetWordStress(tr, phonemes, flags, -1, 0); | SetWordStress(tr, phonemes, flags, -1, 0); |
espeak_ng_STATUS status; | espeak_ng_STATUS status; | ||||
if (translator == NULL) { | if (translator == NULL) { | ||||
status = espeak_ng_SetVoiceByName("en"); | |||||
status = espeak_ng_SetVoiceByName(ESPEAKNG_DEFAULT_VOICE); | |||||
if (status != ENS_OK) | if (status != ENS_OK) | ||||
return status; | return status; | ||||
} | } |
if (unpron_phonemes[0] == phonSWITCH) { | if (unpron_phonemes[0] == phonSWITCH) { | ||||
// change to another language in order to translate this word | // change to another language in order to translate this word | ||||
strcpy(word_phonemes, unpron_phonemes); | strcpy(word_phonemes, unpron_phonemes); | ||||
if (strcmp(&unpron_phonemes[1], "en") == 0) | |||||
if (strcmp(&unpron_phonemes[1], ESPEAKNG_DEFAULT_VOICE) == 0) | |||||
return FLAG_SPELLWORD; // _^_en must have been set in TranslateLetter(), not *_rules which uses only _^_ | return FLAG_SPELLWORD; // _^_en must have been set in TranslateLetter(), not *_rules which uses only _^_ | ||||
return 0; | return 0; | ||||
} | } | ||||
new_language = (char *)(&p[1]); | new_language = (char *)(&p[1]); | ||||
if (new_language[0] == 0) | if (new_language[0] == 0) | ||||
new_language = "en"; | |||||
new_language = ESPEAKNG_DEFAULT_VOICE; | |||||
switch_phonemes = SetTranslator2(new_language); | switch_phonemes = SetTranslator2(new_language); | ||||
f_voice = fopen(buf, "r"); | f_voice = fopen(buf, "r"); | ||||
if (!(control & 8)/*compiling phonemes*/) | if (!(control & 8)/*compiling phonemes*/) | ||||
language_type = "en"; // default | |||||
language_type = ESPEAKNG_DEFAULT_VOICE; // default | |||||
else | else | ||||
language_type = ""; | language_type = ""; | ||||