Class: RubySpeech::SSML::Voice
- Includes:
- XML::Language
- Defined in:
- lib/ruby_speech/ssml/voice.rb
Overview
The voice element is a production element that requests a change in speaking voice.
Constant Summary collapse
- VALID_GENDERS =
[:male, :female, :neutral].freeze
- VALID_CHILD_TYPES =
[Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, S, SayAs, Sub, Voice].freeze
Instance Attribute Summary
Attributes included from GenericElement
Instance Method Summary collapse
- #<<(arg) ⇒ Object
-
#age ⇒ Integer
Indicates the preferred age in years (since birth) of the voice to speak the contained text.
- #age=(i) ⇒ Object
- #eql?(o) ⇒ Boolean
-
#gender ⇒ Symbol
Indicates the preferred gender of the voice to speak the contained text.
- #gender=(g) ⇒ Object
-
#name ⇒ String, ...
A processor-specific voice name to speak the contained text.
- #name=(n) ⇒ Object
-
#variant ⇒ Integer
Indicates a preferred variant of the other voice characteristics to speak the contained text.
- #variant=(i) ⇒ Object
Methods included from XML::Language
Methods inherited from Element
module, namespace, root_element, #to_doc
Methods included from GenericElement
#+, #==, #base_uri, #base_uri=, #build, #children, #clone, #create_node, #embed, #eval_dsl_block, included, #inherit, #initialize, #inspect, #mass_assign, #method_missing, #namespace=, #namespace_href, #node, #nokogiri_children, #read_attr, #respond_to_missing?, #string, #to_s, #traverse, #version, #version=, #write_attr
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RubySpeech::GenericElement
Instance Method Details
#<<(arg) ⇒ Object
117 118 119 120 |
# File 'lib/ruby_speech/ssml/voice.rb', line 117 def <<(arg) raise InvalidChildError, "A Voice can only accept String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, SayAs, Sub, S, Voice as children" unless VALID_CHILD_TYPES.include? arg.class super end |
#age ⇒ Integer
Indicates the preferred age in years (since birth) of the voice to speak the contained text.
59 60 61 |
# File 'lib/ruby_speech/ssml/voice.rb', line 59 def age read_attr :age, :to_i end |
#age=(i) ⇒ Object
68 69 70 71 |
# File 'lib/ruby_speech/ssml/voice.rb', line 68 def age=(i) raise ArgumentError, "You must specify a valid age (non-negative integer)" unless i.is_a?(Integer) && i >= 0 self[:age] = i end |
#eql?(o) ⇒ Boolean
122 123 124 |
# File 'lib/ruby_speech/ssml/voice.rb', line 122 def eql?(o) super o, :language, :gender, :age, :variant, :name end |
#gender ⇒ Symbol
Indicates the preferred gender of the voice to speak the contained text. Enumerated values are: “male”, “female”, “neutral”.
40 41 42 |
# File 'lib/ruby_speech/ssml/voice.rb', line 40 def gender read_attr :gender, :to_sym end |
#gender=(g) ⇒ Object
49 50 51 52 |
# File 'lib/ruby_speech/ssml/voice.rb', line 49 def gender=(g) raise ArgumentError, "You must specify a valid gender (#{VALID_GENDERS.map(&:inspect).join ', '})" unless VALID_GENDERS.include? g self[:gender] = g end |
#name ⇒ String, ...
A processor-specific voice name to speak the contained text.
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ruby_speech/ssml/voice.rb', line 97 def name names = read_attr :name return unless names names = names.split ' ' case names.count when 0 then nil when 1 then names.first else names end end |
#name=(n) ⇒ Object
111 112 113 114 115 |
# File 'lib/ruby_speech/ssml/voice.rb', line 111 def name=(n) # TODO: Raise ArgumentError if names contain whitespace n = n.join(' ') if n.is_a? Array self[:name] = n end |
#variant ⇒ Integer
Indicates a preferred variant of the other voice characteristics to speak the contained text. (e.g. the second male child voice).
78 79 80 |
# File 'lib/ruby_speech/ssml/voice.rb', line 78 def variant read_attr :variant, :to_i end |
#variant=(i) ⇒ Object
87 88 89 90 |
# File 'lib/ruby_speech/ssml/voice.rb', line 87 def variant=(i) raise ArgumentError, "You must specify a valid variant (positive integer)" unless i.is_a?(Integer) && i > 0 self[:variant] = i end |