Skip to content

Instantly share code, notes, and snippets.

@mboeh
Forked from mrinterweb/speak.rb
Last active August 29, 2015 14:04
Show Gist options
  • Save mboeh/620d542ada26d28907ec to your computer and use it in GitHub Desktop.
Save mboeh/620d542ada26d28907ec to your computer and use it in GitHub Desktop.
#! /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
@mboeh
Copy link
Author

mboeh commented Jul 15, 2014

 SPEAK_VOICES="Trinoids" SPEAK_GREETINGS="Bloop:Blop:Beep:Bop:Doop" SPEAK_NAMES="Bloop:Bop:Beep:Blop:Doop" SPEAK_STATUSES="get back to work" speak.rb

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