Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix Multiple Grammars #99

merged 1 commit into from Mar 27, 2013


None yet
2 participants

englercj commented Mar 27, 2013

I made an incorrect assumption with the way multiple grammar loading in FreeSWITCH worked, so the last patch was doing it incorrectly.

From mod_unimrcp.c lines 3085-3097, inside recog_asr_load_grammar():

    start_recognize = (char *) switch_core_hash_find(schannel->params, "start-recognize");
    if (zstr(start_recognize) || strcasecmp(start_recognize, "false"))
        if (recog_channel_disable_all_grammars(schannel) != SWITCH_STATUS_SUCCESS) {
            status = SWITCH_STATUS_FALSE;
            goto done;
        if (recog_channel_enable_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) {
            status = SWITCH_STATUS_FALSE;
            goto done;
        status = recog_channel_start(schannel);

As you can see unless start-recognize is set to false in your unimrcp profile (under <recogparams/>) FreeSWITCH will disable all grammars whenever you load one. Which means recognition will only work for the last grammar you load. Also, you need to initialize speech detection with a detect_speech call before loading other grammars. You should have in your profile something like:

        <param name="start-recognize" value="false" />

This patch makes sure to initialize detection first, then load grammars second, then finally after all are loaded running a detect_speech resume to start using them all. However multiple grammars will only work if start-recognize is set to false as mentioned above.

This seems to be working well for me to load multiple grammars, including DTMF grammars with LumenVox; and I am getting speech results properly for any matches to the grammars.

@tamiel tamiel added a commit that referenced this pull request Mar 27, 2013

@tamiel tamiel Merge pull request #99 from englercj/master
Fix Multiple Grammars

@tamiel tamiel merged commit ef2aefb into plivo:master Mar 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment