Class: Typecast::Models::RecommendedVoice

Inherits:
Object
  • Object
show all
Defined in:
lib/typecast/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(voice_id:, voice_name:, score:) ⇒ RecommendedVoice

Returns a new instance of RecommendedVoice.



196
197
198
199
200
# File 'lib/typecast/models.rb', line 196

def initialize(voice_id:, voice_name:, score:)
  @voice_id = voice_id
  @voice_name = voice_name
  @score = score
end

Instance Attribute Details

#scoreObject (readonly)

Returns the value of attribute score.



183
184
185
# File 'lib/typecast/models.rb', line 183

def score
  @score
end

#voice_idObject (readonly)

Returns the value of attribute voice_id.



183
184
185
# File 'lib/typecast/models.rb', line 183

def voice_id
  @voice_id
end

#voice_nameObject (readonly)

Returns the value of attribute voice_name.



183
184
185
# File 'lib/typecast/models.rb', line 183

def voice_name
  @voice_name
end

Class Method Details

.from_h(hash) ⇒ Object

Recommendation results only include the matched voice ID, voice name, and similarity score. Use get_voice_v2 or get_voices_v2 to fetch detailed voice metadata for a returned voice_id.



188
189
190
191
192
193
194
# File 'lib/typecast/models.rb', line 188

def self.from_h(hash)
  new(
    voice_id: hash.fetch("voice_id", ""),
    voice_name: hash.fetch("voice_name", ""),
    score: hash.fetch("score", 0).to_f
  )
end