Upgrade 3CX to v18 and get it hosted free!

Asterisk AGI MacinTalk

Author image

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.

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!"
or
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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.