diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2010-03-17 11:40:22 -0700 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2010-03-17 15:59:59 -0700 |
commit | 2821fc14ed38e674f41309fc52d5f52a6b9bb1da (patch) | |
tree | 4164e6bce29eacf5eddda8a4fefeb3e40f128939 /pico | |
parent | df387f9c2d4cb129ad311dbda30b7fd52f274cb1 (diff) | |
download | external_svox-2821fc14ed38e674f41309fc52d5f52a6b9bb1da.zip external_svox-2821fc14ed38e674f41309fc52d5f52a6b9bb1da.tar.gz external_svox-2821fc14ed38e674f41309fc52d5f52a6b9bb1da.tar.bz2 |
Fix bug 2449825 Patch from SVOX
Prevent random utterances in Pico TTS when synthesizing
an empty string.
In same patch:
Automatic volume raising tags in the Manager Layer are now removed
NOTE : It is still possible to selectively raise the volume for
portions of the input text, by embedding volume tags in the text
itself. These tags will not be removed by the Manager Layer.
Change-Id: I56fafcf6c1cff986a7394526027534308f227431
Diffstat (limited to 'pico')
-rw-r--r-- | pico/tts/com_svox_picottsengine.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/pico/tts/com_svox_picottsengine.cpp b/pico/tts/com_svox_picottsengine.cpp index 450ebcb..eb5470b 100644 --- a/pico/tts/com_svox_picottsengine.cpp +++ b/pico/tts/com_svox_picottsengine.cpp @@ -61,7 +61,7 @@ using namespace android; /* speaking volume */ #define PICO_MIN_VOLUME 0 #define PICO_MAX_VOLUME 500 -#define PICO_DEF_VOLUME 120 +#define PICO_DEF_VOLUME 100 /* string constants */ #define MAX_OUTBUF_SIZE 128 @@ -515,7 +515,6 @@ static char * doAddProperties( const char * str ) char * data = NULL; int haspitch, hasspeed, hasvol; /* parameters */ int textlen; /* property string length */ - haspitch = 0; hasspeed = 0; hasvol = 0; textlen = strlen(str) + 1; if (picoProp_currPitch != PICO_DEF_PITCH) { /* non-default pitch */ @@ -529,15 +528,11 @@ static char * doAddProperties( const char * str ) hasspeed = 1; } - // Always set the volume for now - this is to work around not being able - // to change the default volume. - // TODO: Fix the underlying problem so that default volume as defined by - // PICO_DEF_VOLUME is respected. - //if (picoProp_currVolume != PICO_DEF_VOLUME) { /* non-default volume */ + if (picoProp_currVolume != PICO_DEF_VOLUME) { /* non-default volume */ textlen += strlen(PICO_VOLUME_OPEN_TAG) + 5; textlen += strlen(PICO_VOLUME_CLOSE_TAG); hasvol = 1; - //} + } /* Compose the property strings. */ data = (char *) malloc( textlen ); /* allocate string */ @@ -567,7 +562,6 @@ static char * doAddProperties( const char * str ) } strcat(data, str); - if (hasvol) { strcat(data, PICO_VOLUME_CLOSE_TAG); } @@ -579,7 +573,6 @@ static char * doAddProperties( const char * str ) if (haspitch) { strcat(data, PICO_PITCH_CLOSE_TAG); } - return data; } @@ -706,6 +699,7 @@ static char * doCamelCase( const char * str ) } //} /* Allocate the return string */ + data = (char *) malloc( totlen ); /* allocate string */ if (!data) { return NULL; @@ -730,7 +724,10 @@ static char * doCamelCase( const char * str ) pos=tokstart+tlen_2; } //} - data[outpos -1] = 0; + if (outpos == 0) { + outpos = 1; + } + data[outpos-1] = 0; return data; }/*doCamelCase*/ @@ -1447,6 +1444,10 @@ tts_result TtsEngine::synthesizeText( const char * text, int8_t * buffer, size_t return TTS_FAILURE; } + if (strlen(text) == 0) { + return TTS_SUCCESS; + } + if (buffer == NULL) { LOGE("synthesizeText called with NULL buffer"); return TTS_FAILURE; @@ -1509,7 +1510,6 @@ tts_result TtsEngine::synthesizeText( const char * text, int8_t * buffer, size_t /* Add property tags to the string - if any. */ local_text = (pico_Char *) doAddProperties( expanded_text ); if (expanded_text) { - LOGV("freeing string for %s", expanded_text); free( expanded_text ); } if (!local_text) { @@ -1526,7 +1526,6 @@ tts_result TtsEngine::synthesizeText( const char * text, int8_t * buffer, size_t /* synthesis loop */ while (text_remaining) { - if (picoSynthAbort) { ret = pico_resetEngine( picoEngine, PICO_RESET_SOFT ); break; |