Browse Source

Possible fix to segfault when changing voices in SSML <s> tags.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@148 d46cf337-b52f-0410-862d-fd96e6ae7743
master
jonsd 17 years ago
parent
commit
28943f9000
1 changed files with 14 additions and 15 deletions
  1. 14
    15
      src/readclause.cpp

+ 14
- 15
src/readclause.cpp View File



#define N_SSML_STACK 20 #define N_SSML_STACK 20
int n_ssml_stack; int n_ssml_stack;
SSML_STACK *ssml_sp;
SSML_STACK ssml_stack[N_SSML_STACK]; SSML_STACK ssml_stack[N_SSML_STACK];


char current_voice_id[40] = {0}; char current_voice_id[40] = {0};
#define SSML_CLOSE 0x10 // for a closing tag, OR this with the tag type #define SSML_CLOSE 0x10 // for a closing tag, OR this with the tag type


// 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,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};




MNEM_TAB ssmltags[] = { MNEM_TAB ssmltags[] = {
wchar_t *age; wchar_t *age;
wchar_t *variant; wchar_t *variant;
const char *new_voice_id; const char *new_voice_id;
SSML_STACK *ssml_sp;


static const MNEM_TAB mnem_gender[] = { static const MNEM_TAB mnem_gender[] = {
{"male", 1}, {"male", 1},
{ {
n_ssml_stack--; n_ssml_stack--;
} }
ssml_sp = &ssml_stack[n_ssml_stack];
} }
else else
{ {
char tag_name[40]; char tag_name[40];
char buf[80]; char buf[80];
PARAM_STACK *sp; PARAM_STACK *sp;
SSML_STACK *ssml_sp;


static const MNEM_TAB mnem_punct[] = { static const MNEM_TAB mnem_punct[] = {
{"none", 1}, {"none", 1},


voice_change_flag = 0; voice_change_flag = 0;
terminator = CLAUSE_NONE; terminator = CLAUSE_NONE;
ssml_sp = &ssml_stack[n_ssml_stack-1];


switch(tag_type) switch(tag_type)
{ {
return(CLAUSE_COLON); return(CLAUSE_COLON);


case SSML_SENTENCE: case SSML_SENTENCE:
if((ssml_sp != NULL) && (ssml_sp->tag_type == SSML_SENTENCE))
if(ssml_sp->tag_type == SSML_SENTENCE)
{ {
// new sentence implies end-of-sentence // new sentence implies end-of-sentence
voice_change_flag = GetVoiceAttributes(px, SSML_SENTENCE+SSML_CLOSE); voice_change_flag = GetVoiceAttributes(px, SSML_SENTENCE+SSML_CLOSE);




case SSML_PARAGRAPH: case SSML_PARAGRAPH:
if(ssml_sp != NULL)
if(ssml_sp->tag_type == SSML_SENTENCE)
{ {
if(ssml_sp->tag_type == SSML_SENTENCE)
{
// new paragraph implies end-of-sentence or end-of-paragraph
voice_change_flag = GetVoiceAttributes(px, SSML_SENTENCE+SSML_CLOSE);
}
if(ssml_sp->tag_type == SSML_PARAGRAPH)
{
// new paragraph implies end-of-sentence or end-of-paragraph
voice_change_flag |= GetVoiceAttributes(px, SSML_PARAGRAPH+SSML_CLOSE);
}
// new paragraph implies end-of-sentence or end-of-paragraph
voice_change_flag = GetVoiceAttributes(px, SSML_SENTENCE+SSML_CLOSE);
}
if(ssml_sp->tag_type == SSML_PARAGRAPH)
{
// new paragraph implies end-of-sentence or end-of-paragraph
voice_change_flag |= GetVoiceAttributes(px, SSML_PARAGRAPH+SSML_CLOSE);
} }
voice_change_flag |= GetVoiceAttributes(px, tag_type); voice_change_flag |= GetVoiceAttributes(px, tag_type);
return(CLAUSE_PARAGRAPH + voice_change_flag); return(CLAUSE_PARAGRAPH + voice_change_flag);


n_ssml_stack =1; n_ssml_stack =1;
n_param_stack = 1; n_param_stack = 1;
ssml_stack[0].tag_type = 0;


for(param=0; param<N_SPEECH_PARAM; param++) for(param=0; param<N_SPEECH_PARAM; param++)
speech_parameters[param] = param_stack[0].parameter[param]; // set all speech parameters to defaults speech_parameters[param] = param_stack[0].parameter[param]; // set all speech parameters to defaults

Loading…
Cancel
Save