Turning Linux into an Answering Machine
From Section6wiki
Linux-based answering machine using MGETTY
For this tutorial, we'll be using Vgetty, part of the mgetty package. The official site is http://alpha.greenie.net/vgetty . You will probably not have to visit the site because just about every distribution carries it. We grabbed the mgetty ebuild from Gentoo's portage tree. /usr/portage/net-dialup/mgetty. Alternatively, you can download the release along with the mgetty source package from http://aplha.greenie.net/mgetty .
tar zxvf mgetty1.1.25-Feb01.tar.gz cd mgetty1.1.25 cp policy.h-dist policy.h vim Makefile
Look for CONFDIR. Remove the $(PREFIX) bit so that the configuration files reside in /etc/mgetty+sendfax. Look around at the other defaults and customize if you like.
make
Enter the voice sub-directory and compile the necessary programs.
cd voice make make install
For RPM fans all you need to do is rpm -Uvh mgetty-1.1.21-91.i386.rpm The default configuration directory should be /etc/mgetty, or /etc/mgetty+sendfax as in our SuSE installation. For those installing from source, you will need to copy the sample voice.conf-dist file into your configuration directory.
cp voice.conf-dist /etc/mgetty+sendfax/voice.conf
Open this file and read through it. The file is very well commented and you should definitely spend some time reading through. Search for the following parameters and customize your installation.
- voice_dir - Point this to the directory that holds your answering machine message as well as your incoming messages.
- rings 3 - Replace the 3 with the number of rings after which the phone is picked up.
- voice_devices - Add the device where your modem is connected. COM1 would be ttyS0, COM2 would be ttyS1, and so on.
- port ttyS0 - Put in the port on where your modem connects.
Now open /etc/inittab and add the following line to it. Check for and
comment out any lines that invoke mgetty.
S1:23:respawn:/usr/local/sbin/vgetty ttyS0
Now you need to record the message that you want to be played when the phone is picked up. If you have a microphone that you can plug into the mic port on the modem then all you need is this command.
vm record standard.rmd
Or you could use a pre-recorded file. Record your message and save it as wav format. Make sure that the file is mono and not stereo. Now you need to run it through a few programs ( included in the vgetty distribution ) to get the final output in the rmd format. wavtopvf filename.wav filename.pvf
Convert the wav to pvf format
pvfspeed -s 7200 filename.pvf filename2.pvf
Change the sampling rate of the pvf file to 7.2Khz. Each modem supports a particular sampling rate and our Rockwell based modem required this sampling rate. The command below will not work if the input pvf file is not in the correct sampling rate. Pvftormd will fail and also tell you what the desired sampling rate is for your modem.
pvftormd Rockwell 4 filename2.pvf filename.rmd
Pvttormd again needs to know what modem to create the rmd file for because the encoding is modem specific. Use pvfspeed -L to see the list of supported modem types. The modem type is case sensitive. The next parameter that can be seen here is 4, which is the number of bits per sample. Possible values for your modem will be shown in the list of supported modem types. More bits means larger rmd files but better sound quality.
The above series of commands can be compressed into a single command line as given below.
wavtopvf filename.wav | pvfspeed -s 7200 | pvftormd Rockwell 4 > filename.rmd
Copy the output rmd file to /var/spool/voice/messages as standard.rmd. Vgetty offers you the option of using multiple greeting files. Create any number of files and place them in the messages directory. Then create or edit the file named Index ( watch the case! ) and put the filenames of the greeting files here. Only one filename per line. Vgetty will now use any of the files specified in there as the greeting message.
That's the setup of vgetty. Now you should start it by giving the command init q. Vgetty will now be running and ready to receive your phone calls.
After picking up the phone vgetty will play the greeting message and then send a beep through the line. Then it switches to recording mode to save the incoming messages. These are saved in the incoming messages folder under /var/spool/voice/incoming.
The files can be played over the phone using the following command.
vm play filename
You can also play it over your sound card using the following command.
rmdtopvf filename.rmd | pvfspeed -s 8000 | pvftobasic > /dev/audio
This was just a basic single voicemailbox machine setup. There's a lot of customization that can be done here, including multiple voicemail boxes. There's a very good solution that gives you all this. Check out VOCP at http://vocp.sourceforge.net .

