Class: Vapi::FallbackCartesiaVoice

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/fallback_cartesia_voice.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(voice_id:, model: OMIT, language: OMIT, chunk_plan: OMIT, additional_properties: nil) ⇒ Vapi::FallbackCartesiaVoice

Parameters:

  • model (Vapi::FallbackCartesiaVoiceModel) (defaults to: OMIT) —

    This is the model that will be used. This is optional and will default to the correct model for the voiceId.

  • language (Vapi::FallbackCartesiaVoiceLanguage) (defaults to: OMIT) —

    This is the language that will be used. This is optional and will default to the correct language for the voiceId.

  • voice_id (String) —

    This is the provider-specific ID that will be used.

  • chunk_plan (Vapi::ChunkPlan) (defaults to: OMIT) —

    This is the plan for chunking the model output before it is sent to the voice provider.

  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 39

def initialize(voice_id:, model: OMIT, language: OMIT, chunk_plan: OMIT, additional_properties: nil)
  @model = model if model != OMIT
  @language = language if language != OMIT
  @voice_id = voice_id
  @chunk_plan = chunk_plan if chunk_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "model": model,
    "language": language,
    "voiceId": voice_id,
    "chunkPlan": chunk_plan
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



23
24
25
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 23

def additional_properties
  @additional_properties
end

#chunk_plan ⇒ Vapi::ChunkPlan (readonly)

Returns This is the plan for chunking the model output before it is sent to the voice provider.

Returns:

  • (Vapi::ChunkPlan) —

    This is the plan for chunking the model output before it is sent to the voice provider.



21
22
23
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 21

def chunk_plan
  @chunk_plan
end

#language ⇒ Vapi::FallbackCartesiaVoiceLanguage (readonly)

Returns This is the language that will be used. This is optional and will default to the correct language for the voiceId.

Returns:



16
17
18
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 16

def language
  @language
end

#model ⇒ Vapi::FallbackCartesiaVoiceModel (readonly)

Returns This is the model that will be used. This is optional and will default to the correct model for the voiceId.

Returns:



13
14
15
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 13

def model
  @model
end

#voice_id ⇒ String (readonly)

Returns This is the provider-specific ID that will be used.

Returns:

  • (String) —

    This is the provider-specific ID that will be used.



18
19
20
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 18

def voice_id
  @voice_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::FallbackCartesiaVoice

Deserialize a JSON object to an instance of FallbackCartesiaVoice

Parameters:

  • json_object (String)

Returns:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 59

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  model = parsed_json["model"]
  language = parsed_json["language"]
  voice_id = parsed_json["voiceId"]
  if parsed_json["chunkPlan"].nil?
    chunk_plan = nil
  else
    chunk_plan = parsed_json["chunkPlan"].to_json
    chunk_plan = Vapi::ChunkPlan.from_json(json_object: chunk_plan)
  end
  new(
    model: model,
    language: language,
    voice_id: voice_id,
    chunk_plan: chunk_plan,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


93
94
95
96
97
98
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 93

def self.validate_raw(obj:)
  obj.model&.is_a?(Vapi::FallbackCartesiaVoiceModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.")
  obj.language&.is_a?(Vapi::FallbackCartesiaVoiceLanguage) != false || raise("Passed value for field obj.language is not the expected type, validation failed.")
  obj.voice_id.is_a?(String) != false || raise("Passed value for field obj.voice_id is not the expected type, validation failed.")
  obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of FallbackCartesiaVoice to a JSON object

Returns:

  • (String)


83
84
85
# File 'lib/vapi_server_sdk/types/fallback_cartesia_voice.rb', line 83

def to_json(*_args)
  @_field_set&.to_json
end