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.



217
218
219
220
221
# File 'lib/typecast/models.rb', line 217

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

Instance Attribute Details

#score ⇒ Object (readonly)

Returns the value of attribute score.



204
205
206
# File 'lib/typecast/models.rb', line 204

def score
  @score
end

#voice_id ⇒ Object (readonly)

Returns the value of attribute voice_id.



204
205
206
# File 'lib/typecast/models.rb', line 204

def voice_id
  @voice_id
end

#voice_name ⇒ Object (readonly)

Returns the value of attribute voice_name.



204
205
206
# File 'lib/typecast/models.rb', line 204

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.



209
210
211
212
213
214
215
# File 'lib/typecast/models.rb', line 209

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