module Kernel

Public Instance Methods

say(text) click to toggle source
# File lib/say/japanese.rb, line 6
def say(text)
  say_as @@say_as_japanese_voice, text
end
say_as(voice, text) click to toggle source
# File lib/say/japanese.rb, line 10
def say_as(voice, text)
  return unless text
  text = text.to_s.strip
  return if text.empty?
  text.gsub!(/(\r\n|\r|\n)/, '。')

  voice ||= @@say_as_japanese_voice

  system "say -v #{voice} #{text}"
end
set_say_as_default(voice) click to toggle source
# File lib/say/japanese.rb, line 21
def set_say_as_default(voice)
  unless [:kyoko, :otoya].include?(voice)
    puts "invalid voice #{voice}"
    puts "use :kyoko or :otoya"
    return
  end

  @@say_as_japanese_voice = voice
end