Last active
December 16, 2015 04:39
-
-
Save Stantheman/5379166 to your computer and use it in GitHub Desktop.
Sean Connery voice maker. <3 cloud
This file contains 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 | |
# Sean Connery voice maker | |
# shhhay the word | |
function connify { | |
word=$1 | |
word=$(sed -E 's/(s|ch)/shhhh/g' <<< $word) | |
echo -n "$word " | |
} | |
# from http://www.gutenberg.org/dirs/etext02/mthes10.zip | |
thesaurus='/tmp/mthesaur.txt' | |
if [[ ! -z $1 && -e $1 ]]; then | |
thesaurus=$1 | |
else | |
echo "Using $thesaurus as default thesaurus" 1>&2 | |
fi | |
while read line; do | |
for word in $line; do | |
# get rid of punctuation | |
search_word=$(tr -d '.!&"' <<< $word) | |
# we're good if it's already an 's' word | |
if [[ ${search_word:0:1} = 's' ]]; then | |
connify $word | |
continue | |
fi | |
new_word=$(grep "^$search_word," $thesaurus) | |
if [[ $? -ne 0 ]]; then | |
connify $word | |
continue | |
fi | |
new_word=$(expr "$new_word" : '.*,\(s[^,]*\),.*') | |
if [[ $? -ne 0 ]]; then | |
connify $word | |
continue | |
fi | |
connify $new_word | |
done | |
echo '' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hm. View raw shows proper spacing, not sure why it looks weird it quick mode :<