找回密码
 注册

QQ登录

只需一步,快速开始

查看: 893|回复: 0

AsteriskNOW & FreePBX – MP3 Voicemail

[复制链接]
发表于 2011-11-17 15:11:50 | 显示全部楼层 |阅读模式
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.
  1. wget http://pkgs.repoforge.org/lame/lame-3.98.4-1.el5.rf.i386.rpm
  2. 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).
  1. #!/usr/bin/perl
  2. open(VOICEMAIL,"|/usr/sbin/sendmail -t");
  3. open(LAMEDEC,"|/usr/bin/dos2unix|/usr/bin/base64 -di|/usr/bin/lame --quiet --preset voice - /var/spool/asterisk/tmp/vmout.$.mp3");
  4. open(VM,">/var/spool/asterisk/tmp/vmout.debug.txt");
  5. my $inaudio = 0;
  6. loop: while(<>){
  7.   if(/^\.$/){
  8.     last loop;
  9.   }
  10.   if(/^Content-Type: audio\/x-wav/i){
  11.     $inaudio = 1;
  12.   }
  13.   if($inaudio){
  14.     while(s/^(Content-.*)wav(.*)$/$1mp3$2/gi){}
  15.     if(/^\n$/){
  16.       iloop: while(<>){
  17.         print LAMEDEC $_;
  18.         if(/^\n$/){
  19.           last iloop;
  20.         }
  21.       }
  22.       close(LAMEDEC);
  23.       print VOICEMAIL "\n";
  24.       print VM "\n";
  25.       open(B64,"/usr/bin/base64 /var/spool/asterisk/tmp/vmout.$.mp3|");
  26.       while(<B64>){
  27.         print VOICEMAIL $_;
  28.         print VM $_;       
  29.       }
  30.       close(B64);
  31.       print VOICEMAIL "\n";
  32.       print VM "\n";
  33.       $inaudio = 0;
  34.     }
  35.   }
  36.   print VOICEMAIL $_;
  37.   print VM $_;
  38. }
  39. print VOICEMAIL "\.";
  40. print VM "\.";
  41. close(VOICEMAIL);
  42. close(VM);

  43. #CLEAN UP THE TEMP FILES CREATED
  44. #This has to be done in a separate cron type job
  45. #because unlinking at the end of this script is too fast,
  46. #the message has not even gotten piped to send mail yet
复制代码

Make the script executable
  1. 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
  1. format= wav
  2. mailcmd= /usr/sbin/sendmp3voicemail.pl
复制代码


Restart Asterisk and test, test, test.
  1. service asterisk restart
复制代码

To roll back if required deleted the mailcmd and change format back to wav49|wav.
Enjoy!
http://www.fscker.ca/rc/


您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-5-28 11:27 , Processed in 0.013646 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表