Sunday, May 11, 2008
Asterisk Telephony - GNU GPL Public Code
# Use this at your own risk!
#
# Any software posted here is free software;
# you can redistribute it and/or modify it under
# the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# These programs are distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Cepstral on Trixbox - Self Explanatory.
Status: Working on 1.2
1. Download, install, and register your Cepstral voice for i368-Linux (using William as an example)
cd /usr/src
wget http://downloads.cepstral.com/cepstral/i386-linux/Cepstral_William_i386-linux_4.1.4.tar.gz
tar zxvf Cepstral_William_i386-linux_4.1.4.tar.gz
cd /usr/src/Cepstral_William_i386-linux_4.1.4
./install.sh (take the defaults)
License your voice ( http://www.cepstral.com/cgi-bin/support?page=faq&type=i386-linux#enterkey )
swift --reg-voice
2. Cepstral needs Data-UUID and Trixbox doesn't have that by default (http://search.cpan.org/dist/Data-UUID/ )
cd /usr/src
wget http://search.cpan.org/CPAN/authors/id/R/RJ/RJBS/Data-UUID-0.142.tar.gz
tar zxvf Data-UUID-0.142.tar.gz
cd /usr/src/Data-UUID-0.142
perl Makefile.PL
make
make test
make install
3. Make cepstral.pl (really a modification of festrival-script.pl) in /var/lib/asterisk/agi-bin, file below:
***cepstral.pl*** (also available here)
#!/usr/bin/perl
use Asterisk::AGI;
use File::Basename;
require Data::UUID;
$AGI = new Asterisk::AGI;
my $ug = new Data::UUID;
my $timestamp = gmtime;
my %input = $AGI->ReadParse();
my ($text)=@ARGV;
my $hash = $ug->create_str;
my $sounddir = "/var/lib/asterisk/sounds/tts";
my $wavefile = "$sounddir/"."tts-$hash.wav";
my $t2wp= "/opt/swift/bin/";
unless (-f $wavefile) {
open(fileOUT, ">$sounddir"."/say-text-$hash.txt");
print fileOUT "$text";
close(fileOUT);
my $execf=$t2wp."swift -f $sounddir/say-text-$hash.txt -p
audio/channels=1,cst/f0_shift=.8,speech/rate=190,audio/sampling-rate=8000,audio/deadair=2
-o $wavefile";
system($execf);
unlink($sounddir."/say-text-$hash.txt");
}
$AGI->stream_file('tts/'.basename($wavefile,".wav"));
*****************
4. Change file rights
cd /var/lib/asterisk/agi-bin
chmod 777 cepstral.pl
5. Modify your dialplan
Make changes in /etc/asterisk/extensions_custom.conf (always use the custom here so they don't get overwritten during updates)
Here's an example:
[custom-number-denied]
exten => s,1,Answer
exten => s,2,Wait(2)
exten => s,3,AGI(cepstral.pl|Your call has been blocked from this system.)
exten => s,4,AGI(cepstral.pl|Please remove us from your calling list.)
exten => s,5,AGI(cepstral.pl|Further calls will be treated as harrasment and
will be prosecuted.)
exten => s,6,AGI(cepstral.pl|Goodbye.)
exten => s,7,hangup
6. Call it from your dialplan. This one is used in the Inbound Routes to match a caller ID number and then dump it to a custom context of:
custom-number-denied,s,1