Module: Kernel

Defined in:
lib/say/japanese.rb

Constant Summary collapse

@@say_as_japanese_voice =
:kyoko

Instance Method Summary collapse

Instance Method Details

#say(text) ⇒ Object



6
7
8
# File 'lib/say/japanese.rb', line 6

def say(text)
  say_as @@say_as_japanese_voice, text
end

#say_as(voice, text) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# 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) ⇒ Object



21
22
23
24
25
26
27
28
29
# 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