+1-323-999-6135 blog@hegars.com

#!/bin/bash

#
# to convert and upload voice prompts to asterisk using mac voice.
#

rate=200
voice=lee
file=$1
words=$2
extype=/$3

user=root
host=192.168.81.240
dst=/var/lib/asterisk/sounds/$voice$extype
pem=/Users/hegars/ssh.pem

#define the function to process files
function process {

#generate voice file
say -v $voice -r $rate “$words” -o $file.wav –file-format=WAVE –data-format=LEF32@8000

#all in one?
#say -v $voice -r $rate “$words” -o $file.ulaw –file-format=WAVE –data-format=ulaw@8000

#convert voice files to right format
ffmpeg -i $file.wav -codec:a pcm_mulaw -f mulaw $file.ulaw -y

#copy file to server
scp -i $pem $file.ulaw $user@$host:$dst

#remove temp files
rm $file.wav
rm $file.ulaw

#end function process
}

#check to see if input from console else continue
if [ “$1” = “” ]; then
       echo nothing entered, please try again
       exit
else
       process
fi