Browse Source

Fix crash: SSML when <voice name=""> has an unrecognised voice name.

SSML: Don't speak text within <metadata> </metadata>


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@145 d46cf337-b52f-0410-862d-fd96e6ae7743
master
jonsd 17 years ago
parent
commit
134f750277
3 changed files with 20 additions and 3 deletions
  1. 10
    1
      src/readclause.cpp
  2. 1
    0
      src/voice.h
  3. 9
    2
      src/voices.cpp

+ 10
- 1
src/readclause.cpp View File

@@ -190,6 +190,8 @@ int iswalpha(int c)
{
if(c < 0x100)
return(isalpha(c));
if((c > 0x3040) && (c <= 0xa700))
return(1); // japanese, chinese characters
if(c > MAX_WALPHA)
return(0);
return(walpha_tab[c-0x100]);
@@ -758,6 +760,7 @@ int Translator::AnnouncePunctuation(int c1, int c2, char *buf, int bufix)
#define SSML_AUDIO 11
#define SSML_EMPHASIS 12
#define SSML_BREAK 13
#define SSML_METADATA 14
#define HTML_BREAK 15
#define SSML_CLOSE 0x10 // for a closing tag, OR this with the tag type

@@ -779,6 +782,7 @@ MNEM_TAB ssmltags[] = {
{"audio", SSML_AUDIO},
{"emphasis", SSML_EMPHASIS},
{"break", SSML_BREAK},
{"metadata", SSML_METADATA},

{"br", HTML_BREAK},
{"li", HTML_BREAK},
@@ -816,7 +820,7 @@ static const char *VoiceFromStack()
{
sp = &ssml_stack[ix];

if(sp->voice_name[0] != 0)
if((sp->voice_name[0] != 0) && (SelectVoiceByName(NULL,sp->voice_name) != NULL))
{
strcpy(voice_name, sp->voice_name);
language[0] = 0;
@@ -1495,7 +1499,12 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
}
break;

case SSML_METADATA:
ignore_text = 1;
break;

case SSML_SUB + SSML_CLOSE:
case SSML_METADATA + SSML_CLOSE:
ignore_text = 0;
break;


+ 1
- 0
src/voice.h View File

@@ -71,6 +71,7 @@ extern voice_t *voice;
extern int tone_points[10];

const char *SelectVoice(espeak_VOICE *voice_select);
espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name);
voice_t *LoadVoice(const char *voice_name, int control);
voice_t *LoadVoiceVariant(const char *voice_name, int variant);
void DoVoiceChange(voice_t *v);

+ 9
- 2
src/voices.cpp View File

@@ -1221,8 +1221,8 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int



static espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
{//============================================================================
espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
{//=====================================================================
int ix;
int match_fname = -1;
int match_fname2 = -1;
@@ -1231,6 +1231,13 @@ static espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
int last_part_len;
char last_part[41];

if(voices == NULL)
{
if(n_voices_list == 0)
espeak_ListVoices(NULL); // create the voices list
voices = voices_list;
}

sprintf(last_part,"%c%s",PATHSEP,name);
last_part_len = strlen(last_part);


Loading…
Cancel
Save