Skip to content

Instantly share code, notes, and snippets.

@mrinterweb
Last active August 29, 2015 14:03
Show Gist options
  • Save mrinterweb/0ed2ac30a97e25e03fad to your computer and use it in GitHub Desktop.
Save mrinterweb/0ed2ac30a97e25e03fad to your computer and use it in GitHub Desktop.
Fun with OS X "say" and linux espeak commands
#! /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
greetings = [
'ahoy',
'greeting',
'saalutations',
'waazame',
'bleep booop',
'exceslior',
'land hoe',
'hail',
]
names = [
`whoami`,
'Govna',
'captain',
'boss',
'cheef',
'over loard',
'dragon commander',
'your excellence',
]
statuses = [
'all done here',
'works done',
'bingo!',
'hazaa',
'flip Yeah',
'get back to work',
'all systems go',
]
r = ->(arr) { arr[rand(arr.length)] }
str = "#{r[greetings]}, #{r[names]}! #{r[statuses]}"
if RUBY_PLATFORM =~ /linux/i
`echo "#{str}" | espeak`
else
# get a list of all possible voices
voices = `say -v \? | cut -d " " -f1`.split("\n")
`say -v#{r[voices]} #{str}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment