- SEE ALSO
Ivrs - Perl extension for Interactive Voice Response System.
$iv = new Ivrs($portname,$vdir);
This module provides the complete interface to voice modem for Interactive Voice Response System (IVRS). The IVRS are widely used for telebanking, product inforamtion, tele marketing, voice mail, fax servers, and many more. All these can be implemented using this module and with very few lines of Perl code. This module takes care of all low level functions of serial port and modem.
A log file defined by the $logfile="/var/log/Ivrs_Log.ttyS*" will be opened for logging IVRS activity. Set $Babble =0 if you do not want to log all the messages (default is 1).
The demo files explains the working of various subroutines of the module.
demo1 - A simple voice interaction.
demo2 - Message recording and playback.
demo3 - Fax server.
demo4 - Dial a telephone number.
demo5 - Transfer caller line to another phone
$iv = new Ivrs('ttyS1',$vdir);
The first variable is the port name for modem / serial port (ttyS0 or ttyS1)
The second variable $vdir is voice file directory. You must specify $vdir if you want to use other than default directory ( sfiles/ ). If you are running IVRS from /etc/inittab (YES!! you can do) then absolute path for voice files is must.
The serial port parameters are set here. These parameters are carefully worked out after extensive trials. Change only if you know what are you doing or if these settings do not work on your modem.
This will put the modem in voice mode. Number of AT commands are required to set this. You may comment out the AT commands which do not start with AT# if your modem fails to respond. Some modem uses AT+ for voice commands. In that case you will have to replace all AT# with AT+.
This will put the modem in answer mode and wait for the ring. When the ring comes, call will be received on the first ring and Caller ID will be returned in $cid (not tested so far).
If you want to play a message directly (without some one calling) through Modem speaker then skip it and put $iv->atcomm("AT#VTX","CONNECT"); but then you will not be able to punch DTMF codes.
This requires a bit of explanation. From version 0.06, the use of lin file is removed and all files are raw modem data (Rockwell Modem, 7200 samples per second with compression Type 4) type only, So pvftools are no longer required to run the IVRS.
The $msgfile contains the message file to be played. You can specify the full path of the file like, /home/Ivrs-0.07/sfiles/greet or only file name (like greet) from voice file directory. If no file name is specified, it will play special file indicated by $tmpmsg. I will discuss this file in next section.
Another variable required is $dtmf, which is number of dtmf codes to be accpeted from the user while playing the file.
If $dtmf=0 then playing of file will not be stopped even if caller presses any key.
If $dtmf=1, then playing of file will be immidiately stopped if the caller presses first dtmf code and $iv->playfile will return the digit pressed.
If $dtmf=2 or more, then playing of specified file will be stopped when caller presses first digit and next a silence (tsil15) of 15 seconds will played, for caller to enter remaining digits. When caller has pressed required number of digits ($dtmf) then playing will be stopped and $iv->playfile will return with complete dtmf digits.
if $dtmf = * OR # then playing will stop and DTMF code punched by caller prior to * OR # will be returned.
IVRS requires many messages to be generated on the fly and then played to caller, like numbers in numerical format, date etc. The default voice directory sfiles/ has number of rmd files. These files can be cut and pasted as required. The above mentioned routines adds up various rmd files to a file specified by $tmpmsg, and finally this file is played to caller. For example to play number 123 to caller, files (from sfiles/) '1','hundred', '20' and '3' will be added to $tmpmsg, and then played.
Add a message from sfiles/
Add a numeric value in Indian format (using lacs and crore)
Same as above but with International format (using milions and billions)
Add characters (A-Z and 0-9)
Add date in yyyymmdd format.
This will record the file $filename in rmd format with proper header for a period of $duration seconds. This rmd file can be converted to any format using pvftools like rmdtopvf and pvftowav.
You can dial out a number, however code is experimental, it worked with US Robotics modem only.
You can transfer a call, however code is experimental, it worked with US Robotics modem only.
This will put the modem in fax mode and you can run efix and efax to send the fax. This should be last instruction in your script. Also install efax or copy these files from bin/ directory to your /usr/bin.
This will do some cleanup, hangup the line and reset the modem.
I thank Bill Birthisel, firstname.lastname@example.org, for serial port code taken from SerialPort.pm,
Copyright (c) 2002 Mukund Deshmukh. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Mukund Deshmukh <email@example.com>