From f0211bc6e4c85e3118c161a610bbd397bc6492db Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 16 Oct 2007 16:49:44 +0000 Subject: [PATCH] make * and # become words explicitly in the core tts func git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5895 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_ivr_play_say.c | 41 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 78de3d7618..4eaf2e925d 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -1200,6 +1200,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session switch_status_t status = SWITCH_STATUS_SUCCESS; switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; uint32_t rate = 0; + int extra = 0; + char *p, *tmp = NULL; channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -1216,9 +1218,46 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session len = sh->samples * 2; flags = 0; - switch_sleep(200000); + //switch_sleep(200000); + for(p = text; p && *p; p++) { + if (*p == '*') { + extra += 4; + } else if (*p == '#') { + extra += 5; + } + } + + if (extra) { + char *tp; + switch_size_t mylen = strlen(text) + extra + 1; + tmp = malloc(mylen); + tp = tmp; + for (p = text; p && *p; p++) { + if (*p == '*') { + *tp++ = 's'; + *tp++ = 't'; + *tp++ = 'a'; + *tp++ = 'r'; + p++; + } else if (*p == '#') { + *tp++ = 'p'; + *tp++ = 'o'; + *tp++ = 'u'; + *tp++ = 'n'; + *tp++ = 'd'; + p++; + } else { + *tp++ = *p; + } + } + *tp = '\0'; + text = tmp; + } + switch_core_speech_feed_tts(sh, text, &flags); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Speaking text: %s\n", text); + switch_safe_free(tmp); + text = NULL; write_frame.rate = sh->rate;