Skip to content

Instantly share code, notes, and snippets.

@Stantheman
Last active December 16, 2015 04:39
Show Gist options
  • Save Stantheman/5379166 to your computer and use it in GitHub Desktop.
Save Stantheman/5379166 to your computer and use it in GitHub Desktop.
Sean Connery voice maker. <3 cloud
#!/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
@Stantheman
Copy link
Author

Hm. View raw shows proper spacing, not sure why it looks weird it quick mode :<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment