]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix core to actually work right with tts fixing a probably long standing bug with...
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 2 Aug 2007 00:54:39 +0000 (00:54 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 2 Aug 2007 00:54:39 +0000 (00:54 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5548 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_module_interfaces.h
src/switch_ivr_play_say.c

index 2ea548e2afcfdad0a800801aab78ca8d75527740..a24125624d6aa7ffdefac3c4dbe1a5edf26b5588 100644 (file)
@@ -365,6 +365,7 @@ struct switch_speech_handle {
        /*! The Rate */
        uint32_t rate;
        uint32_t speed;
+       uint32_t samples;
        char voice[80];
        char engine[80];
        /*! the handle's memory pool */
index ffd47bb4a724acfdc519b00e76992ff60416ec25..51f2c4f9cc1cda95090e8d2f052cb0165c0dc510 100644 (file)
@@ -1156,7 +1156,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
        int lead_in_out = 10;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
        switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-       uint32_t rate = 0, samples = 0;
+       uint32_t rate = 0;
 
        channel = switch_core_session_get_channel(session);
        assert(channel != NULL);
@@ -1170,9 +1170,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
        write_frame.data = abuf;
        write_frame.buflen = sizeof(abuf);
 
-       samples = (uint32_t) (sh->rate / 50);
-       len = samples * 2;
-
+       len = sh->samples * 2;
+       
        flags = 0;
        switch_sleep(200000);
        switch_core_speech_feed_tts(sh, text, &flags);
@@ -1345,7 +1344,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
 {
        switch_channel_t *channel;
        int interval = 0;
-       uint32_t samples = 0;
        uint32_t len = 0;
        switch_frame_t write_frame = { 0 };
        switch_timer_t timer;
@@ -1366,9 +1364,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
        timer_name = switch_channel_get_variable(channel, "timer_name");
 
        switch_core_session_reset(session);
-
+       read_codec = switch_core_session_get_read_codec(session);
+       
        if (rate == 0) {
-               read_codec = switch_core_session_get_read_codec(session);
                rate = read_codec->implementation->samples_per_second;
        }
 
@@ -1382,9 +1380,9 @@ 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 = 20;
-       samples = (uint32_t) (rate / 50);
-       len = samples * 2;
+       interval = read_codec->implementation->microseconds_per_frame / 1000;
+       sh.samples = switch_bytes_per_frame(rate, interval);
+       len = sh.samples * 2;
 
        codec_name = "L16";
 
@@ -1402,7 +1400,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
        }
 
        if (timer_name) {
-               if (switch_core_timer_init(&timer, timer_name, interval, (int) samples, pool) != SWITCH_STATUS_SUCCESS) {
+               if (switch_core_timer_init(&timer, timer_name, interval, (int) sh.samples, pool) != SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
                        switch_core_codec_destroy(write_frame.codec);
                        flags = 0;