]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Added synthparams and recogparams to config so that default MRCP params can be define...
authorChristopher Rienzo <chris@rienzo.net>
Mon, 22 Feb 2010 14:26:16 +0000 (14:26 +0000)
committerChristopher Rienzo <chris@rienzo.net>
Mon, 22 Feb 2010 14:26:16 +0000 (14:26 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16717 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/mrcp_profiles/loquendo-7-mrcp-v2.xml
conf/mrcp_profiles/nuance-1.0.0-mrcp-v1.xml
conf/mrcp_profiles/nuance-5.0-mrcp-v1.xml
conf/mrcp_profiles/nuance-5.0-mrcp-v2.xml
conf/mrcp_profiles/unimrcpserver-mrcp-v1.xml
conf/mrcp_profiles/voxeo-prophecy-8.0-mrcp-v1.xml
src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c

index 4d6dfacbbc62e28236b8dbdc1d76bad32a564bf6..dcf42821f5bc948d0b8835f4e9410bfa387d1696 100644 (file)
     <!--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>
index fb998812c663ab01d18631bd70f5eb339127d4bc..0700dec629b5ac01abb8cacb4b8570677d3de3c9 100644 (file)
     <!--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>
index f471735a9dddf27182bb21ecae39f68e5b6ec88c..3c4938a66da53fd00eb7d2f5cd2486b29072fc65 100644 (file)
     <!--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>
index 109fa3c2c927e9f0dd3f413003124053fa1cbffc..b53cba09849ecfb3ca7d1c68ac1693129e77af76 100644 (file)
     <!--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>
index 3bfb04349445cc7933a6d43d06a2c9c09665dd7e..fe02b1582f9c01b06f157c3f69289a73aa13ac0d 100644 (file)
     <!--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>
index d49b92d1051e1fdb136a89302390316edc7b324b..fb1d0ee287c52030006600a5c1323abd93e8e218 100644 (file)
     <!--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>
index 91fd15cc8617648f615ebb4fb5167df9206e290a..b4027d8431d56ed0caa17229f2d1db4ec5e1a996 100644 (file)
@@ -136,6 +136,10 @@ struct profile {
        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 @@ static switch_status_t profile_create(profile_t ** profile, const char *name, sw
                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 @@ static switch_status_t synth_speech_open(switch_speech_handle_t *sh, const char
        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 @@ static switch_status_t synth_speech_open(switch_speech_handle_t *sh, const char
                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 @@ static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec
        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,7 +2733,21 @@ static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec
                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:
 
@@ -3589,6 +3622,7 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool)
                        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 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool)
                        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;