Skip to content

Instantly share code, notes, and snippets.

@joshtronic
Created March 10, 2012 16:32
Show Gist options
  • Save joshtronic/2011957 to your computer and use it in GitHub Desktop.
Save joshtronic/2011957 to your computer and use it in GitHub Desktop.
spell and speak
#!/bin/bash
echo "Press [CTRL+C] to exit..."; echo
os=${OSTYPE//[0-9.]/}
if [[ "$os" == "linux-gnu" ]];
then
speak="espeak -v english-us"
elif [[ "$os" == "darwin" ]];
then
speak="say"
else
echo "Operating system is not supported"
exit
fi
while :
do
phrase=''
# Break apart words
IFS=' ' read -ra chars
for i in "${chars[@]}"; do
# Break apart letters
j=0
while [ $j -lt ${#i} ];
do
$speak "${i:$j:1}" &> /dev/null
j=$((j+1));
done
$speak "$i" &> /dev/null
if [[ "$phrase" = "" ]];
then
phrase="$i"
else
phrase="$phrase $i"
fi
done
# Don't say it twice!
if [[ $phrase != $chars ]];
then
$speak "$phrase" &> /dev/null
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment