|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define N_XML_BUF 500 |
|
|
#define N_XML_BUF 500 |
|
|
|
|
|
|
|
|
|
|
|
static void TerminateBufWithSpaceAndZero(char *buf, int index); |
|
|
|
|
|
|
|
|
static const char *xmlbase = ""; // base URL from <speak> |
|
|
static const char *xmlbase = ""; // base URL from <speak> |
|
|
|
|
|
|
|
|
static int namedata_ix = 0; |
|
|
static int namedata_ix = 0; |
|
|
|
|
|
|
|
|
// end the clause now and pick up the punctuation next time |
|
|
// end the clause now and pick up the punctuation next time |
|
|
UngetC(c2); |
|
|
UngetC(c2); |
|
|
ungot_char2 = c1; |
|
|
ungot_char2 = c1; |
|
|
buf[0] = ' '; |
|
|
|
|
|
buf[1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, 0); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Perhaps not enough room, end the clause before the SSML tag |
|
|
// Perhaps not enough room, end the clause before the SSML tag |
|
|
UngetC(c2); |
|
|
UngetC(c2); |
|
|
ungot_char2 = c1; |
|
|
ungot_char2 = c1; |
|
|
buf[ix] = ' '; |
|
|
|
|
|
buf[ix+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
return CLAUSE_NONE; |
|
|
return CLAUSE_NONE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, 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++] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
|
|
|
|
|
|
if (terminator & CLAUSE_TYPE_VOICE_CHANGE) |
|
|
if (terminator & CLAUSE_TYPE_VOICE_CHANGE) |
|
|
strcpy(voice_change, current_voice_id); |
|
|
strcpy(voice_change, current_voice_id); |
|
|
|
|
|
|
|
|
ix += utf8_out(c1, &buf[ix]); |
|
|
ix += utf8_out(c1, &buf[ix]); |
|
|
terminator = CLAUSE_PERIOD; // line doesn't end in punctuation, assume period |
|
|
terminator = CLAUSE_PERIOD; // line doesn't end in punctuation, assume period |
|
|
} |
|
|
} |
|
|
buf[ix] = ' '; |
|
|
|
|
|
buf[ix+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
return terminator; |
|
|
return terminator; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (end_clause_after_tag) |
|
|
if (end_clause_after_tag) |
|
|
RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation |
|
|
RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation |
|
|
buf[ix] = ' '; |
|
|
|
|
|
buf[ix+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
if (parag > 3) |
|
|
if (parag > 3) |
|
|
parag = 3; |
|
|
parag = 3; |
|
|
if (option_ssml) parag = 1; |
|
|
if (option_ssml) parag = 1; |
|
|
|
|
|
|
|
|
if (linelength <= option_linelength) { |
|
|
if (linelength <= option_linelength) { |
|
|
// treat lines shorter than a specified length as end-of-clause |
|
|
// treat lines shorter than a specified length as end-of-clause |
|
|
UngetC(c2); |
|
|
UngetC(c2); |
|
|
buf[ix] = ' '; |
|
|
|
|
|
buf[ix+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
return CLAUSE_COLON; |
|
|
return CLAUSE_COLON; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!IsAlpha(c1) || !iswlower(c1)) { |
|
|
if (!IsAlpha(c1) || !iswlower(c1)) { |
|
|
UngetC(c2); |
|
|
UngetC(c2); |
|
|
ungot_char2 = c1; |
|
|
ungot_char2 = c1; |
|
|
buf[end_clause_index] = ' '; // delete the end-clause punctuation |
|
|
|
|
|
buf[end_clause_index+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, end_clause_index); |
|
|
return end_clause_after_tag; |
|
|
return end_clause_after_tag; |
|
|
} |
|
|
} |
|
|
end_clause_after_tag = 0; |
|
|
end_clause_after_tag = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_end_clause) { |
|
|
if (is_end_clause) { |
|
|
UngetC(c_next); |
|
|
UngetC(c_next); |
|
|
buf[ix] = ' '; |
|
|
|
|
|
buf[ix+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
|
|
|
|
|
|
if (iswdigit(cprev) && !IsAlpha(c_next)) // ???? |
|
|
if (iswdigit(cprev) && !IsAlpha(c_next)) // ???? |
|
|
punct_data &= ~CLAUSE_DOT_AFTER_LAST_WORD; |
|
|
punct_data &= ~CLAUSE_DOT_AFTER_LAST_WORD; |
|
|
|
|
|
|
|
|
// clause too long, getting near end of buffer, so break here |
|
|
// clause too long, getting near end of buffer, so break here |
|
|
// try to break at a word boundary (unless we actually reach the end of buffer). |
|
|
// try to break at a word boundary (unless we actually reach the end of buffer). |
|
|
// (n_buf-4) is to allow for 3 bytes of multibyte character plus terminator. |
|
|
// (n_buf-4) is to allow for 3 bytes of multibyte character plus terminator. |
|
|
buf[ix] = ' '; |
|
|
|
|
|
buf[ix+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
UngetC(c2); |
|
|
UngetC(c2); |
|
|
return CLAUSE_NONE; |
|
|
return CLAUSE_NONE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ix += utf8_out(CHAR_EMPHASIS, &buf[ix]); |
|
|
ix += utf8_out(CHAR_EMPHASIS, &buf[ix]); |
|
|
if (end_clause_after_tag) |
|
|
if (end_clause_after_tag) |
|
|
RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation |
|
|
RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation |
|
|
buf[ix] = ' '; |
|
|
|
|
|
buf[ix+1] = 0; |
|
|
|
|
|
|
|
|
TerminateBufWithSpaceAndZero(buf, ix); |
|
|
return CLAUSE_EOF; // end of file |
|
|
return CLAUSE_EOF; // end of file |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmlbase = NULL; |
|
|
xmlbase = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void TerminateBufWithSpaceAndZero(char *buf, int index) { |
|
|
|
|
|
buf[index] = ' '; |
|
|
|
|
|
buf[index+1] = 0; |
|
|
|
|
|
} |