Asterisk AGI MacinTalk

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

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[*]}"
unqarg=` echo $1 | sed -e 's/"//g'`

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

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"

rm /tmp/agi$$_*

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

How to use Macintalk

On MacOS X, open the Terminal application and type:

say -v Vicki --channels=1 --data-format=UI8@8000 -o /tmp/outfile.wav "Isn't it nice to have a computer that will talk to you?"

If you just type either of the following commands, the computer will simply read it out:

say -v Fred "Hello there!"
echo "Hello there!" | say -v Victoria

"man say" displays a manpage that lists the file formats and voices available.

On Ubuntu, if sox gives you this error, you probably are missing option sound formats packages: sox soxio: Failed reading `/tmp/myfile.wav': unknown file type `auto'. If so, do an sudo apt-get update && sudo apt-get install libsox-fmt-all See which sound formats you've got with a good old: sox --help | grep "SUPPORTED FILE FORMATS"

See also

Created by: jcovert, Last modification: Sun 25 of Apr, 2010 (23:00 UTC) by simon
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+