Class: RubySpeech::SSML::Emphasis

Inherits:
Element
  • Object
show all
Defined in:
lib/ruby_speech/ssml/emphasis.rb

Overview

The emphasis element requests that the contained text be spoken with emphasis (also referred to as prominence or stress). The synthesis processor determines how to render emphasis since the nature of emphasis differs between languages, dialects or even voices.

www.w3.org/TR/speech-synthesis/#S3.2.2

Constant Summary collapse

VALID_LEVELS =
[:strong, :moderate, :none, :reduced].freeze
VALID_CHILD_TYPES =
[Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Mark, Phoneme, Prosody, SayAs, Sub, Voice].freeze

Instance Attribute Summary

Attributes included from GenericElement

#parent

Instance Method Summary collapse

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

Raises:


51
52
53
54
# File 'lib/ruby_speech/ssml/emphasis.rb', line 51

def <<(arg)
  raise InvalidChildError, "An Emphasis can only accept String, Audio, Break, Emphasis, Mark, Phoneme, Prosody, SayAs, Sub, Voice as children" unless VALID_CHILD_TYPES.include? arg.class
  super
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

56
57
58
# File 'lib/ruby_speech/ssml/emphasis.rb', line 56

def eql?(o)
  super o, :level
end

#levelSymbol

Indicates the strength of emphasis to be applied. Defined values are “strong”, “moderate”, “none” and “reduced”. The default level is “moderate”. The meaning of “strong” and “moderate” emphasis is interpreted according to the language being spoken (languages indicate emphasis using a possible combination of pitch change, timing changes, loudness and other acoustic differences). The “reduced” level is effectively the opposite of emphasizing a word. For example, when the phrase “going to” is reduced it may be spoken as “gonna”. The “none” level is used to prevent the synthesis processor from emphasizing words that it might typically emphasize. The values “none”, “moderate”, and “strong” are monotonically non-decreasing in strength.

Returns:

  • (Symbol)

37
38
39
# File 'lib/ruby_speech/ssml/emphasis.rb', line 37

def level
  read_attr :level, :to_sym
end

#level=(l) ⇒ Object

Parameters:

  • l (Symbol)

    the level. Must be one of VALID_LEVELS

Raises:

  • (ArgumentError)

46
47
48
49
# File 'lib/ruby_speech/ssml/emphasis.rb', line 46

def level=(l)
  raise ArgumentError, "You must specify a valid level (#{VALID_LEVELS.map(&:inspect).join ', '})" unless VALID_LEVELS.include? l
  self[:level] = l
end