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