Skip to content

Instantly share code, notes, and snippets.

@JamesHagerman
Created November 1, 2017 00:36
Show Gist options
  • Select an option

  • Save JamesHagerman/cea7a1cab361de7ceb3c8a36a1f2e444 to your computer and use it in GitHub Desktop.

Select an option

Save JamesHagerman/cea7a1cab361de7ceb3c8a36a1f2e444 to your computer and use it in GitHub Desktop.
Text to speech tool to build a wavefile for transmission through an SDR
#!/bin/bash
# I needed a way to
# All of this amounts to:
# espeak -v en -m "<say-as interpret-as='characters'>K M 6 I D A</say-as><break strength='strong' />Software defined radio transmit test<break time='5s' />" -w callsign-plus-sdr-transmit-notice.wav
CALLSIGN="KM6IDA"
MESSAGE="Software defined radio transmit test"
DELAY="5s"
echo "Callsign: $CALLSIGN"
# split callsign upwith spaces:
CALLSIGN=`echo $CALLSIGN | sed 's/./& /g'`
# echo " Callsign with spaces: $CALLSIGN"
echo "Message: $MESSAGE"
echo "Post message delay time: $DELAY"
echo
callsignMarkup="<say-as interpret-as='characters'>$CALLSIGN</say-as>"
messageMarkup="<break strength='strong' />$MESSAGE"
if [[ -z "$DELAY" ]]; then
echo "No delay provided..."
else
delayMarkup="<break time='$DELAY' />"
fi
# The actual text we'll turn into speach:
completeMarkup="$callsignMarkup $messageMarkup $delayMarkup"
# The actual command used to do the Text-to-speach:
ESPEAKCMD="espeak -v en -m"
echo "Speaking the message..."
$ESPEAKCMD "$completeMarkup"
echo "Enter a filename without extension or spaces (ctrl-c to quit)"
read FILENAME
echo "Okay! Saving speach output to: $FILENAME.wav"
$ESPEAKCMD "$completeMarkup" -w "$FILENAME.wav"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment