-
-
Save mboeh/620d542ada26d28907ec to your computer and use it in GitHub Desktop.
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
#! /usr/bin/env ruby | |
# Some of the words are misspelled to help the say program pronounce them right | |
# | |
# copy the following line and paste for fun! | |
# curl -O https://gist.githubusercontent.com/mrinterweb/0ed2ac30a97e25e03fad/raw/5da7c2a012a08cfcc9649e0f410d53f8986e4990/speak.rb && mv speak.rb speak && chmod a+x speak && ./speak | |
def envlist(name, &default) | |
results = (ENV["SPEAK_#{name.to_s.upcase}"] || "").split(":") | |
results.empty? ? default.call : results | |
end | |
greetings = envlist(:greetings) { [ | |
'ahoy', | |
'greeting', | |
'saalutations', | |
'waazame', | |
'bleep booop', | |
'exceslior', | |
'land hoe', | |
'hail', | |
] } | |
names = envlist(:names) { [ | |
`whoami`, | |
'Govna', | |
'captain', | |
'boss', | |
'cheef', | |
'over loard', | |
'dragon commander', | |
'your excellence', | |
] } | |
statuses = envlist(:statuses) { [ | |
'all done here', | |
'works done', | |
'bingo!', | |
'hazaa', | |
'flip Yeah', | |
'get back to work', | |
'all systems go', | |
] } | |
str = "#{greetings.sample}, #{names.sample}! #{statuses.sample}" | |
if RUBY_PLATFORM =~ /linux/i | |
`echo "#{str}" | espeak` | |
else | |
voices = envlist(:voices) { | |
# get a list of all possible voices | |
`say -v \? | cut -d " " -f1`.split("\n") | |
} | |
`say -v#{voices.sample} #{str}` | |
end |
Author
mboeh
commented
Jul 15, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment