Revision
16717
Author
crienzo
Date
2010-02-22 08:26:16 -0600 (Mon, 22 Feb 2010)

Log Message

Added synthparams and recogparams to config so that default MRCP params can be defined for SPEAK and RECOGNIZE requests.

Modified Paths

Diff

Modified: freeswitch/trunk/conf/mrcp_profiles/loquendo-7-mrcp-v2.xml (16716 => 16717)


--- freeswitch/trunk/conf/mrcp_profiles/loquendo-7-mrcp-v2.xml	2010-02-22 07:38:54 UTC (rev 16716)
+++ freeswitch/trunk/conf/mrcp_profiles/loquendo-7-mrcp-v2.xml	2010-02-22 14:26:16 UTC (rev 16717)
@@ -19,5 +19,14 @@
     <!--param name="ptime" value="20"/-->
     <param name="codecs" value="PCMU PCMA L16/96/8000"/>
     <param name="jsgf-mime-type" value="application/jsgf"/>
+
+    <!-- Add any default MRCP params for SPEAK requests here -->
+    <synthparams>
+    </synthparams>
+
+    <!-- Add any default MRCP params for RECOGNIZE requests here -->
+    <recogparams>
+      <!--param name="start-input-timers" value="false"/-->
+    </recogparams>
   </profile>
 </include>

Modified: freeswitch/trunk/conf/mrcp_profiles/nuance-1.0.0-mrcp-v1.xml (16716 => 16717)


--- freeswitch/trunk/conf/mrcp_profiles/nuance-1.0.0-mrcp-v1.xml	2010-02-22 07:38:54 UTC (rev 16716)
+++ freeswitch/trunk/conf/mrcp_profiles/nuance-1.0.0-mrcp-v1.xml	2010-02-22 14:26:16 UTC (rev 16717)
@@ -26,5 +26,14 @@
     <!--param name="max-playout-delay" value="200"/-->
     <!--param name="ptime" value="20"/-->
     <param name="codecs" value="PCMU PCMA L16/96/8000"/>
+
+    <!-- Add any default MRCP params for SPEAK requests here -->
+    <synthparams>
+    </synthparams>
+
+    <!-- Add any default MRCP params for RECOGNIZE requests here -->
+    <recogparams>
+      <!--param name="start-input-timers" value="false"/-->
+    </recogparams>
   </profile>
 </include>

Modified: freeswitch/trunk/conf/mrcp_profiles/nuance-5.0-mrcp-v1.xml (16716 => 16717)


--- freeswitch/trunk/conf/mrcp_profiles/nuance-5.0-mrcp-v1.xml	2010-02-22 07:38:54 UTC (rev 16716)
+++ freeswitch/trunk/conf/mrcp_profiles/nuance-5.0-mrcp-v1.xml	2010-02-22 14:26:16 UTC (rev 16717)
@@ -26,5 +26,14 @@
     <!--param name="max-playout-delay" value="200"/-->
     <!--param name="ptime" value="20"/-->
     <param name="codecs" value="PCMU PCMA L16/96/8000"/>
+
+    <!-- Add any default MRCP params for SPEAK requests here -->
+    <synthparams>
+    </synthparams>
+
+    <!-- Add any default MRCP params for RECOGNIZE requests here -->
+    <recogparams>
+      <!--param name="start-input-timers" value="false"/-->
+    </recogparams>
   </profile>
 </include>

Modified: freeswitch/trunk/conf/mrcp_profiles/nuance-5.0-mrcp-v2.xml (16716 => 16717)


--- freeswitch/trunk/conf/mrcp_profiles/nuance-5.0-mrcp-v2.xml	2010-02-22 07:38:54 UTC (rev 16716)
+++ freeswitch/trunk/conf/mrcp_profiles/nuance-5.0-mrcp-v2.xml	2010-02-22 14:26:16 UTC (rev 16717)
@@ -30,5 +30,14 @@
     <!--param name="max-playout-delay" value="200"/-->
     <!--param name="ptime" value="20"/-->
     <param name="codecs" value="PCMU PCMA L16/96/8000"/>
