[asterisk-speech-rec] PHPAGI
Steven Mathers
Steven.Mathers at prosodieCRM.com
Wed Jan 2 09:17:01 CST 2008
Hi Nitesh,
Ive got this set up threw PHPAGI
Sample code:
#!/usr/bin/php
<?php
/* Speech app that takes input and speaks the number you say */
function mylog($str){
global $LOGFILE, $UID;
$fp = fopen($LOGFILE,"a");
fputs($fp,date("M:j:Y")."-".date("H:i:s")."-UID=".$UID."-".$str."\n");
fclose($fp);
}
require('/var/lib/asterisk/agi-bin/phpagi-2.14/phpagi.php');
$LOGFILE="/var/log/asterisk/call_log";
$agi = new AGI();
$UID=$agi->request[agi_uniqueid];
$ANI=$agi->request[agi_callerid];
$DNIS=$agi->request[agi_dnid];
$CHANNEL=$agi->request[agi_channel];
$channelnum = substr_replace((ltrim($CHANNEL, 'Zap /')),'',-2);
$rownum = 1979+$channelnum;
//$agi->exec('Playback','hello-world', 'noanwser');
$agi->stream_file('hello-world');
$code=$agi->exec("SpeechCreate");
$code=$agi->exec("SpeechActivateGrammar","ABNFNumber");
$code=$agi->exec("SpeechStart");
//If($code<0) do something?
$agi->exec("SpeechBackground","vm-msginstruct",5);
$res=$agi->get_variable("SPEECH_TEXT(0)");
$data=$res['data'];
mylog("SR result=".$data);
//append the speech results to the CDR so the logger will include it in
the caller mysql entry
$datalog='SpeechResults:'.$data;
$agi->exec('Set','CDR(userfield)='.$datalog);
//destroy speech object
$agi->exec("SpeechDeactivateGrammar","ABNFNumber");
$agi->exec('SpeechDestroy');
$agi->exec('SayNumber',$data,'f');
?>
This will work with Lumenvox connector installed. Basically all this
does is accept a number and say the Speech result back at the person.
Cheers.
-----Original Message-----
From: asterisk-speech-rec-bounces at lists.digium.com
[mailto:asterisk-speech-rec-bounces at lists.digium.com] On Behalf Of
Stephen Keller
Sent: Thursday, December 27, 2007 6:34 PM
To: Use of speech recognition in Asterisk
Subject: Re: [asterisk-speech-rec] PHPAGI
> Now is there anyway to integrate LumenVox speech recognition
> app with PHPAGI?
Hi Nitesh,
In short the answer to this question is yes. When you use LumenVox
speech recognition on Asterisk, you will just make use of the standard
Asterisk speech applications exported by res_speech.so.
All the documentation for these applications is at
http://www.asterisk.org/doxygen/1.4/AstSpeech.html
> Now how can I use speech to capture the input and store it in
> $pin_no variable?
I am no expert at PHP or the AGI, but basically all you will need to do
is use AGI to execute the SpeechBackground() function and then from your
application read in the value of the Asterisk $SPEECH_TEXT(0) variable.
Perhaps somebody more familiar with PHP and AGI can give you a code
snippet of how this is done in PHP.
If you know Java, you can see some sample Java applications that do this
via the AGI at
http://www.lumenvox.com/partners/digium/applicationzone/index.aspx
I have a video series at LumenVox.com that will really walk you through
the basics of speech recognition on Asterisk that begins at
http://www.lumenvox.com/support/videos/asteriskSpeechRec101/vid01_summar
y.aspx
That assumes you are using dialplan, but the core logic should be the
same regardless of how you implement it.
Thanks,
Stephen Keller
Technical Support
LumenVox
P: 1-877-977-0707 - just say, "Support"
P: +1-858-707-7700
F: +1-858-707-7072
support at LumenVox.com
www.LumenVox.com
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
asterisk-speech-rec mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-speech-rec
More information about the asterisk-speech-rec
mailing list