Sha256: 519b898d5d7a12a8a42141016b38c92963b92da8cdc83d04772e06a303f1395d
Contents?: true
Size: 760 Bytes
Versions: 5
Compression:
Stored size: 760 Bytes
Contents
module Ralyxa class OutputSpeech DEFAULT_RESPONSE_TEXT = "Hello World" DEFAULT_RESPONSE_SSML = "<speak>Hello World</speak>" def initialize(speech, ssml) @speech = speech @ssml = ssml end def to_h Hash.new.tap do |output_speech| @ssml ? set_ssml(output_speech) : set_plaintext(output_speech) end end def self.as_hash(speech: nil, ssml: false) new(speech, ssml).to_h end private def set_ssml(output_speech) output_speech[:type] = "SSML" output_speech[:ssml] = (@speech || DEFAULT_RESPONSE_SSML) end def set_plaintext(output_speech) output_speech[:type] = "PlainText" output_speech[:text] = (@speech || DEFAULT_RESPONSE_TEXT) end end end
Version data entries
5 entries across 5 versions & 1 rubygems