From 19e2f697f63a20911e65f7363a2458e733fdd937 Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Thu, 25 Feb 2021 19:30:08 +0200 Subject: [PATCH] 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. --- src/libespeak-ng/readclause.c | 10 +--------- src/libespeak-ng/ssml.c | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 0acaa062..372a7065 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -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; diff --git a/src/libespeak-ng/ssml.c b/src/libespeak-ng/ssml.c index c9ca85a1..ce2232ec 100644 --- a/src/libespeak-ng/ssml.c +++ b/src/libespeak-ng/ssml.c @@ -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;