]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
clean up speak code
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 28 Aug 2007 17:06:20 +0000 (17:06 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 28 Aug 2007 17:06:20 +0000 (17:06 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5670 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_ivr.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/applications/mod_ivrtest/mod_ivrtest.c
src/switch_cpp.cpp
src/switch_ivr_menu.c
src/switch_ivr_play_say.c
src/switch_swig.c

index f45f1fa327e8cb4320e68989e4e25afeda85cad9..395ed95fbaede3454bdb4d40054fff40e138de9e 100644 (file)
@@ -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
index 1a8446d97203a0ddf59697b40f9fef90831a21e4..3a452efb2988ec46e95a617f85dd35e941b36a2b 100644 (file)
@@ -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;
                }
index 31101daae1117339e7de0a430469796feb21ad24..70113991e69ddc745b4deb88b3eafa5d4c396e9f 100644 (file)
@@ -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);
 
 }
 
index 128d9cc01875e69191b24fae53ee38a9db82d50a..16ff53cd43407e48b24f39d9a221f2496dd50fd0 100644 (file)
@@ -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);
        }
 
 }
index a83f0c9ec994058fa089293856b7bba7cbf92d24..daad48d9036b44738d7940a9a1e523bd9e992b23 100644 (file)
@@ -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;
 }
index 28f69c016cdc2d2b3cddf24aeb8a1664b1b257f0..d4714c0eb024c00e4f2fc2d8dabcef513ea0f9fe 100644 (file)
@@ -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);
index 9f320bb4ada0b55796384679c189542fe7a993df..96dd1b276beac0b713caead57e5b1f095b0b7423 100644 (file)
@@ -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,
index de5e43b4a9ef0fe07cc0bbb11f18f1bd41ec18f6..e1e0cb9ad02e64d5177538e9d4e8809e5de7db72 100644 (file)
@@ -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;
 }