login | register
Sun 07 of Sep, 2008 [20:32 UTC]

voip-info.org

Discuss [0] History

Asterisk AGI MacinTalk

Created by: jcovert,Last modification on Tue 28 of Nov, 2006 [16:42 UTC]

Asterisk AGI MacinTalk


I just wrote an AGI that lets you call MacinTalk as follows

exten => exten,pri,agi,macintalk|The text you want spoken goes here

Put the following into /var/lib/asterisk/agi-bin/macintalk


#!/bin/bash
trap 'rm /tmp/agi$$_*; exit' INT TERM HUP
#declare -a array
while read -e ARG && [ "$ARG" ] ; do :; done # variables not needed
#        array=(` echo $ARG | sed -e 's/://' -e 's/"//g'`)
#       varname=${array[0]}
#        unset array[0]
#       export $varname="${array[*]}"
#done
unqarg=` echo $1 | sed -e 's/"//g'`

checkresults() {
        while read line
        do
        case ${line:0:4} in
        "200 " ) echo $line >&2
                 return;;
        "510 " ) echo $line >&2
                 return;;
        "520 " ) echo $line >&2
                 return;;
        *      ) echo $line >&2;;       #keep on reading those Invlid command
                                        #command syntax until "520 End ..."
        esac
        done
}

say -v Fred -o /tmp/agi$$_1.aiff "$unqarg"
sox /tmp/agi$$_1.aiff -r 8000 -t ul /tmp/agi$$_2.ulaw
echo "EXEC Playback /tmp/agi$$_2"
checkresults

rm /tmp/agi$$_*



If you need sox, I got it by going to http://www.waveformsoftware.com and downloading SoX Wrap. Double clicking on the package installs the necessary libraries, then I copied SoX Wrap.app/Contents/Resources/sox to /usr/local/bin so that it could be used as a command.

Have fun.
/john


See also



Comments