Class: Bandwidth::Bxml::SpeakSentence

Inherits:
Verb
  • Object
show all
Defined in:
lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb

Instance Method Summary collapse

Methods inherited from Verb

#generate_xml, #set_attributes

Constructor Details

#initialize(text, attributes = {}) ⇒ SpeakSentence

Initializer

Parameters:

  • text (String)

    The text to speak. Cannot be blank. Can be a mixture of plain text and SSML tags.

  • attributes (Hash) (defaults to: {})

    The attributes to add to the element. Defaults to an empty hash.



7
8
9
10
11
12
13
14
15
# File 'lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb', line 7

def initialize(text, attributes = {})
  super('SpeakSentence', text, attributes)
  
  @attribute_map = {
    voice: 'voice',   # Optional [String]: Selects the voice of the speaker. If the voice attribute is present, gender and locale are ignored. You can find a list of supported voices here: https://dev.bandwidth.com/docs/voice/bxml/speakSentence/#supported-voices
    gender: 'gender', # Optional [String]: Selects the gender of the speaker. Valid values are "male" or "female". Default "female".
    locale: 'locale', # Optional [String]: Selects the locale of the speaker. Default "en_US"
  }
end

Instance Method Details

#to_bxmlString

Return BXML representaion of this response

Returns:

  • (String)

    The XML response in string format.



19
20
21
22
# File 'lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb', line 19

def to_bxml
  bxml = Ox.dump(generate_xml)
  bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') }
end