zaf / asterisk-speech-recog

Speech recognition script for Asterisk that uses google's speech engine.
GNU General Public License v2.0
245 stars 131 forks source link

Update speech-recog.agi - coorect BEEP #22

Closed manufuentescr closed 7 years ago

manufuentescr commented 8 years ago

The correct definition for BEEP is : BEEP = 1 NOBEEP = -1

zaf commented 8 years ago

Hello and thank you for the patch. Unfortunately it is not working as intended. If you look at res/res_agi.c in the asterisk source and especially in the function handle_recordfile() in recent versions of asterisk you will see that the 'beep' flag is defined (not clearly stated but still defined) as a non digit argument in order not to conflict with the other optional flag which is offset.

Copying asterisk 13 res_agi.c lines 2589:2596

    /* backward compatibility, if no offset given, arg[6] would have been
     * caught below and taken to be a beep, else if it is a digit then it is a
     * offset */
    if ((argc >6) && (sscanf(argv[6], "%30ld", &sample_offset) != 1) && (!strchr(argv[6], '=')))
        res = ast_streamfile(chan, "beep", ast_channel_language(chan));

    if ((argc > 7) && (!strchr(argv[7], '=')))
        res = ast_streamfile(chan, "beep", ast_channel_language(chan));

With the proposed patch a beep sound is never played before recording starts as it is treated like an offset.