Browse Source

code cleanup: remove unnecessary current_voice_id in readclause.c

Instead of passing a temporary variable current_voice_id to SSML
processing logic and then copying the value to voice_change, pass
voice_change directly. GetVoiceAttributes() both sets voice_change and
retuns CLAUSE_TYPE_VOICE_CHANGE that is used by TranslateClause() for
error checking.

tests/ssml/language-switch.ssml covers the intended behavior of language
switching and will fail when either voice_change or CLAUSE_TYPE_VOICE_CHANGE
is not set correctly.
master
Juho Hiltunen 4 years ago
parent
commit
19e2f697f6
2 changed files with 2 additions and 10 deletions
  1. 1
    9
      src/libespeak-ng/readclause.c
  2. 1
    1
      src/libespeak-ng/ssml.c

+ 1
- 9
src/libespeak-ng/readclause.c View File

@@ -74,7 +74,6 @@ static SSML_STACK ssml_stack[N_SSML_STACK];

static espeak_VOICE base_voice;
static char base_voice_variant_name[40] = { 0 };
static char current_voice_id[40] = { 0 };

static int n_param_stack;
PARAM_STACK param_stack[N_PARAM_STACK];
@@ -652,7 +651,6 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
tr->clause_upper_count = 0;
tr->clause_lower_count = 0;
*tone_type = 0;
*voice_change = 0;

if (ungot_char2 != 0)
c2 = ungot_char2;
@@ -743,14 +741,11 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
xml_buf[n_xml_buf] = 0;
c2 = ' ';

terminator = ProcessSsmlTag(xml_buf, buf, &ix, n_buf, xmlbase, &audio_text, current_voice_id, &base_voice, base_voice_variant_name, &ignore_text, &clear_skipping_text, &sayas_mode, &sayas_start, ssml_stack, &n_ssml_stack, &n_param_stack, (int *)speech_parameters);
terminator = ProcessSsmlTag(xml_buf, buf, &ix, n_buf, xmlbase, &audio_text, voice_change, &base_voice, base_voice_variant_name, &ignore_text, &clear_skipping_text, &sayas_mode, &sayas_start, ssml_stack, &n_ssml_stack, &n_param_stack, (int *)speech_parameters);

if (terminator != 0) {
buf[ix] = ' ';
buf[ix++] = 0;

if (terminator & CLAUSE_TYPE_VOICE_CHANGE)
strcpy(voice_change, current_voice_id);
return terminator;
}
c1 = ' ';
@@ -1139,9 +1134,6 @@ void InitText2(void)

option_punctuation = speech_parameters[espeakPUNCTUATION];
option_capitals = speech_parameters[espeakCAPITALS];

current_voice_id[0] = 0;

ignore_text = false;
audio_text = false;
clear_skipping_text = false;

+ 1
- 1
src/libespeak-ng/ssml.c View File

@@ -312,7 +312,7 @@ static int GetVoiceAttributes(wchar_t *pw, int tag_type, SSML_STACK *ssml_sp, SS
// a voice change.
// If it's a closing tag, delete the top frame of the stack and determine whether this implies
// a voice change.
// Returns CLAUSE_TYPE_VOICE_CHANGE if there is a voice change
// if there is a voice change, sets current_voice_id and returns CLAUSE_TYPE_VOICE_CHANGE

wchar_t *lang;
wchar_t *gender;

Loading…
Cancel
Save