+
+    <!-- Add any default MRCP params for SPEAK requests here -->
+    <synthparams>
+    </synthparams>
+
+    <!-- Add any default MRCP params for RECOGNIZE requests here -->
+    <recogparams>
+      <!--param name="start-input-timers" value="false"/-->
+    </recogparams>
   </profile>
 </include>

Modified: freeswitch/trunk/conf/mrcp_profiles/unimrcpserver-mrcp-v1.xml (16716 => 16717)


--- freeswitch/trunk/conf/mrcp_profiles/unimrcpserver-mrcp-v1.xml	2010-02-22 07:38:54 UTC (rev 16716)
+++ freeswitch/trunk/conf/mrcp_profiles/unimrcpserver-mrcp-v1.xml	2010-02-22 14:26:16 UTC (rev 16717)
@@ -14,5 +14,14 @@
     <!--param name="max-playout-delay" value="200"/-->
     <!--param name="ptime" value="20"/-->
     <param name="codecs" value="PCMU PCMA L16/96/8000"/>
+
+    <!-- Add any default MRCP params for SPEAK requests here -->
+    <synthparams>
+    </synthparams>
+
+    <!-- Add any default MRCP params for RECOGNIZE requests here -->
+    <recogparams>
+      <!--param name="start-input-timers" value="false"/-->
+    </recogparams>
   </profile>
 </include>

Modified: freeswitch/trunk/conf/mrcp_profiles/voxeo-prophecy-8.0-mrcp-v1.xml (16716 => 16717)


--- freeswitch/trunk/conf/mrcp_profiles/voxeo-prophecy-8.0-mrcp-v1.xml	2010-02-22 07:38:54 UTC (rev 16716)
+++ freeswitch/trunk/conf/mrcp_profiles/voxeo-prophecy-8.0-mrcp-v1.xml	2010-02-22 14:26:16 UTC (rev 16717)
@@ -14,5 +14,14 @@
     <!--param name="max-playout-delay" value="200"/-->
     <!--param name="ptime" value="20"/-->
     <param name="codecs" value="PCMU PCMA L16/96/8000"/>
+
+    <!-- Add any default MRCP params for SPEAK requests here -->
+    <synthparams>
+    </synthparams>
+
+    <!-- Add any default MRCP params for RECOGNIZE requests here -->
+    <recogparams>
+      <!--param name="start-input-timers" value="false"/-->
+    </recogparams>
   </profile>
 </include>

Modified: freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c (16716 => 16717)


--- freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c	2010-02-22 07:38:54 UTC (rev 16716)
+++ freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c	2010-02-22 14:26:16 UTC (rev 16717)
@@ -136,6 +136,10 @@
 	const char *srgs_xml_mime_type;
 	/** MIME type to use for SRGS ABNF grammars */
 	const char *srgs_mime_type;
+	/** Default params to use for RECOGNIZE requests */
+	switch_hash_t *default_recog_params;
+	/** Default params to use for SPEAK requests */
+	switch_hash_t *default_synth_params;
 };
 typedef struct profile profile_t;
 static switch_status_t profile_create(profile_t ** profile, const char *name, switch_memory_pool_t *pool);
@@ -501,6 +505,8 @@
 		lprofile->srgs_xml_mime_type = "application/srgs+xml";
 		lprofile->gsl_mime_type = "application/x-nuance-gsl";
 		lprofile->jsgf_mime_type = "application/x-jsgf";
+		switch_core_hash_init(&lprofile->default_synth_params, pool);
+		switch_core_hash_init(&lprofile->default_recog_params, pool);
 		*profile = lprofile;
 
 		if (globals.enable_profile_events && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_PROFILE_CREATE) == SWITCH_STATUS_SUCCESS) {
@@ -1498,6 +1504,7 @@
 	profile_t *profile = NULL;
 	int speech_channel_number = get_next_speech_channel_number();
 	char name[200] = { 0 };
+	switch_hash_index_t *hi = NULL;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
 					  "speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n", sh->name, sh->rate,
@@ -1534,6 +1541,17 @@
 		speech_channel_set_param(schannel, "Voice-Name", voice_name);
 	}
 
