[asterisk-users] How to make SpeechBackground keepplayingifutterance doesn't match our grammar
Steve Murphy
murf at parsetree.com
Tue Jan 26 00:52:34 CST 2010
Quinn--
I would venture to guess that your problem is because you are using the
sound file streaming
mechanism at too high a level. At the app/agi level, you don't get any
control over the process.
You start the sound process, then you wait for the interrupt; it's all
neatly bundled into a single
package.
At the C level, using the machinery that Asterisk uses, you use these calls:
res = ast_streamfile(chan, "Filename", chan->language);
if (res2) { failure_code(); }
else {
ast_autoservice_start(chan); /* keep those packets running out to chan
*/
}
/* put code here to process the stuff from voice recognition s/w until you
get what
you want, or time out, or whatever */
if (!res2) {
ast_stopstream(chan);
ast_autoservice_stop(chan);
}
The code above pretty much supposes that the file will play longer than it
will take to get some outcome
from the VR stuff; but no matter, if it runs clear to the end, it will just
leave you with a dead channel.
Best to set some sort of timeout so as not to sit forever if the person at
the other end of "chan" is mute
or dies or something. The main thing to remem is that autoservice_start()
and streamfile() immediately
return, and do not block, and the shuffling of sound packets is handled in a
different thread. Some other
event or timeout or something needs to eat up time between the starting of
the playback and the stopping
of the playback.
Hope this helps, probably not what you were hoping for.
murf
On Mon, Jan 25, 2010 at 4:33 PM, Quinn Weaver <quinn at fairpath.com> wrote:
> On Mon, Jan 25, 2010 at 2:56 PM, Danny Nicholas <danny at debsinc.com> wrote:
> > Since you're "Perling" it, why not just put the $sb_retval in a while
> loop
> > like this:
> >
> > - my $response_good=0;
> > - my $sb_retval=undef;
> > - while (! $response_good) {
> > - my $tmp_retval = $c->agi->exec('SpeechBackground', $path);
> > - if ($tmp_retval eq 'play_next') {
> > $sb_retval=$tmp_retval;
> > $response_good=1;
> > }
> > ...
> > }
>
> If we did that, we'd be replaying $path from the beginning every time
> the user said something that didn't match the grammar. For a podcast
> episode like a radio show, that's bad—you don't want to be 30 seconds
> or two minutes into the content and have to start over.
>
> Also, as I said, it's always matching one of the rules in our
> grammar--even if I literally say "goobledegook." So it's unclear how
> we'd implement $response_good.
>
> --
> Quinn Weaver Consulting, LLC
> Full-stack web design and development
> http://quinnweaver.com/
> 510-520-5217
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
>
--
Steve Murphy
ParseTree Corp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100125/44d098a1/attachment.htm
More information about the asterisk-users
mailing list