[Freeswitch-dev] Regarding the patch for Multiple grammar ASR support
Yungwei Chen
yungwei at resolvity.com
Tue Jul 19 01:39:24 MSD 2011
Hi,
I am interested in taking advantages of the patch (http://jira.freeswitch.org/browse/FS-2906) for Multiple grammar ASR support from a javascript program.
But I am not sure exactly when to call the following function from a javascript program:
...
this.addMultipleGrammars = function () {
// hardcoded urls are just for my initial tests.
this.session.execute("detect_speech", "grammar " + "http://192.168.16.9/pizza_arso.grxml");
this.session.execute("detect_speech", "grammaron " + "http://192.168.16.9/pizza_arso.grxml");
}
...
I tried the following in scripts/js_modules/SpeechTools.jm, but this didn't work because the code snippet at the bottom prevented me from having multiple active grammars.
.....
while(this.asr.session.ready() && this.collected_index < this.req) {
var x;
this.needConfirm = false;
if (!rv) {
this.asr.addMultipleGrammars();
rv = this.react(this.top_sound, this.top_sound);
}
...
I had to comment out the following piece of code in recog_asr_load_grammar function of /opt/freeswitch-snapshot/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c to get my expected results.
This fix may not be needed. Perhaps you can point me to the right direction. Thanks.
...
start_recognize = (char *) switch_core_hash_find(schannel->params, "start-recognize");
if (zstr(start_recognize) || strcasecmp(start_recognize, "false"))
{
// this disables all grammars
/* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "calling recog_channel_disable_all_grammars()\n");
if (recog_channel_disable_all_grammars(schannel) != SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_FALSE;
goto done;
}
*/
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "calling recog_channel_enable_grammar()\n");
if (recog_channel_enable_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_FALSE;
goto done;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "calling recog_channel_start()\n");
status = recog_channel_start(schannel);
}
More information about the FreeSWITCH-dev
mailing list