+	/* Set default TTS params */
+	for (hi = switch_hash_first(NULL, profile->default_synth_params); hi; hi = switch_hash_next(hi)) {
+		char *param_name = NULL, *param_val = NULL;
+		const void *key;
+		void *val;
+		switch_hash_this(hi, &key, NULL, &val);
+		param_name = (char *) key;
+		param_val = (char *) val;
+		speech_channel_set_param(schannel, param_name, param_val);
+	}
+
   done:
 
 	return status;
@@ -2679,6 +2697,7 @@
 	const char *profile_name = NULL;
 	profile_t *profile = NULL;
 	recognizer_data_t *r = NULL;
+	switch_hash_index_t *hi = NULL;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "asr_handle: name = %s, codec = %s, rate = %d, grammar = %s, param = %s\n",
 					  ah->name, ah->codec, ah->rate, ah->grammar, ah->param);
@@ -2714,8 +2733,22 @@
 		status = SWITCH_STATUS_FALSE;
 		goto done;
 	}
-	status = speech_channel_open(schannel, profile);
+	
+	if ((status = speech_channel_open(schannel, profile)) != SWITCH_STATUS_SUCCESS) {
+		goto done;
+	}
 
+	/* Set default ASR params */
+	for (hi = switch_hash_first(NULL, profile->default_recog_params); hi; hi = switch_hash_next(hi)) {
+		char *param_name = NULL, *param_val = NULL;
+		const void *key;
+		void *val;
+		switch_hash_this(hi, &key, NULL, &val);
+		param_name = (char *) key;
+		param_val = (char *) val;
+		speech_channel_set_param(schannel, param_name, param_val);
+	}
+
   done:
 
 	return status;
@@ -3589,6 +3622,7 @@
 			mrcp_profile_t *mprofile = NULL;
 			mpf_rtp_config_t *rtp_config = NULL;
 			profile_t *mod_profile = NULL;
+			switch_xml_t default_params = NULL; 
 
 			/* get profile attributes */
 			const char *name = apr_pstrdup(pool, switch_xml_attr(profile, "name"));
@@ -3603,6 +3637,42 @@
 			profile_create(&mod_profile, name, mod_pool);
 			switch_core_hash_insert(globals.profiles, mod_profile->name, mod_profile);
 
+			/* pull in any default SPEAK params */
+			default_params = switch_xml_child(profile, "synthparams");
+			if (default_params) {
+				switch_xml_t param = NULL;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading SPEAK params\n");
+				for (param = switch_xml_child(default_params, "param"); param; param = switch_xml_next(param)) {
+					const char *param_name = switch_xml_attr(param, "name");
+					const char *param_value = switch_xml_attr(param, "value");
+					if (zstr(param_name)) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing SPEAK param name\n");
+						client = NULL;
+						goto done;
+					}
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading SPEAK Param %s:%s\n", param_name, param_value);
+					switch_core_hash_insert(mod_profile->default_synth_params, param_name, param_value);
+				}
+			}
+
+			/* pull in any default RECOGNIZE params */
+			default_params = switch_xml_child(profile, "recogparams");
+			if (default_params) {
+				switch_xml_t param = NULL;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading RECOGNIZE params\n");
+				for (param = switch_xml_child(default_params, "param"); param; param = switch_xml_next(param)) {
+					const char *param_name = switch_xml_attr(param, "name");
+					const char *param_value = switch_xml_attr(param, "value");
+					if (zstr(param_name)) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing RECOGNIZE param name\n");
+						client = NULL;
+						goto done;
+					}
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading RECOGNIZE Param %s:%s\n", param_name, param_value);
+					switch_core_hash_insert(mod_profile->default_recog_params, param_name, param_value);
+				}
+			}
+
 			/* create RTP config, common to MRCPv1 and MRCPv2 */
 			rtp_config = mpf_rtp_config_create(pool);
 			rtp_config->rtp_port_min = DEFAULT_RTP_PORT_MIN;