Andrew's Asterisk Stuff - Last Update: 15-Feb-2010



VM Wrap to next message mod:

Also See: Digium bug ID #12254
vm-goingtofirst.wav Going to the first message.
vm-goingtolast.wav Going to the last message.
vm14.patch.gz

I have an old PBX VM system that allowed me to wrap around during voicemail message selection. At the first message I am able to select "previous" and have it jump back to the last message (so I could keep playing them in reverse order). Similar for the last message, it allows me to select "next" and it will jump to the first message. This does not force a change to the order of playback it just allows you to go in a circle to get the message you want quickly.

This new feature is enabled by default but can be disabled in the voicemail.conf file. The system knows if there are no messages, or just one, and does not play the prompts for prev/next since it's pointless.

This patch is for Branch 1.4 (about the same version as 1.4.23).

Included english audio files are not correctly licensed for distribution with asterisk and should be re-recorded to match the other asterisk prompts anyway.

vm-goingtofirst.wav "Going to the first message."
vm-goingtolast.wav "Going to the last message."

Copy WAV files to /var/lib/asterisk/sounds (and transcode as needed).
Copy patch to main asterisk source directory and run patch -p0 <vm.patch and rebuild.


TTS Mods:

I gave up on Festival for Text To Speech (TTS). Speech quality was poor, it failed to produce audio sometimes, it locked up all the time, but it is free...

I now use Cepstral as a cost effective (but not free) solution.

Cepstral is easy to install, supports Linux and Solairs, works well, sounds good most of the time, and has a choice of voices including Allison (who records the packaged prompts for Asterisk). They offer full demo downloads so you can test a working setup before you pay for it. The current tested version is 5.1 (there are bugs, but I have worked aound many of them).

At their current prices, it's $30 for the each voice and a single queued FIFO license (no matter how may voices you have paid for). For additional "ports" (concurrent use) it's $50/each in addition to the voices. You have to pay for at least 2 total concurrent uses ($100) to get beyond the single port FIFO setup.

There are at least three ways to use Cepstral with Asterisk:

There are a few other applications for Cepstral/Swift including app_swift by Will Orton and app_swift by Darren Sessions

Application

Requires Cepstral Swift 5.1 (may work with 5.0), please install and test it first.

app_swift

I wrote the appliction named app_swift that uses the swift.conf file and supports several dialplan apps.
My new version supports current 1.4 and 1.6 in the same program with new CLI support. Also, 16kHz support for 1.6

Dialplan Applications:

SwiftCache does an MD5 hash on the text (including the default voice name) and checks to see if it has already been recorded to a cached audio file, if not it records the audio to a new file. The file name of the wave sound file is returned (in local channel variable SWIFTCACHE_FILE) so it can be used by the application Playback, Background, Read, or any other app that supports a file. If a name is not retuned then there was a problem recording the file.

CLI commands:

swift.conf options include:

[general]

; voice
; default: Allison-8kHz
;
; Set the voice you want swift to use; If the voice you specify is not found,
; swift should automatically use the default voice it is configured with.
; Selecting an 8kHz voice should mean less transcoding/CPU usage.
;
voice=Allison-8kHz
;voice=Allison

; use_16khz
; default: no
;
; 16khz support is only for Asterisk 1.6 and only helps wideband codecs.
; Only 16kHz/22kHz voices will sound better (8kHz voices still work).
;
use_16khz=no

; buffer_size
; default: 64000
; range: 16000-1024000 (8kHz)
; range: 32000-1024000 (16kHz)
;
; Number of bytes of audio data to buffer from the Swift libraries.
; app_swift will allocate this much buffer space for each concurrent running
; swift app call.
;
; A larger buffer allows the swift lib to generate audio and complete sonner,
; reducing the amount of time we keep the swift port open (consuming a swift
; concurrency license).
; You should tune this based on the lenth of things you're having swift speak,
; how much memory you can afford to burn (more is better).
;
buffer_size=64000

[cache]
; directory
; default: /tmp
;
; Directory where cached audio files should be stored.
; If directory does not exist then /tmp is used
;
directory=/var/spool/asterisk/swiftcache

; general_infofile
; default: speech.txt
;
; This file in the cache directory will be appended with the text of
; the spoken phrase when recorded. This file will keep growing.
; Can be set to empty (NULL) to disable writing.
;
general_infofile=speech.txt

; individual_infofile
; default: yes
;
; If set a text file (with the same MD5 hash) will be written to the
; cache directory with the phrase recorded in the audio file.
;
individual_infofile=yes

; force_rebuild
; default: no
;
; If set this will always write a new audio file to the cache directory.
;
force_rebuild=no

; rebuild_age
; default: 0 (none)
;
; If set to more than zero (0), the file will be rewritten if it is
; more than AGE hours old.
;
rebuild_age=0

; cleanup_files
; default: yes
;
; If set this will remove other audio files of different formats
; for the same speech text hash. This prevents old files from being used.
; Cleanup is only done when a new file is written.
;
cleanup_files=yes

; output_format
; default: wav
;
; wav (default), ulaw, alaw, sln, sln16, wav16
; 16khz support is only for Asterisk 1.6 (16khz WAV support only with patch)
;
audio_format=wav

Dialplan Examples (extensions.conf)


