Sha256: 20ef3a6359b1ec940f74f343ebe9241b54db1b7c42be441368b80a9dc43b9ed4

Contents?: true

Size: 1.25 KB

Versions: 54

Compression:

Stored size: 1.25 KB

Contents

module Plivo
  module XML
    class Speak < Element
      @valid_attributes = %w[voice language loop]

      SUPPORTED_ENGINES=%w(Polly)
      SUPPORTED_VOICES=%w(Nicole Russell Vitoria Ricardo Chantal Naja Mads Lotte Ruben Lea Celine Mathieu Vicki Marlene Hans Aditi Dora Karl Raveena Aditi Carla Giorgio Mizuki Takumi Seoyeon Zhiyu Liv Ewa Maja Jacek Jan Ines Cristiano Carmen Tatyana Maxim Conchita Enrique Astrid Filiz Amy Emma Brian Joanna Matthew Salli Justin Kendra Joey Kimberly Ivy Penelope Miguel Gwyneth Geraint Zeina Mia)

      def initialize(body, attributes = {})
        if attributes.nil? || attributes[:voice].nil? || ['MAN', 'WOMAN'].include?(attributes[:voice])
          @nestables = []
        else
          engine = attributes[:voice].split('.')[0]
          voice = attributes[:voice].split('.')[1]
          if SUPPORTED_ENGINES.include?(engine) && SUPPORTED_VOICES.include?(voice)
            @nestables = %w(Break Cont Emphasis Lang P Phoneme Prosody S SayAs Sub W)
          else
            raise PlivoXMLError, "<Speak> voice #{attributes[:voice]} is not valid."
          end
        end
        if !body
          raise PlivoXMLError, 'No text set for Speak'
        end
        super(body, attributes, @nestables)
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
plivo-4.61.2 lib/plivo/xml/speak.rb
plivo-4.61.1 lib/plivo/xml/speak.rb
plivo-4.61.0 lib/plivo/xml/speak.rb
plivo-4.60.3 lib/plivo/xml/speak.rb
plivo-4.60.2 lib/plivo/xml/speak.rb
plivo-4.60.1 lib/plivo/xml/speak.rb
plivo-4.60.0 lib/plivo/xml/speak.rb
plivo-4.59.1 lib/plivo/xml/speak.rb
plivo-4.59.0 lib/plivo/xml/speak.rb
plivo-4.56.0 lib/plivo/xml/speak.rb
plivo-4.55.2 lib/plivo/xml/speak.rb
plivo-4.55.1 lib/plivo/xml/speak.rb
plivo-4.55.0 lib/plivo/xml/speak.rb
plivo-4.54.0 lib/plivo/xml/speak.rb
plivo-4.53.1 lib/plivo/xml/speak.rb
plivo-4.53.0 lib/plivo/xml/speak.rb
plivo-4.52.0 lib/plivo/xml/speak.rb
plivo-4.51.0 lib/plivo/xml/speak.rb
plivo-4.50.0 lib/plivo/xml/speak.rb
plivo-4.49.0 lib/plivo/xml/speak.rb