[Freeswitch-svn] [commit] r5670 - in freeswitch/trunk/src: . include mod/applications/mod_conference mod/applications/mod_dptools mod/applications/mod_ivrtest
Author: anthm Date: Tue Aug 28 13:06:20 2007 New Revision: 5670 Modified: freeswitch/trunk/src/include/switch_ivr.h freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c freeswitch/trunk/src/switch_cpp.cpp freeswitch/trunk/src/switch_ivr_menu.c freeswitch/trunk/src/switch_ivr_play_say.c freeswitch/trunk/src/switch_swig.c Log: clean up speak code Modified: freeswitch/trunk/src/include/switch_ivr.h ============================================================================== --- freeswitch/trunk/src/include/switch_ivr.h (original) +++ freeswitch/trunk/src/include/switch_ivr.h Tue Aug 28 13:06:20 2007 @@ -317,13 +317,12 @@ \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 Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original) +++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Tue Aug 28 13:06:20 2007 @@ -3877,7 +3877,7 @@ 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; } Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original) +++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Aug 28 13:06:20 2007 @@ -942,7 +942,7 @@ 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); } Modified: freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c (original) +++ freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c Tue Aug 28 13:06:20 2007 @@ -207,7 +207,7 @@ 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 @@ } 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); } } Modified: freeswitch/trunk/src/switch_cpp.cpp ============================================================================== --- freeswitch/trunk/src/switch_cpp.cpp (original) +++ freeswitch/trunk/src/switch_cpp.cpp Tue Aug 28 13:06:20 2007 @@ -123,7 +123,6 @@ int CoreSession::speak(char *text) { switch_status_t status; - switch_codec_t *codec; sanity_check(-1); @@ -142,9 +141,9 @@ 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; } Modified: freeswitch/trunk/src/switch_ivr_menu.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_menu.c (original) +++ freeswitch/trunk/src/switch_ivr_menu.c Tue Aug 28 13:06:20 2007 @@ -263,7 +263,7 @@ } 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 @@ 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); Modified: freeswitch/trunk/src/switch_ivr_play_say.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_play_say.c (original) +++ freeswitch/trunk/src/switch_ivr_play_say.c Tue Aug 28 13:06:20 2007 @@ -250,11 +250,7 @@ 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(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_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_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, Modified: freeswitch/trunk/src/switch_swig.c ============================================================================== --- freeswitch/trunk/src/switch_swig.c (original) +++ freeswitch/trunk/src/switch_swig.c Tue Aug 28 13:06:20 2007 @@ -260,11 +260,11 @@ 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; }
participants (1)
-
Freeswitch SVN