Re: [asterisk-users] How to make SpeechBackground keepplayingifutterance doesn't match our grammar

2010-01-25 Thread Danny Nicholas
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;
}
 ...
 }
--
 

-Original Message-
From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Quinn Weaver
Sent: Monday, January 25, 2010 4:45 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] How to make SpeechBackground
keepplayingifutterance doesn't match our grammar

On Mon, Jan 25, 2010 at 2:07 PM, Danny Nicholas da...@debsinc.com wrote:
 What does your dialplan snippet to run this look like?

It's part of a Perl FastAGI, running on a separate box from Asterisk.
The Perl code is using Asterisk::AGI's exec() method to call
SpeechBackground:

my $sb_retval = $c-agi-exec('SpeechBackground', $path);

where $path specifies a .sln file on the remote (Asterisk) host.

Here's the dialplan snippet for invoking the FastAGI.  Some notes:

- 127.0.0.1:4575 is an ssh tunnel to my box, where I'm doing the
development.  I know this works; I hear sound, DTMF works, speech
recognition occurs, et cetera.

- While my dialplan does Answer() and Hangup(), my Perl program does
it as well.  Doesn't seem to cause a problem.

- The extension name, XX was my client's  actual phone number,
so I X'ed it out.

[inbound]
exten = XX,s,Answer()
exten = XX,1,Background(demo-congrats)
exten = XX,n,Hangup()
...
exten = 3,1,Goto(quinn-tunnel-test,1,1)
exten = 3,n,Hangup()

[quinn-tunnel-test]
exten = 1,1,Answer()
exten = 1,n,AGI(agi://127.0.0.1:4575/Entry/entry?)
exten = 1,n,Hangup()

-- 
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


-- 
_
-- 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


Re: [asterisk-users] How to make SpeechBackground keepplayingifutterance doesn't match our grammar

2010-01-25 Thread Quinn Weaver
On Mon, Jan 25, 2010 at 2:56 PM, Danny Nicholas da...@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

Re: [asterisk-users] How to make SpeechBackground keepplayingifutterance doesn't match our grammar

2010-01-25 Thread Steve Murphy
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 qu...@fairpath.com wrote:

 On Mon, Jan 25, 2010 at 2:56 PM, Danny Nicholas da...@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
-- 
_
-- 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