diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 19823d07..366f70a7 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -549,24 +549,6 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output return short_pause; } -static void PopParamStack(int tag_type, char *outbuf, int *outix) -{ - // unwind the stack up to and including the previous tag of this type - int ix; - int top = 0; - - if (tag_type >= SSML_CLOSE) - tag_type -= SSML_CLOSE; - - for (ix = 0; ix < n_param_stack; ix++) { - if (param_stack[ix].type == tag_type) - top = ix; - } - if (top > 0) - n_param_stack = top; - ProcessParamStack(outbuf, outix, n_param_stack, param_stack, speech_parameters); -} - wchar_t *GetSsmlAttribute(wchar_t *pw, const char *name) { // Gets the value string for an attribute. @@ -902,7 +884,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb case SSML_STYLE + SSML_CLOSE: case SSML_PROSODY + SSML_CLOSE: case SSML_EMPHASIS + SSML_CLOSE: - PopParamStack(tag_type, outbuf, outix); + PopParamStack(tag_type, outbuf, outix, &n_param_stack, (PARAM_STACK *) param_stack, (int *) speech_parameters); break; case SSML_PHONEME: attr1 = GetSsmlAttribute(px, "alphabet"); @@ -1018,12 +1000,12 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb ProcessParamStack(outbuf, outix, n_param_stack, param_stack, speech_parameters); if (self_closing) - PopParamStack(tag_type, outbuf, outix); + PopParamStack(tag_type, outbuf, outix, &n_param_stack, (PARAM_STACK *) param_stack, (int *) speech_parameters); else audio_text = true; return CLAUSE_NONE; case SSML_AUDIO + SSML_CLOSE: - PopParamStack(tag_type, outbuf, outix); + PopParamStack(tag_type, outbuf, outix, &n_param_stack, (PARAM_STACK *) param_stack, (int *) speech_parameters); audio_text = false; return CLAUSE_NONE; case SSML_BREAK: diff --git a/src/libespeak-ng/ssml.c b/src/libespeak-ng/ssml.c index b3e95342..a0401d44 100644 --- a/src/libespeak-ng/ssml.c +++ b/src/libespeak-ng/ssml.c @@ -364,3 +364,22 @@ PARAM_STACK *PushParamStack(int tag_type, int *n_param_stack, PARAM_STACK *param sp->parameter[ix] = -1; return sp; } + +void PopParamStack(int tag_type, char *outbuf, int *outix, int *n_param_stack, PARAM_STACK *param_stack, int *speech_parameters) +{ + // unwind the stack up to and including the previous tag of this type + int ix; + int top = 0; + + if (tag_type >= SSML_CLOSE) + tag_type -= SSML_CLOSE; + + for (ix = 0; ix < *n_param_stack; ix++) { + if (param_stack[ix].type == tag_type) + top = ix; + } + if (top > 0) + *n_param_stack = top; + ProcessParamStack(outbuf, outix, *n_param_stack, param_stack, speech_parameters); +} + diff --git a/src/libespeak-ng/ssml.h b/src/libespeak-ng/ssml.h index 494d535e..1afcbdc8 100644 --- a/src/libespeak-ng/ssml.h +++ b/src/libespeak-ng/ssml.h @@ -79,3 +79,4 @@ int GetVoiceAttributes(wchar_t *pw, int tag_type, SSML_STACK *ssml_sp, SSML_STAC void ProcessParamStack(char *outbuf, int *outix, int n_param_stack, PARAM_STACK *param_stack, int *speech_parameters); PARAM_STACK *PushParamStack(int tag_type, int *n_param_stack, PARAM_STACK *param_stack); const char *VoiceFromStack(SSML_STACK *ssml_stack, int n_ssml_stack, espeak_VOICE *base_voice, char base_voice_variant_name[40]); +void PopParamStack(int tag_type, char *outbuf, int *outix, int *n_param_stack, PARAM_STACK *param_stack, int *speech_parameters);