|
|
Based on AsteriskNOW 1.7 with all updates applied (and upgraded to FreePBX 2.9.07) as of 2011-06. Pieced together from several sources, mostly based on info and script from voip-info.org (sending voicemails as mp3′s).
Download and install the latest version of lame that has been compiled for your architecture. If you are running Trixbox or AsteriskNOW you are most likely CentOS-5 x86 32bit.
- wget http://pkgs.repoforge.org/lame/lame-3.98.4-1.el5.rf.i386.rpm
- rpm -Uvh lame-3.98.4-1.el5.rf.i386.rpm
复制代码
If the above link does not work then google “dags repo” and dig through there until you find the latest lame for your platform (cat /etc/redhat-release).
Create the following script as /usr/sbin/sendmp3voicemail.pl (view/download sendmp3voicemail).
- #!/usr/bin/perl
- open(VOICEMAIL,"|/usr/sbin/sendmail -t");
- open(LAMEDEC,"|/usr/bin/dos2unix|/usr/bin/base64 -di|/usr/bin/lame --quiet --preset voice - /var/spool/asterisk/tmp/vmout.$.mp3");
- open(VM,">/var/spool/asterisk/tmp/vmout.debug.txt");
- my $inaudio = 0;
- loop: while(<>){
- if(/^\.$/){
- last loop;
- }
- if(/^Content-Type: audio\/x-wav/i){
- $inaudio = 1;
- }
- if($inaudio){
- while(s/^(Content-.*)wav(.*)$/$1mp3$2/gi){}
- if(/^\n$/){
- iloop: while(<>){
- print LAMEDEC $_;
- if(/^\n$/){
- last iloop;
- }
- }
- close(LAMEDEC);
- print VOICEMAIL "\n";
- print VM "\n";
- open(B64,"/usr/bin/base64 /var/spool/asterisk/tmp/vmout.$.mp3|");
- while(<B64>){
- print VOICEMAIL $_;
- print VM $_;
- }
- close(B64);
- print VOICEMAIL "\n";
- print VM "\n";
- $inaudio = 0;
- }
- }
- print VOICEMAIL $_;
- print VM $_;
- }
- print VOICEMAIL "\.";
- print VM "\.";
- close(VOICEMAIL);
- close(VM);
- #CLEAN UP THE TEMP FILES CREATED
- #This has to be done in a separate cron type job
- #because unlinking at the end of this script is too fast,
- #the message has not even gotten piped to send mail yet
复制代码
Make the script executable
- chmod 775 /usr/sbin/sendmp3voicemail.pl
复制代码
Change default voicemail format to uncompressed WAV (which will be converted to MP3) and set mailcmd script.
FreePBX -> Voicemail Admin -> Settings
- format= wav
- mailcmd= /usr/sbin/sendmp3voicemail.pl
复制代码
Restart Asterisk and test, test, test.
To roll back if required deleted the mailcmd and change format back to wav49|wav.
Enjoy!
http://www.fscker.ca/rc/
|
|