Skip to content

Instantly share code, notes, and snippets.

@hrs
Created July 21, 2014 01:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrs/f868d0aee7bf7cb6131f to your computer and use it in GitHub Desktop.
Save hrs/f868d0aee7bf7cb6131f to your computer and use it in GitHub Desktop.
REPL for Say
#!/usr/bin/env ruby
class SayRepl
attr_reader :voice
def initialize(voice)
@voice = voice
end
def go
input = ""
while !eof?(input) do
speak(input)
input = get_line
end
puts
end
private
def get_line
print "> "
$stdin.gets
end
def speak(input)
if voice
`say -v #{voice} "#{input}"`
else
`say "#{input}"`
end
end
def eof?(input)
input.nil?
end
end
SayRepl.new(ARGV.first).go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment