diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index f45f1fa327..395ed95fba 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -317,13 +317,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session \param session the session to speak on \param tts_name the desired tts module \param voice_name the desired voice - \param rate the sample rate \param text the text to speak \param args arguements to pass for callbacks etc \return SWITCH_STATUS_SUCCESS if all is well */ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session, - char *tts_name, char *voice_name, uint32_t rate, char *text, switch_input_args_t *args); + char *tts_name, char *voice_name, char *text, switch_input_args_t *args); /*! \brief Make an outgoing call diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 1a8446d972..3a452efb29 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -3877,7 +3877,7 @@ static switch_status_t conference_local_play_file(conference_obj_t * conference, if (!(conference->tts_engine && conference->tts_voice)) { status = SWITCH_STATUS_FALSE; } else { - status = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, 0, path + 4, NULL); + status = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, path + 4, NULL); } goto done; } diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 31101daae1..70113991e6 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -942,7 +942,7 @@ SWITCH_STANDARD_APP(speak_function) args.input_callback = on_dtmf; args.buf = buf; args.buflen = sizeof(buf); - switch_ivr_speak_text(session, engine, voice, codec->implementation->samples_per_second, text, &args); + switch_ivr_speak_text(session, engine, voice, text, &args); } diff --git a/src/mod/applications/mod_ivrtest/mod_ivrtest.c b/src/mod/applications/mod_ivrtest/mod_ivrtest.c index 128d9cc018..16ff53cd43 100644 --- a/src/mod/applications/mod_ivrtest/mod_ivrtest.c +++ b/src/mod/applications/mod_ivrtest/mod_ivrtest.c @@ -207,7 +207,7 @@ static void tts_function(switch_core_session_t *session, char *data) args.input_callback = show_dtmf; args.buf = buf; args.buflen = sizeof(buf); - switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, &args); + switch_ivr_speak_text(session, tts_name, voice_name, text, &args); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n"); } @@ -405,7 +405,7 @@ static void ivrtest_function(switch_core_session_t *session, char *data) } snprintf(say, sizeof(say), "You Dialed [%s]\n", buf); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, say); - switch_ivr_speak_text(session, "cepstral", "david", codec->implementation->samples_per_second, say, NULL); + switch_ivr_speak_text(session, "cepstral", "david", say, NULL); } } diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index a83f0c9ec9..daad48d903 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -123,7 +123,6 @@ void CoreSession::setDTMFCallback(void *cbfunc, char *funcargs) { int CoreSession::speak(char *text) { switch_status_t status; - switch_codec_t *codec; sanity_check(-1); @@ -142,9 +141,9 @@ int CoreSession::speak(char *text) return SWITCH_STATUS_FALSE; } - codec = switch_core_session_get_read_codec(session); + begin_allow_threads(); - status = switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, ap); + status = switch_ivr_speak_text(session, tts_name, voice_name, text, ap); end_allow_threads(); return status == SWITCH_STATUS_SUCCESS ? 1 : 0; } diff --git a/src/switch_ivr_menu.c b/src/switch_ivr_menu.c index 28f69c016c..d4714c0eb0 100644 --- a/src/switch_ivr_menu.c +++ b/src/switch_ivr_menu.c @@ -263,7 +263,7 @@ static switch_status_t play_or_say(switch_core_session_t *session, switch_ivr_me } else { if (strlen(sound) > 4 && strncmp(sound, "say:", 4) == 0) { if (menu->tts_engine && menu->tts_voice) { - status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, sound + 4, &args); + status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, sound + 4, &args); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine to play sound\n"); } @@ -369,7 +369,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s status = switch_ivr_play_file(session, NULL, aptr, NULL); break; case SWITCH_IVR_ACTION_SAYTEXT: - status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, aptr, NULL); + status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, aptr, NULL); break; case SWITCH_IVR_ACTION_SAYPHRASE: status = switch_ivr_phrase_macro(session, aptr, "", menu->phrase_lang, NULL); diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 9f320bb4ad..96dd1b276b 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -250,11 +250,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", chan_lang); } } else if (!strcasecmp(func, "speak-text")) { - switch_codec_t *read_codec; - if ((read_codec = switch_core_session_get_read_codec(session))) { - - status = switch_ivr_speak_text(session, tts_engine, tts_voice, read_codec->implementation->samples_per_second, odata, args); - } + status = switch_ivr_speak_text(session, tts_engine, tts_voice, odata, args); } } } @@ -1340,9 +1336,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session, - char *tts_name, char *voice_name, uint32_t rate, char *text, switch_input_args_t *args) + char *tts_name, char *voice_name, char *text, switch_input_args_t *args) { switch_channel_t *channel; + uint32_t rate = 0; int interval = 0; switch_frame_t write_frame = { 0 }; switch_timer_t timer; @@ -1365,9 +1362,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses switch_core_session_reset(session); read_codec = switch_core_session_get_read_codec(session); - if (rate == 0) { - rate = read_codec->implementation->samples_per_second; - } + rate = read_codec->implementation->samples_per_second; + interval = read_codec->implementation->microseconds_per_frame / 1000; memset(&sh, 0, sizeof(sh)); if (switch_core_speech_open(&sh, tts_name, voice_name, (uint32_t) rate, interval, @@ -1380,7 +1376,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses switch_channel_answer(channel); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OPEN TTS %s\n", tts_name); - interval = read_codec->implementation->microseconds_per_frame / 1000; + codec_name = "L16"; if (switch_core_codec_init(&codec, diff --git a/src/switch_swig.c b/src/switch_swig.c index de5e43b4a9..e1e0cb9ad0 100644 --- a/src/switch_swig.c +++ b/src/switch_swig.c @@ -260,11 +260,11 @@ int fs_switch_ivr_session_transfer(switch_core_session_t *session, char *extensi return status == SWITCH_STATUS_SUCCESS ? 1 : 0; } -int fs_switch_ivr_speak_text(switch_core_session_t *session, char *tts_name, char *voice_name, uint32_t rate, char *text) +int fs_switch_ivr_speak_text(switch_core_session_t *session, char *tts_name, char *voice_name, char *text) { switch_status_t status; - status = switch_ivr_speak_text(session, tts_name, voice_name, rate, text, NULL); + status = switch_ivr_speak_text(session, tts_name, voice_name, text, NULL); return status == SWITCH_STATUS_SUCCESS ? 1 : 0; }