[Freeswitch-svn] [commit] r1573 - in freeswitch/trunk/src: . include mod/applications/mod_rss mod/asr_tts/mod_cepstral mod/endpoints/mod_wanpipe
anthm at freeswitch.org
anthm at freeswitch.org
Thu Jun 8 15:22:55 EDT 2006
Author: anthm
Date: Thu Jun 8 15:22:54 2006
New Revision: 1573
Removed:
freeswitch/trunk/src/mod/applications/mod_rss/
Modified:
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_ivr.c
Log:
ivr stuff (part 1)
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Thu Jun 8 15:22:54 2006
@@ -918,6 +918,14 @@
SWITCH_DECLARE(void) switch_core_speech_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val);
/*!
+ \brief Set a float parameter on a TTS handle
+ \param sh the speech handle
+ \param param the parameter
+ \param val the value
+*/
+SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val);
+
+/*!
\brief Read rendered audio from the TTS module
\param sh the speech handle to read
\param data the buffer to read to
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Thu Jun 8 15:22:54 2006
@@ -330,6 +330,7 @@
void (*speech_flush_tts)(switch_speech_handle_t *sh);
void (*speech_text_param_tts)(switch_speech_handle_t *sh, char *param, char *val);
void (*speech_numeric_param_tts)(switch_speech_handle_t *sh, char *param, int val);
+ void (*speech_float_param_tts)(switch_speech_handle_t *sh, char *param, double val);
const struct switch_speech_interface *next;
};
@@ -345,6 +346,9 @@
char *name;
/*! The Rate*/
uint32_t rate;
+ uint32_t speed;
+ char voice[80];
+ char engine[80];
/*! the handle's memory pool */
switch_memory_pool_t *memory_pool;
/*! private data for the format module to store handle specific info */
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Thu Jun 8 15:22:54 2006
@@ -424,6 +424,7 @@
SWITCH_SPEECH_FLAG_PEEK = (1 << 3) - Read data but do not erase it.
SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 4) - Free interface's pool on destruction.
SWITCH_SPEECH_FLAG_BLOCKING = (1 << 5) - Indicate that a blocking call is desired
+SWITCH_SPEECH_FLAG_PAUSE = (1 << 6) - Pause toggle for playback
</pre>
*/
typedef enum {
@@ -433,6 +434,7 @@
SWITCH_SPEECH_FLAG_PEEK = (1 << 3),
SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 4),
SWITCH_SPEECH_FLAG_BLOCKING = (1 << 5),
+ SWITCH_SPEECH_FLAG_PAUSE = (1 << 6)
} switch_speech_flag_t;
Modified: freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c Thu Jun 8 15:22:54 2006
@@ -36,7 +36,7 @@
#include <swift.h>
#include <switch.h>
-#define MY_BUF_LEN 1024 * 512
+#define MY_BUF_LEN 1024 * 256
static const char modname[] = "mod_cepstral";
@@ -152,8 +152,14 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
goto all_done;
}
+
+ voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
}
+ if (voice_name) {
+ switch_copy_string(sh->voice, voice_name, sizeof(sh->voice));
+ }
+
swift_port_set_callback(cepstral->port, &write_audio, SWIFT_EVENT_AUDIO, cepstral);
sh->private_info = cepstral;
@@ -175,7 +181,6 @@
cepstral->done = 1;
cepstral->done_gen = 1;
- printf("CLOSE!!!\n");
swift_port_stop(cepstral->port, SWIFT_ASYNC_ANY, SWIFT_EVENT_NOW);
/* Close the Swift Port and Engine */
if (NULL != cepstral->port) swift_port_close(cepstral->port);
@@ -294,6 +299,83 @@
return status;
}
+static void cepstral_text_param_tts(switch_speech_handle_t *sh, char *param, char *val)
+{
+ cepstral_t *cepstral;
+
+ cepstral = sh->private_info;
+ assert(cepstral != NULL);
+
+ if (!strcasecmp(param, "voice")) {
+ char *voice_name = val;
+ if (!strcasecmp(voice_name, "next")) {
+ if ((cepstral->voice = swift_port_find_next_voice(cepstral->port))) {
+ if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
+ cepstral->done = cepstral->done_gen = 1;
+ return;
+ }
+ voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
+ } else {
+ voice_name = NULL;
+ }
+ } else {
+ if (voice_name && SWIFT_FAILED(swift_port_set_voice_by_name(cepstral->port, voice_name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid voice %s!\n", voice_name);
+ voice_name = NULL;
+ }
+ }
+
+ if (!voice_name) {
+ /* Find the first voice on the system */
+ if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
+ cepstral->done = cepstral->done_gen = 1;
+ return;
+ }
+
+ /* Set the voice found by find_first_voice() as the port's current voice */
+ if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
+ cepstral->done = cepstral->done_gen = 1;
+ return;
+ }
+
+ voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
+ }
+
+ if (voice_name) {
+ switch_copy_string(sh->voice, voice_name, sizeof(sh->voice));
+ }
+
+ return;
+ }
+
+ swift_port_set_param_string(cepstral->port, param, val, NULL);
+}
+
+static void cepstral_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val)
+{
+ cepstral_t *cepstral;
+
+ cepstral = sh->private_info;
+ assert(cepstral != NULL);
+
+ swift_port_set_param_int(cepstral->port, param, val, NULL);
+
+}
+
+
+static void cepstral_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
+{
+ cepstral_t *cepstral;
+
+ cepstral = sh->private_info;
+ assert(cepstral != NULL);
+
+ swift_port_set_param_float(cepstral->port, param, val, NULL);
+
+}
+
static const switch_speech_interface_t cepstral_speech_interface = {
/*.interface_name*/ "cepstral",
/*.speech_open*/ cepstral_speech_open,
@@ -302,7 +384,10 @@
/*.speech_interpret_asr*/ NULL,
/*.speech_feed_tts*/ cepstral_speech_feed_tts,
/*.speech_read_tts*/ cepstral_speech_read_tts,
- /*.speech_flush_tts*/ cepstral_speech_flush_tts
+ /*.speech_flush_tts*/ cepstral_speech_flush_tts,
+ /*.speech_text_param_tts*/ cepstral_text_param_tts,
+ /*.speech_numeric_param_tts*/ cepstral_numeric_param_tts,
+ /*.speech_numeric_param_tts*/ cepstral_float_param_tts
};
static const switch_loadable_module_interface_t cepstral_module_interface = {
Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c Thu Jun 8 15:22:54 2006
@@ -566,8 +566,8 @@
while (bytes > 0) {
unsigned int towrite;
-#if 0
- if (sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP) <= 0) {
+#if 1
+ if (sangoma_socket_waitfor(tech_pvt->socket, 1000, POLLOUT | POLLERR | POLLHUP) <= 0) {
return SWITCH_STATUS_GENERR;
}
#endif
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Thu Jun 8 15:22:54 2006
@@ -578,6 +578,7 @@
return SWITCH_STATUS_GENERR;
}
+ switch_copy_string(sh->engine, module_name, sizeof(sh->engine));
sh->flags = *flags;
if (pool) {
sh->memory_pool = pool;
@@ -640,6 +641,15 @@
}
}
+SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
+{
+ assert(sh != NULL);
+
+ if (sh->speech_interface->speech_float_param_tts) {
+ sh->speech_interface->speech_float_param_tts(sh, param, val);
+ }
+}
+
SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh,
void *data,
switch_size_t *datalen,
@@ -736,15 +746,13 @@
while (data->running > 0) {
switch (switch_core_session_read_frame(session, &read_frame, -1, stream_id)) {
case SWITCH_STATUS_SUCCESS:
- break;
case SWITCH_STATUS_TIMEOUT:
+ case SWITCH_STATUS_BREAK:
break;
default:
data->running = -1;
continue;
}
-
- switch_yield(10000);
}
data->running = 0;
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Thu Jun 8 15:22:54 2006
@@ -554,6 +554,52 @@
ilen = len;
while(switch_channel_ready(channel)) {
+
+ if (dtmf_callback || buf) {
+ /*
+ dtmf handler function you can hook up to be executed when a digit is dialed during playback
+ if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
+ */
+ if (switch_channel_has_dtmf(channel)) {
+ if (buf && !strcasecmp(buf, "_break_")) {
+ status = SWITCH_STATUS_BREAK;
+ } else {
+ switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
+ if (dtmf_callback) {
+ status = dtmf_callback(session, dtmf, buf, buflen);
+ } else {
+ switch_copy_string((char *)buf, dtmf, buflen);
+ status = SWITCH_STATUS_BREAK;
+ }
+ }
+ }
+
+ if (status != SWITCH_STATUS_SUCCESS) {
+ done = 1;
+ break;
+ }
+ }
+
+ if (switch_test_flag(sh, SWITCH_SPEECH_FLAG_PAUSE)) {
+ if (timer) {
+ if ((x = switch_core_timer_next(timer)) < 0) {
+ break;
+ }
+ } else {
+ switch_frame_t *read_frame;
+ switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+
+ while (switch_channel_test_flag(channel, CF_HOLD)) {
+ switch_yield(10000);
+ }
+
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ break;
+ }
+ }
+ continue;
+ }
+
flags = SWITCH_SPEECH_FLAG_BLOCKING;
status = switch_core_speech_read_tts(sh,
abuf,
@@ -596,27 +642,6 @@
}
}
- if (dtmf_callback || buf) {
- /*
- dtmf handler function you can hook up to be executed when a digit is dialed during playback
- if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
- */
- if (switch_channel_has_dtmf(channel)) {
- switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
- if (dtmf_callback) {
- status = dtmf_callback(session, dtmf, buf, buflen);
- } else {
- switch_copy_string((char *)buf, dtmf, buflen);
- status = SWITCH_STATUS_BREAK;
- }
- }
-
- if (status != SWITCH_STATUS_SUCCESS) {
- done = 1;
- break;
- }
- }
-
if (timer) {
if ((x = switch_core_timer_next(timer)) < 0) {
break;
More information about the Freeswitch-svn
mailing list