1#!/usr/bin/perl -w 2# 3# $Id: answering_machine.pl,v 1.1 1998/09/09 21:48:52 gert Exp $ 4# 5# A simple answering machine. See the Modem::Vgetty man page for the 6# discussion of this source code. 7# 8# Copyright (c) 1998 Jan "Yenya" Kasprzak <kas@fi.muni.cz>. All rights 9# reserved. This package is free software; you can redistribute it and/or 10# modify it under the same terms as Perl itself. 11# 12# To run it: set the $voicemaster and $voicedir variables below to something 13# usable. Create the $voicedir directory. Edit the vgetty's configuration 14# file (voice.conf) so that it contains the following options: 15# 16# voice_shell /usr/bin/perl 17# call_program /some/path/answering_machine.pl 18# 19# (optional: create the welcome message using something like 20# autopvf <message.au |pvfspeed -s <speed>|pvftormd <modem_type> \ 21# > $voicedir/welcome.rmd 22# where the speed and modem_type depends on your modem type - see the 23# pvftormd(1) documentation.) 24# Configure the vgetty on your modem line (in voice.conf), run it 25# (maybe from /etc/inittab) an call your modem. It should play a welcome 26# message (if you have created one), beep and record the message you 27# say to the phone. 28# 29use Modem::Vgetty; 30 31my $voicemaster = 'root@localhost'; 32my $voicedir = '/var/spool/voice'; 33my $tmout = 30; 34my $finish = 0; 35my $v = new Modem::Vgetty; 36$v->add_handler('BUSY_TONE', 'finish', 37 sub { $v->stop; $finish=1; }); 38$v->add_handler('SILENCE_DETECTED', 'finish', 39 sub { $v->stop; $finish=1; }); 40local $SIG{ALRM} = sub { $v->stop; }; 41$v->enable_events; 42$v->play_and_wait($voicedir.'/welcome.rmd'); 43$v->beep(100,10); 44$v->waitfor('READY'); 45if ($finish == 0) { 46 my $num = 0; 47 $num++ while(-r "$voicedir/$num.rmd"); 48 $v->record("$voicedir/$num.rmd"); 49 alarm $tmout; 50 $v->waitfor('READY'); 51} 52system "echo 'Play with rmdtopvf $voicedir/$num.rmd|pvftoau >/dev/audio'" . 53 " | mail -s 'New voice message' $voicemaster"; 54exit 0; 55