Class: FreeTTS::Voice
- Inherits:
-
Object
- Object
- FreeTTS::Voice
- Defined in:
- lib/freetts/voice.rb
Constant Summary collapse
- DEFAULT_NAME =
"kevin16"
Class Attribute Summary collapse
-
.voice_manager ⇒ Object
readonly
Returns the value of attribute voice_manager.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(voice) ⇒ Voice
constructor
A new instance of Voice.
- #method_missing(method, *args, &block) ⇒ Object
- #speak(saying) ⇒ Object
Constructor Details
#initialize(voice) ⇒ Voice
Returns a new instance of Voice.
9 10 11 |
# File 'lib/freetts/voice.rb', line 9 def initialize(voice) @voice_impl = voice end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/freetts/voice.rb', line 17 def method_missing(method, *args, &block) method = method.to_s java_method_name = case method when /\A(.*)=\Z/ "set_#{ $1 }" when /\A(.*)\Z/ "get_#{ $1 }" end if java_method_name and @voice_impl.respond_to?(java_method_name.to_sym) return @voice_impl.send(java_method_name.to_sym, *args) else = "undefined method #{ method } for #{ self }:Voice" raise NoMethodError.new() end end |
Class Attribute Details
.voice_manager ⇒ Object (readonly)
Returns the value of attribute voice_manager.
6 7 8 |
# File 'lib/freetts/voice.rb', line 6 def voice_manager @voice_manager end |
Class Method Details
.all ⇒ Object
34 35 36 |
# File 'lib/freetts/voice.rb', line 34 def self.all voice_manager.get_voices.map { |voice| voice.get_name } end |
Instance Method Details
#speak(saying) ⇒ Object
13 14 15 |
# File 'lib/freetts/voice.rb', line 13 def speak() @voice_impl.speak() end |