Created
July 21, 2014 01:25
-
-
Save hrs/f868d0aee7bf7cb6131f to your computer and use it in GitHub Desktop.
REPL for Say
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 | |
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