Created
March 10, 2012 16:32
-
-
Save joshtronic/2011957 to your computer and use it in GitHub Desktop.
spell and speak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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