exten => 440,n,Swift(Allison likes bigfoot.)
exten => 441,n,SwiftBackground(Allison likes bigfoot.)
exten => 442,n,SwiftCache(Allison likes bigfoot.)
exten => 442,n,Playback(${SWIFTCACHE_FILE})
In 440 speech audio is sent directly to the channel (does not stop for DTMF).
In 441 speech audio is sent directly to the channel and allows the caller to dial a new extension.
In 442 the speech audio is saved in the file stored in SWIFTCACHE_FILE which allows you to call any Asterisk application that uses a sound file.
You could also setup a nightly script to transcode cached wave files into other formats so asterisk would need to do even less work on playback.

New stuff to be added: Dialplan variables to control the voice options.


Pager Date Mod:

Also See: Digium bug ID #16263

Allows custom pager date format in voicemail.
This is a standard feature of 1.6 Trunk.

Patch file for 1.4 (branch): pagerdate14.patch.gz
Example in voicemail.conf just after emaildateformat: pagerdateformat=%T %D


Transfer Beep Mod:

Also See: Digium bug ID #9239

After an attended SIP transfer is completed play a beep.
This is a standard feature of 1.6 Trunk.

Patch file for 1.4 (branch): transfer_beep_14.patch.gz
Copy patch file to your main asterisk source directory
run patch in Asterisk directory: patch -p0 <transfer_beep_14.patch
rebuild and install

I just add this to the [global] section of the extensions config file: ATTENDED_TRANSFER_COMPLETE_SOUND=beep


FAX Mods:

I am now using app_fax.c backported from 1.6 with SPANDSP 0.0.6pre10
Here is a patch that others are using that did not work for me, but it's a good start.
I am using a different updated version based on the above patch.
The T.38 code is ifdef'd out so it should compile with a standard version of asterisk 1.4. Any existing T.38 code has not been tested by me in 1.4...

Also See: Digium bug ID #14769 (related to fixes for 1.6 already included here for 1.4)
For a T.38 fix with sending faxes see bug ID #14849

Here is my current (6-Apr-2009) app_fax.c (just copy it to the apps directory)
Install the new version of SPANDSP 0.0.6pre10 and apply the fax.patch and rebuild the system as below.

You can't use the old app_rxfax/app_txfax code with the new SPANDSP.
If you are upgrading/replacing the older app_rxfax/app_txfax just remove them from your app directory and add app_fax in their place, then rebuild. You do not have to re-run the fax.patch.

Older RxFax/TxFax:

Also See: Digium bug ID #10815
Also See: Digium bug ID #11614
Also See: Digium bug ID #11796

Install additional packages needed (debian examples: apt-get install autoconf)

Download SPANDSP 0.0.4pre18
Configure SPANDSP: ./configure
Install SPANDSP: make install
Copy app_rxfax.c and app_txfax.c to the asterisk apps directory.
modified: apps/app_rxfax.c
modified: apps/app_txfax.c (never worked correctly for me)
updated patch: fax.patch (for branch 1.4, about the same as 1.4.23)
Copy patch file to your main asterisk source directory
run patch in Asterisk directory: patch -p0 <fax.patch
remake the asterisk configure files: bootstrap.sh
run ./configure for asterisk
enable the applications from menuselect: make menuselect
Build Asterisk: make

Dialplan example:


[default]
exten => 8605551212,1,Macro(rxfax-email,someone@somewhere.com)

[macro-rxfax-email]
exten => s,1,Answer()
exten => s,n,Set(TIMESTAMP=${STRFTIME(,EST5EDT,%Y%m%d-%H%M%S)})
exten => s,n,Set(FILEID=${TIMESTAMP}_${UNIQUEID})
exten => s,n,Set(FAXPAGES=0)
exten => s,n,Set(EMAILTO=${ARG1})
exten => s,n,RxFAX(/tmp/fax-${FILEID}.tif)
exten => s,n,Hangup()

exten => h,1,NoOp("Finish with RxFax")
exten => h,n,GotoIf(${FAXPAGES}>0?process:done)
exten => h,n(process),system(/usr/bin/tiff2pdf -z -n -f /tmp/fax-${FILEID}.tif | /usr/bin/mime-construct --header "From: FAX " --to "${EMAILTO}" --subject "FAX from ${REMOTESTATIONID} - ${FAXPAGES} Pages" --string "FAX PDF Attached" --type application/pdf --attachment "fax.pdf" --file - --output | /usr/lib/sendmail -F"FAX" -f"fax@somwhere.nett" "${EMAILTO}")
exten => h,n(done),system(/bin/rm -f /tmp/fax-${FILEID}.tif)
exten => h,n,Hangup()
Note there is a problem with hangups in macros with some Asterisk 1.4 versions. Please make sure you are NOT running 1.4.23. See Digium bug ID #14122

Remote called Party ID:

Also See: Digium bug ID #8824

The patch has been updated for 1.4.29, download the patch from the bug report. My older patch I use for 1.4.23 remote_id_branch.patch.gz (updated Jan 2009)
Copy patch file to your main asterisk source directory
run patch in Asterisk directory: patch -p0 <remote_id_branch.patch
enable the dialplan function from menuselect: make menuselect
Build Asterisk: make


G.722 Mods:

Upgrade to Asterisk 1.6 and get official support.


G.722 codec patch for Branch 1.4 back ported from 1.6
g722-20090218.patch.gz assumes branch 1.4 (about version 1.4.23)
Copy patch file to your main asterisk source directory
run patch in Asterisk directory: patch -p0 <g722.patch
Enable the G.722 codec from menuselect: make menuselect
Build Asterisk: make
Add allow=g722 to sip.conf in the general section or for peers

Notes:

Old Notes (no longer apply):


Codec Negotiation:

Also See: Digium bug ID #4825
I have nothing to do with this patch, but I think it should be part of Asterisk... Asterisk Codec Negotiation Patch