]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add speak application
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 9 Jun 2006 15:15:58 +0000 (15:15 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 9 Jun 2006 15:15:58 +0000 (15:15 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1583 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_playback/mod_playback.c
src/mod/asr_tts/mod_cepstral/mod_cepstral.c
src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c

index a7b10376a3f06c89301cce72212b1a78588a47ff..78898bff972bdf5d2c0ab36d1d0ec4c35ed6c5fc 100644 (file)
@@ -49,6 +49,43 @@ static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void
 }
 
 
+static void speak_function(switch_core_session_t *session, char *data)
+{
+       switch_channel_t *channel;
+       char buf[10];
+       char *argv[4] = {0};
+       int argc;
+       char *engine = NULL;
+       char *voice = NULL;
+       char *text = NULL;
+       char *timer_name = NULL;
+       char *mydata = NULL;
+       switch_codec_t *codec;
+
+       codec = switch_core_session_get_read_codec(session);
+       assert(codec != NULL);
+
+       channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+       mydata = switch_core_session_strdup(session, data);
+       argc = switch_separate_string(mydata, '|', argv, sizeof(argv)/sizeof(argv[0]));
+
+       engine = argv[0];
+       voice = argv[1];
+       text = argv[2];
+       timer_name = argv[3];
+       
+       if (!(engine && voice && text)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
+               switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+       }
+
+       switch_channel_answer(channel);
+       switch_ivr_speak_text(session, engine, voice, timer_name, codec->implementation->samples_per_second, on_dtmf, text, buf, sizeof(buf));
+       
+}
+
 static void playback_function(switch_core_session_t *session, char *data)
 {
        switch_channel_t *channel;
@@ -85,9 +122,17 @@ static void record_function(switch_core_session_t *session, char *data)
        
 }
 
+
+static const switch_application_interface_t speak_application_interface = {
+       /*.interface_name */ "speak",
+       /*.application_function */ speak_function
+};
+
 static const switch_application_interface_t record_application_interface = {
        /*.interface_name */ "record",
-       /*.application_function */ record_function
+       /*.application_function */ record_function,
+       NULL,NULL,NULL,
+       &speak_application_interface
 };
 
 static const switch_application_interface_t playback_application_interface = {
index 5698cb7f0e69ae9cfa40cb8d5dc4530076443911..0963c8d72b02d71cf19641de847f183f33f2c7e3 100644 (file)
@@ -195,6 +195,8 @@ static switch_status_t cepstral_speech_close(switch_speech_handle_t *sh, switch_
 static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
 {
        cepstral_t *cepstral;
+       const char *fp = "file:";
+       int len = strlen(fp);
 
        assert(sh != NULL);
        cepstral = sh->private_info;
@@ -204,8 +206,13 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
        cepstral->done = 0;
 
        cepstral->tts_stream = NULL;
-
-       swift_port_speak_text(cepstral->port, text, 0, NULL, &cepstral->tts_stream, NULL); 
+       
+       if (!strncasecmp(text, fp, len)) {
+               text += len;
+               swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL); 
+       } else {
+               swift_port_speak_text(cepstral->port, text, 0, NULL, &cepstral->tts_stream, NULL); 
+       }
 
        return SWITCH_STATUS_FALSE;
 }
index 6ed3b8f69eadfeac3dc3be40093ed53d2cda478d..4cc922bcc37e6ed8c54f1caa59d5a05c3f0443d5 100644 (file)
@@ -236,8 +236,6 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
 
                proceed = parse_exten(session, xexten, &extension);
 
-               //printf("ASS %s %d\n", (char *) switch_xml_attr_soft(xexten, "name"), proceed);
-
                if (proceed && !switch_true(cont)) {
                        break;
                }