[Freeswitch-svn] [commit] r4293 - in freeswitch/trunk/src: . include

Freeswitch SVN mmurdock at freeswitch.org
Thu Feb 15 16:59:59 EST 2007


Author: mmurdock
Date: Thu Feb 15 16:59:59 2007
New Revision: 4293

Modified:
   freeswitch/trunk/src/include/switch_ivr.h
   freeswitch/trunk/src/switch_ivr.c

Log:
Add Phrase Macro support to ivr menu.

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Thu Feb 15 16:59:59 2007
@@ -511,6 +511,7 @@
 	SWITCH_IVR_ACTION_EXECAPP,	/* Execute an application.         */
 	SWITCH_IVR_ACTION_PLAYSOUND,	/* Play a sound.                   */
 	SWITCH_IVR_ACTION_SAYTEXT,	/* say text.                       */
+	SWITCH_IVR_ACTION_SAYPHRASE,	/* say a phrase macro.                       */
 	SWITCH_IVR_ACTION_BACK,		/* Go back 1 menu.                 */
 	SWITCH_IVR_ACTION_TOMAIN,	/* Go back to the top level menu.  */
 	SWITCH_IVR_ACTION_TRANSFER,	/* Transfer caller to another ext. */
@@ -547,6 +548,7 @@
 													 const char *invalid_sound, 
 													 const char *tts_engine,
 													 const char *tts_voice,
+													 const char *phrase_lang,
 													 int timeout,
 													 int max_failures, 
 													 switch_memory_pool_t *pool);

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Thu Feb 15 16:59:59 2007
@@ -3971,6 +3971,7 @@
 	char *exit_sound;
 	char *tts_engine;
 	char *tts_voice;
+	char *phrase_lang;
 	char *buf;
 	char *ptr;
 	int max_failures;
@@ -4022,6 +4023,7 @@
 													 const char *exit_sound,
 													 const char *tts_engine,
 													 const char *tts_voice,
+													 const char *phrase_lang,
 													 int timeout,
 													 int max_failures, 
 													 switch_memory_pool_t *pool)
@@ -4075,6 +4077,10 @@
 		menu->tts_voice = switch_core_strdup(menu->pool, tts_voice);
 	}
 
+	if (!switch_strlen_zero(phrase_lang)) {
+		menu->phrase_lang = switch_core_strdup(menu->pool, phrase_lang);
+	}
+
 	menu->max_failures = max_failures;
 
 	menu->timeout = timeout;
@@ -4185,11 +4191,18 @@
 		if (*sound == '/' || *sound == '\\') {
 			status = switch_ivr_play_file(session, NULL, sound, &args);
 		} else {
-			if (menu->tts_engine && menu->tts_voice) {
-				status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, sound, &args);
-			}
-			else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine to play sound\n");
+			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);
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine to play sound\n");
+				}
+			} else {
+				if (strlen(sound) > 7 && strncmp(sound, "phrase:", 7) == 0) {
+						status = switch_ivr_phrase_macro(session, sound+7, "", menu->phrase_lang, &args);
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "play_or_say: no player for [%s]. Use say: or phrase:\n", sound);
+				}
 			}
 		}
 
@@ -4286,6 +4299,9 @@
 					case SWITCH_IVR_ACTION_SAYTEXT:
 						status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, aptr, NULL);
 						break;
+					case SWITCH_IVR_ACTION_SAYPHRASE:
+						status = switch_ivr_phrase_macro(session, aptr, "", menu->phrase_lang, NULL);
+						break;
 					case SWITCH_IVR_ACTION_TRANSFER:
 						switch_ivr_session_transfer(session, aptr, NULL, NULL);
 						running = 0;
@@ -4469,6 +4485,7 @@
 			{"menu-exec-api",	SWITCH_IVR_ACTION_EXECAPP},
 			{"menu-play-sound",	SWITCH_IVR_ACTION_PLAYSOUND},
 			{"menu-say-text",	SWITCH_IVR_ACTION_SAYTEXT},
+			{"menu-say-phrase",	SWITCH_IVR_ACTION_SAYPHRASE},
 			{"menu-back",		SWITCH_IVR_ACTION_BACK},
 			{"menu-top",		SWITCH_IVR_ACTION_TOMAIN},
 			{"menu-call-transfer",	SWITCH_IVR_ACTION_TRANSFER},
@@ -4505,6 +4522,7 @@
 		const char *exit_sound	= switch_xml_attr(xml_menu,"exit-sound");		// if the attr doesn't exist, return NULL
 		const char *tts_engine	= switch_xml_attr(xml_menu,"tts-engine");		// if the attr doesn't exist, return NULL
 		const char *tts_voice		= switch_xml_attr(xml_menu,"tts-voice");		// if the attr doesn't exist, return NULL
+		const char *phrase_lang		= switch_xml_attr(xml_menu,"phrase_lang");		// if the attr doesn't exist, return NULL
 		const char *timeout		= switch_xml_attr_soft(xml_menu,"timeout");		// if the attr doesn't exist, return ""
 		const char *max_failures	= switch_xml_attr_soft(xml_menu,"max-failures");	// if the attr doesn't exist, return ""
 		switch_ivr_menu_t *menu	= NULL;
@@ -4519,6 +4537,7 @@
 									exit_sound,
 									tts_engine,
 									tts_voice,
+									phrase_lang,
 									atoi(timeout)*1000,
 									atoi(max_failures),
 									xml_menu_ctx->pool



More information about the Freeswitch-svn mailing list