mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 20:50:41 +00:00
add speak application
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1583 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
79f8e133f1
commit
f7e6e52855
@ -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 = {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user