Class: IvonaSpeechCloud::Input::CreateSpeech

Inherits:
Object
  • Object
show all
Includes:
CommonDefaults
Defined in:
lib/ivona_speech_cloud/input.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CommonDefaults

#gender, #language

Constructor Details

#initialize(options) ⇒ CreateSpeech

Returns a new instance of CreateSpeech.

Parameters:

  • options (Array)


33
34
35
36
# File 'lib/ivona_speech_cloud/input.rb', line 33

def initialize(options)
  @text = options.first
  @options = options.last.is_a?(Hash) ? options.pop : {}
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



30
31
32
# File 'lib/ivona_speech_cloud/input.rb', line 30

def options
  @options
end

#textObject

Returns the value of attribute text.



30
31
32
# File 'lib/ivona_speech_cloud/input.rb', line 30

def text
  @text
end

Instance Method Details

#codecObject



61
62
63
# File 'lib/ivona_speech_cloud/input.rb', line 61

def codec
  options.fetch(:codec, DEFAULT[:codec])
end

#paragraph_breakObject



81
82
83
# File 'lib/ivona_speech_cloud/input.rb', line 81

def paragraph_break
  options.fetch(:paragraph_break, DEFAULT[:paragraph_break])
end

#paramsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ivona_speech_cloud/input.rb', line 38

def params
  {
    "Input" => {
      "Data" => text
    },
    "OutputFormat" => {
      "Codec" => codec,
      "SampleRate" => sample_rate,
    },
    "Parameters" => {
      "Rate" => rate,
      "Volume" => volume,
      "SentenceBreak" => sentence_break,
      "ParagraphBreak" => paragraph_break
    },
    "Voice" => {
      "Name" => voice_name,
      "Language" => language,
      "Gender" => gender
    }
  }.to_json
end

#rateObject



69
70
71
# File 'lib/ivona_speech_cloud/input.rb', line 69

def rate
  options.fetch(:rate, DEFAULT[:rate])
end

#sample_rateObject



65
66
67
# File 'lib/ivona_speech_cloud/input.rb', line 65

def sample_rate
  options.fetch(:sample_rate, DEFAULT[:sample_rate])
end

#sentence_breakObject



77
78
79
# File 'lib/ivona_speech_cloud/input.rb', line 77

def sentence_break
  options.fetch(:sentence_break, DEFAULT[:sentence_break])
end

#voice_nameObject



85
86
87
# File 'lib/ivona_speech_cloud/input.rb', line 85

def voice_name
  options.fetch(:voice_name, DEFAULT[:voice_name])
end

#volumeObject



73
74
75
# File 'lib/ivona_speech_cloud/input.rb', line 73

def volume
  options.fetch(:volume, DEFAULT[:volume])
end