Speakable
Useful for when programs need to talk back more effectively.
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add speakable
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install speakable
Creating a Speakable class
class MySpeaker
include Speakable # <--- defines the speaker object for the class instance
def initialize k
@id = k # <--- necessary for object creation
# use the speaker object immediately
speaker.wav "#{self.class.name} {@id} has been created at #{Time.now.to_i}"
end
def say_hello # example method using the speaker object
# use the speaker object in your code
speaker.say "Hello, World!"
end
# ... whatever else your class needs to do ...
end
The Speakable class object
@me = MySpeaker.new("me") #=> create the speakable object
@me.say_hello #=> run the custom method
@me.speaker[:voice] = 'en-us' #=> set voice
@me.speaker[:variant] = 'm3' #=> set variant
@me.speaker[:pitch] = 220 #=> set pitch
@me.speaker[:speed] = 140 #=> set speed
@me.speaker[:capital] = 170 #=> set capital letter emphasis
@me.speaker.say "Hello, World!" #=> Speak in the speaker's voice
@me.speaker.wav "Hello, World!" #=> Create wav of speakers's voice
The Speakable module
Speakable.keys #=> array of speakers
Speakable.voices #=> list espeak voices
Speakable.voice #=> hash of Speaker voices
Speakable.defaults #=> default voice