Class: RubySpeech::SSML::Audio

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

Overview

The audio element supports the insertion of recorded audio files (see Appendix A for required formats) and the insertion of other audio formats in conjunction with synthesized speech output. The audio element may be empty. If the audio element is not empty then the contents should be the marked-up text to be spoken if the audio document is not available. The alternate content may include text, speech markup, desc elements, or other audio elements. The alternate content may also be used when rendering the document to non-audible output and for accessibility (see the desc element). The required attribute is src, which is the URI of a document with an appropriate MIME type.

An audio element is successfully rendered:

* If the referenced audio source is played, or
* If the synthesis processor is unable to execute #1 but the alternative content is successfully rendered, or
* If the processor can detect that text-only output is required and the alternative content is successfully rendered.

Deciding which conditions result in the alternative content being rendered is processor-dependent. If the audio element is not successfully rendered, a synthesis processor should continue processing and should notify the hosting environment. The processor may determine after beginning playback of an audio source that the audio cannot be played in its entirety. For example, encoding problems, network disruptions, etc. may occur. The processor may designate this either as successful or unsuccessful rendering, but it must document this behavior.

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

Constant Summary collapse

VALID_CHILD_TYPES =
[Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Desc, Emphasis, Mark, P, Phoneme, Prosody, S, 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:


54
55
56
57
# File 'lib/ruby_speech/ssml/audio.rb', line 54

def <<(arg)
  raise InvalidChildError, "An Audio 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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

59
60
61
# File 'lib/ruby_speech/ssml/audio.rb', line 59

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

#srcString

The URI of a document with an appropriate MIME type

Returns:

  • (String)

43
44
45
# File 'lib/ruby_speech/ssml/audio.rb', line 43

def src
  read_attr :src
end

#src=(s) ⇒ Object

Parameters:

  • the (String)

    source. Must be a valid URI


50
51
52
# File 'lib/ruby_speech/ssml/audio.rb', line 50

def src=(s)
  self[:src] = s
end