Browse Source

code cleanup: remove unnecessary new_translator in LoadVoice()

It looks like this was used in situations where both "language" and
"translator" voice options were found. Since bda8b6f76a "translator"
hasn't been supported.
master
Juho Hiltunen 4 years ago
parent
commit
f16b27b840
1 changed files with 20 additions and 28 deletions
  1. 20
    28
      src/libespeak-ng/voices.c

+ 20
- 28
src/libespeak-ng/voices.c View File

int conditional_rules = 0; int conditional_rules = 0;
LANGUAGE_OPTIONS *langopts = NULL; LANGUAGE_OPTIONS *langopts = NULL;


Translator *new_translator = NULL;

char voicename[40]; char voicename[40];
char language_name[40]; char language_name[40];
char translator_name[40]; char translator_name[40];
strcpy(phonemes_name, language_type); strcpy(phonemes_name, language_type);
SelectPhonemeTableName(phonemes_name); SelectPhonemeTableName(phonemes_name);


if (new_translator != NULL) translator = SelectTranslator(translator_name);
DeleteTranslator(new_translator); langopts = &translator->langopts;

new_translator = SelectTranslator(translator_name);
langopts = &new_translator->langopts;
strncpy0(voice->language_name, language_name, sizeof(voice->language_name)); strncpy0(voice->language_name, language_name, sizeof(voice->language_name));
} }
} }
if (f_voice != NULL) if (f_voice != NULL)
fclose(f_voice); fclose(f_voice);


if ((new_translator == NULL) && (!tone_only)) { if ((translator == NULL) && (!tone_only)) {
// not set by language attribute // not set by language attribute
new_translator = SelectTranslator(translator_name); translator = SelectTranslator(translator_name);
} }


SetSpeed(3); // for speed_percent SetSpeed(3); // for speed_percent
voice->height2[ix] = voice->height[ix]; voice->height2[ix] = voice->height[ix];
} }


if (tone_only) if (!tone_only) {
new_translator = translator;
else {
if (!!(control & 8/*compiling phonemes*/)) { if (!!(control & 8/*compiling phonemes*/)) {
/* Set by espeak_ng_CompilePhonemeDataPath when it /* Set by espeak_ng_CompilePhonemeDataPath when it
* calls LoadVoice("", 8) to set up a dummy(?) voice. * calls LoadVoice("", 8) to set up a dummy(?) voice.
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; translator->phoneme_tab_ix = ix;
new_translator->dict_min_size = dict_min; translator->dict_min_size = dict_min;
if (!(control & 8/*compiling phonemes*/)) { if (!(control & 8/*compiling phonemes*/)) {
LoadDictionary(new_translator, new_dictionary, control & 4); LoadDictionary(translator, new_dictionary, control & 4);
if (dictionary_name[0] == 0) { if (dictionary_name[0] == 0) {
DeleteTranslator(new_translator); DeleteTranslator(translator);
return NULL; // no dictionary loaded return NULL; // no dictionary loaded
} }
} }

translator->dict_condition = conditional_rules;
new_translator->dict_condition = conditional_rules;


voice_languages[langix] = 0; voice_languages[langix] = 0;
} }


if ((value = new_translator->langopts.param[LOPT_LENGTH_MODS]) != 0) if ((value = translator->langopts.param[LOPT_LENGTH_MODS]) != 0)
SetLengthMods(new_translator, value); SetLengthMods(translator, value);


voice->width[0] = (voice->width[0] * 105)/100; voice->width[0] = (voice->width[0] * 105)/100;


if (!tone_only)
translator = new_translator;

// relative lengths of different stress syllables // relative lengths of different stress syllables
for (ix = 0; ix < stress_lengths_set; ix++) for (ix = 0; ix < stress_lengths_set; ix++)
translator->stress_lengths[ix] = stress_lengths[ix]; translator->stress_lengths[ix] = stress_lengths[ix];

Loading…
Cancel
Save