Browse Source

code cleanup: Move self_closing checks to ProcessSsmlTag()

This is a bit slower since we don't pass n_xml_buf as an argument but
rather get it with a call to wcslen. It is much cleaner though, since
the name ProcessSsmlTag() implies that all processing should be done
there.
master
Juho Hiltunen 5 years ago
parent
commit
75d66c89d0
3 changed files with 11 additions and 11 deletions
  1. 1
    9
      src/libespeak-ng/readclause.c
  2. 10
    1
      src/libespeak-ng/ssml.c
  3. 0
    1
      src/libespeak-ng/ssml.h

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

int terminator; int terminator;
int found; int found;
bool any_alnum = false; bool any_alnum = false;
bool self_closing;
int punct_data = 0; int punct_data = 0;
bool is_end_clause; bool is_end_clause;
int announced_punctuation = 0; int announced_punctuation = 0;
xml_buf[n_xml_buf] = 0; xml_buf[n_xml_buf] = 0;
c2 = ' '; c2 = ' ';


self_closing = false;
if (xml_buf[n_xml_buf-1] == '/') {
// a self-closing tag
xml_buf[n_xml_buf-1] = ' ';
self_closing = true;
}

terminator = ProcessSsmlTag(xml_buf, buf, &ix, n_buf, self_closing, 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, 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);


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

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

} }
} }


int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, bool self_closing, const char *xmlbase, bool *audio_text, char *current_voice_id, espeak_VOICE *base_voice, char *base_voice_variant_name, bool *ignore_text, bool *clear_skipping_text, int *sayas_mode, int *sayas_start, SSML_STACK *ssml_stack, int *n_ssml_stack, int *n_param_stack, int *speech_parameters)
int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, const char *xmlbase, bool *audio_text, char *current_voice_id, espeak_VOICE *base_voice, char *base_voice_variant_name, bool *ignore_text, bool *clear_skipping_text, int *sayas_mode, int *sayas_start, SSML_STACK *ssml_stack, int *n_ssml_stack, int *n_param_stack, int *speech_parameters)
{ {
// xml_buf is the tag and attributes with a zero terminator in place of the original '>' // xml_buf is the tag and attributes with a zero terminator in place of the original '>'
// returns a clause terminator value. // returns a clause terminator value.
// these tags have no effect if they are self-closing, eg. <voice /> // these tags have no effect if they are self-closing, eg. <voice />
static char ignore_if_self_closing[] = { 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0 }; static char ignore_if_self_closing[] = { 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0 };


bool self_closing = false;
int len;
len = wcslen(xml_buf);
if (xml_buf[len - 1] == '/') {
// a self-closing tag
xml_buf[len - 1] = ' ';
self_closing = true;
}

static const MNEM_TAB mnem_phoneme_alphabet[] = { static const MNEM_TAB mnem_phoneme_alphabet[] = {
{ "espeak", 1 }, { "espeak", 1 },
{ NULL, -1 } { NULL, -1 }

+ 0
- 1
src/libespeak-ng/ssml.h View File

char *outbuf, char *outbuf,
int *outix, int *outix,
int n_outbuf, int n_outbuf,
bool self_closing,
const char *xmlbase, const char *xmlbase,
bool *audio_text, bool *audio_text,
char *current_voice_id, char *current_voice_id,

Loading…
Cancel
Save