Class: Mac::TTS
- Inherits:
-
Object
- Object
- Mac::TTS
- Defined in:
- lib/mactts.rb
Defined Under Namespace
Classes: InvalidVoiceException, SayCommandNotFoundException
Instance Attribute Summary collapse
-
#say_command ⇒ Object
Returns the value of attribute say_command.
-
#tempfile ⇒ Object
Returns the value of attribute tempfile.
-
#voice ⇒ Object
Returns the value of attribute voice.
Class Method Summary collapse
-
.say(text, voice = :fred) ⇒ Object
Class method to make it easy to use the defaults to say your text.
-
.valid_voices ⇒ Object
An array of valid voice names recognized by the say command Taken from the Speech preference pane.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ TTS
constructor
Initialize the class with a sane set of defaults that can be overriden with the opts hash: opts = { :say_command => ‘/path/to/say’, :tempfile => ‘tempfile_name’, :voice => :valid_voice }.
-
#say(text) ⇒ Object
Use TTS to speak your text, with the voice specified in @voice.
Constructor Details
#initialize(opts = {}) ⇒ TTS
Initialize the class with a sane set of defaults that can be overriden with the opts hash:
opts = { :say_command => '/path/to/say',
:tempfile => 'tempfile_name',
:voice => :valid_voice
}
31 32 33 34 35 |
# File 'lib/mactts.rb', line 31 def initialize(opts = {}) @say_command = opts[:say_command] || '/usr/bin/say' @tempfile = opts[:tempfile] || 'mactts' @voice = opts[:voice] || :fred end |
Instance Attribute Details
#say_command ⇒ Object
Returns the value of attribute say_command.
20 21 22 |
# File 'lib/mactts.rb', line 20 def say_command @say_command end |
#tempfile ⇒ Object
Returns the value of attribute tempfile.
20 21 22 |
# File 'lib/mactts.rb', line 20 def tempfile @tempfile end |
#voice ⇒ Object
Returns the value of attribute voice.
20 21 22 |
# File 'lib/mactts.rb', line 20 def voice @voice end |
Class Method Details
.say(text, voice = :fred) ⇒ Object
42 43 44 45 |
# File 'lib/mactts.rb', line 42 def self.say(text, voice = :fred) mactts = TTS.new(:voice => voice) mactts.say(text) end |
.valid_voices ⇒ Object
An array of valid voice names recognized by the say command Taken from the Speech preference pane.
61 62 63 64 65 |
# File 'lib/mactts.rb', line 61 def self.valid_voices [ :alex, :fred, :bruce, :junior, :ralph, :agnes, :kathy, :princess, :vicki, :victoria, :albert, :bad, :bahh, :bells, :boing, :bubbles, :cellos, :deranged, :good, :hysterical, :pipe, :trinoids, :whisper, :zarvox ] end |