Module: Say
- Defined in:
- lib/voice/say.rb
Constant Summary collapse
- DEFAULT_SAY =
'/usr/bin/say'
- DICT =
{ '...' => 'ellipsis', '&' => 'and', '+' => 'plus', '!' => 'exclamation point', '?' => 'question mark', ':' => 'colon', '>' => 'greater than', '<' => 'less than', '^' => 'carrot' }
- EMOTICONS =
{ '8==D' => 'dick', '<3' => 'heart', ':)' => 'smiley face', '=)' => 'smiley face', ':-)' => 'smiley face', ';)' => 'winkey face', ';-)' => 'winkey face', '=D' => 'excited smiley face', ':D' => 'excited smiley face', '8==D~~' => 'dick with sperm shooting out' }
Class Method Summary collapse
Class Method Details
.say(text, opts = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/voice/say.rb', line 30 def self.say(text, opts={}) return if text.empty? for key in EMOTICONS.keys.sort{|a,b| b.length <=> a.length} text.gsub!(key, " #{EMOTICONS[key]} ") end for key in DICT.keys.sort{|a,b| b.length <=> a.length} text.gsub!(key, " #{DICT[key]} ") end system "#{DEFAULT_SAY} #{"-v #{opts[:voice]}" if opts[:voice]} '#{text}'" end |