[arm-allstar] speaktext.sh
(KP4TR)Ramon Gonzalez
kp4tr.ramon at gmail.com
Sat Jul 26 11:02:07 EST 2014
Doug
Attached is a shellscript I wrote based on the questions I had about
making the radio transmit and sending speech.
I'm using this to output information from my local environment using
another script that fetches this for me from DTMF commands. That other
script is yet to be written but I do have it for IRLP. Just need to
adapt it to Allstar.
To use just enter text in quotes and the node to send it to. It is still
a work in progress but useable
Example syntax is:
./speaktext.sh "IP 192.168.1.20" 28727
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hamvoip.org/pipermail/arm-allstar/attachments/20140726/646e903d/attachment.html>
-------------- next part --------------
#!/bin/bash
#
# Script to speak letters and numbers from asterisk sounds
# over a radio node using simpleusb
# by Ramon Gonzalez KP4TR 2014
#
#set -xv
ASTERISKSND=/var/lib/asterisk/sounds
LOCALSND=/tmp/randommsg
function speak {
SPEAKTEXT=$(echo "$1" | tr '[:upper:]' '[:lower:]')
let SPEAKLEN=$(echo "$SPEAKTEXT" | /usr/bin/wc -m)-1
COUNTER=0
rm -f ${LOCALSND}.gsm
touch ${LOCALSND}.gsm
while [ $COUNTER -lt $SPEAKLEN ]; do
let COUNTER=COUNTER+1
CH=$(echo "$SPEAKTEXT"|cut -c${COUNTER})
if [[ $CH =~ ^[A-Za-z_]+$ ]]; then
cat ${ASTERISKSND}/letters/${CH}.gsm >> ${LOCALSND}.gsm
fi
if [[ ${CH} =~ ^-?[0-9]+$ ]]; then
cat /var/lib/asterisk/sounds/digits/${CH}.gsm >> ${LOCALSND}.gsm
fi
case $CH in
.) cat ${ASTERISKSND}/letters/dot.gsm >> ${LOCALSND}.gsm;;
-) cat ${ASTERISKSND}/letters/dash.gsm >> ${LOCALSND}.gsm;;
=) cat ${ASTERISKSND}/letters/equals.gsm >> ${LOCALSND}.gsm;;
/) cat ${ASTERISKSND}/letters/slash.gsm >> ${LOCALSND}.gsm;;
!) cat ${ASTERISKSND}/letters/exclaimation-point.gsm >> ${LOCALSND}.gsm;;
@) cat ${ASTERISKSND}letters/at.gsm >> ${LOCALSND}.gsm;;
$) cat ${ASTERISKSND}/letters/dollar.gsm >> ${LOCALSND}.gsm;;
*) ;;
esac
done
asterisk -rx "susb key"
asterisk -rx "rpt playback $2 ${LOCALSND}"
asterisk -rx "susb unkey"
}
if [ "$1" == "" -o "$2" == "" ];then
echo "Usage: speaktext.sh \"abc123\" node#"
exit
fi
speak "$1" $2
More information about the arm-allstar
mailing list