Michael...

I don't believe that PHPAGI supports this currently. What you are looking for is a combination of 2 functions: get_data() and swift().

PHPAGI code is very easy to follow so build your own function to do what you want and add it to your copy of PHPAGI.php. Ain't OSS wonderful?

I did the following... (my apologies to PHPAGI and PHP gurus for my inelegant code... but it works for me).

----snip----
  /**
   * Use Cepstral Swift to read text and get dtmf
   */
function swift_get_data($text, $frequency=8000, $voice=NULL, $addl_params='', $timeout=NULL, $max_digits=NULL)
   {
     $text = trim($text);
     if($text == '') return true;

     if(!is_null($voice))
       $voice = "-n $voice";
     elseif(isset($this->config['cepstral']['voice']))
       $voice = "-n {$this->config['cepstral']['voice']}";

     if($addl_params != '')
       $addl_params = ",$addl_params";

     // create the wave file
     $fname = $this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR;
$fname .= str_replace('.', '_', 'swift_' . $this->request['agi_uniqueid']); $p = popen("{$this->config['cepstral']['swift']} -p audio/channels=1,audio/sampling-rate=$frequency$addl_params $voice -o $fname.wav -f -", 'w');
     fputs($p, $text);
     pclose($p);

     // stream it
     $ret = $this->get_data($fname, $timeout, $max_digits);

     // destroy it
     if(file_exists($fname . '.wav'))
       unlink($fname . '.wav');

     return $ret;
   }

----/snip----

usage:

----snip----

$result = $agi->swift_get_data('To do thing 1 press 1. 'To do thing 2 press 2. 'To do thing 3 press 3. ',8000,'David','',2500,1);
 $keys = $result['result'];

 if ($keys == "1") {
  // ***** do thing 1
 } elseif ($keys == "2") {
  // ***** do thing 2
 } elseif ($keys == "3") {
  // ***** do thing 3
 }

----/snip----

Clarke Kawakami
Open Telephony Labs LLC
http://www.optellabs.com

I am trying to use swift in PHP/AGI.

function swift($text, $escape_digits='', $frequency=8000, $voice=NULL,
$fnameIn='')

During swift speaking some text I want the caller to be able to press
1, 2 or 3 to do thing 1, thing 2 or thing 3.

How are these digit defines and then caught?

Thanks,
Michael

_______________________________________________
Asterisk-Users mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to