Class: Vapi::SmallestAiVoice

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/smallest_ai_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, speed: OMIT, chunk_plan: OMIT, fallback_plan: OMIT, additional_properties: nil) ⇒ Vapi::SmallestAiVoice

Parameters:

  • voice_id (Vapi::SmallestAiVoiceId) —

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

  • model (String) (defaults to: OMIT) —

    Smallest AI voice model to use. Defaults to 'lightning' when not specified.

  • speed (Float) (defaults to: OMIT) —

    This is the speed multiplier 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.

  • fallback_plan (Vapi::FallbackPlan) (defaults to: OMIT) —

    This is the plan for voice provider fallbacks in the event that the primary voice provider fails.

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

    Additional properties unmapped to the current class definition



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 40

def initialize(voice_id:, model: OMIT, speed: OMIT, chunk_plan: OMIT, fallback_plan: OMIT,
               additional_properties: nil)
  @voice_id = voice_id
  @model = model if model != OMIT
  @speed = speed if speed != OMIT
  @chunk_plan = chunk_plan if chunk_plan != OMIT
  @fallback_plan = fallback_plan if fallback_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "voiceId": voice_id,
    "model": model,
    "speed": speed,
    "chunkPlan": chunk_plan,
    "fallbackPlan": fallback_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



24
25
26
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 24

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.



19
20
21
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 19

def chunk_plan
  @chunk_plan
end

#fallback_plan ⇒ Vapi::FallbackPlan (readonly)

Returns This is the plan for voice provider fallbacks in the event that the primary voice provider fails.

Returns:

  • (Vapi::FallbackPlan) —

    This is the plan for voice provider fallbacks in the event that the primary voice provider fails.



22
23
24
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 22

def fallback_plan
  @fallback_plan
end

#model ⇒ String (readonly)

Returns Smallest AI voice model to use. Defaults to 'lightning' when not specified.

Returns:

  • (String) —

    Smallest AI voice model to use. Defaults to 'lightning' when not specified.



14
15
16
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 14

def model
  @model
end

#speed ⇒ Float (readonly)

Returns This is the speed multiplier that will be used.

Returns:

  • (Float) —

    This is the speed multiplier that will be used.



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

def speed
  @speed
end

#voice_id ⇒ Vapi::SmallestAiVoiceId (readonly)

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

Returns:



12
13
14
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 12

def voice_id
  @voice_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::SmallestAiVoice

Deserialize a JSON object to an instance of SmallestAiVoice

Parameters:

  • json_object (String)

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 63

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["voiceId"].nil?
    voice_id = nil
  else
    voice_id = parsed_json["voiceId"].to_json
    voice_id = Vapi::SmallestAiVoiceId.from_json(json_object: voice_id)
  end
  model = parsed_json["model"]
  speed = parsed_json["speed"]
  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
  if parsed_json["fallbackPlan"].nil?
    fallback_plan = nil
  else
    fallback_plan = parsed_json["fallbackPlan"].to_json
    fallback_plan = Vapi::FallbackPlan.from_json(json_object: fallback_plan)
  end
  new(
    voice_id: voice_id,
    model: model,
    speed: speed,
    chunk_plan: chunk_plan,
    fallback_plan: fallback_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)


109
110
111
112
113
114
115
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 109

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

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of SmallestAiVoice to a JSON object

Returns:

  • (String)


99
100
101
# File 'lib/vapi_server_sdk/types/smallest_ai_voice.rb', line 99

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