Class: Vapi::ElevenLabsVoice

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/eleven_labs_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:, caching_enabled: OMIT, stability: OMIT, similarity_boost: OMIT, style: OMIT, use_speaker_boost: OMIT, speed: OMIT, optimize_streaming_latency: OMIT, enable_ssml_parsing: OMIT, auto_mode: OMIT, model: OMIT, chunk_plan: OMIT, language: OMIT, fallback_plan: OMIT, additional_properties: nil) ⇒ Vapi::ElevenLabsVoice

Parameters:

  • caching_enabled (Boolean) (defaults to: OMIT)

    This is the flag to toggle voice caching for the assistant.

  • voice_id (Vapi::ElevenLabsVoiceId)

    This is the provider-specific ID that will be used. Ensure the Voice is present in your 11Labs Voice Library.

  • stability (Float) (defaults to: OMIT)

    Defines the stability for voice settings.

  • similarity_boost (Float) (defaults to: OMIT)

    Defines the similarity boost for voice settings.

  • style (Float) (defaults to: OMIT)

    Defines the style for voice settings.

  • use_speaker_boost (Boolean) (defaults to: OMIT)

    Defines the use speaker boost for voice settings.

  • speed (Float) (defaults to: OMIT)

    Defines the speed for voice settings.

  • optimize_streaming_latency (Float) (defaults to: OMIT)

    Defines the optimize streaming latency for voice settings. Defaults to 3.

  • enable_ssml_parsing (Boolean) (defaults to: OMIT)

    This enables the use of elevenlabs.io/docs/speech-synthesis/prompting#pronunciation. Defaults to false to save latency. @default false

  • auto_mode (Boolean) (defaults to: OMIT)

    Defines the auto mode for voice settings. Defaults to false.

  • model (Vapi::ElevenLabsVoiceModel) (defaults to: OMIT)

    This is the model that will be used. Defaults to ‘eleven_turbo_v2’ if not specified.

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

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

  • language (String) (defaults to: OMIT)

    This is the language (ISO 639-1) that is enforced for the model. Currently only Turbo v2.5 supports language enforcement. For other models, an error will be returned if language code is provided.

  • 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



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 82

def initialize(voice_id:, caching_enabled: OMIT, stability: OMIT, similarity_boost: OMIT, style: OMIT,
               use_speaker_boost: OMIT, speed: OMIT, optimize_streaming_latency: OMIT, enable_ssml_parsing: OMIT, auto_mode: OMIT, model: OMIT, chunk_plan: OMIT, language: OMIT, fallback_plan: OMIT, additional_properties: nil)
  @caching_enabled = caching_enabled if caching_enabled != OMIT
  @voice_id = voice_id
  @stability = stability if stability != OMIT
  @similarity_boost = similarity_boost if similarity_boost != OMIT
  @style = style if style != OMIT
  @use_speaker_boost = use_speaker_boost if use_speaker_boost != OMIT
  @speed = speed if speed != OMIT
  @optimize_streaming_latency = optimize_streaming_latency if optimize_streaming_latency != OMIT
  @enable_ssml_parsing = enable_ssml_parsing if enable_ssml_parsing != OMIT
  @auto_mode = auto_mode if auto_mode != OMIT
  @model = model if model != OMIT
  @chunk_plan = chunk_plan if chunk_plan != OMIT
  @language = language if language != OMIT
  @fallback_plan = fallback_plan if fallback_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "cachingEnabled": caching_enabled,
    "voiceId": voice_id,
    "stability": stability,
    "similarityBoost": similarity_boost,
    "style": style,
    "useSpeakerBoost": use_speaker_boost,
    "speed": speed,
    "optimizeStreamingLatency": optimize_streaming_latency,
    "enableSsmlParsing": enable_ssml_parsing,
    "autoMode": auto_mode,
    "model": model,
    "chunkPlan": chunk_plan,
    "language": language,
    "fallbackPlan": fallback_plan
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



50
51
52
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 50

def additional_properties
  @additional_properties
end

#auto_modeBoolean (readonly)

Returns Defines the auto mode for voice settings. Defaults to false.

Returns:

  • (Boolean)

    Defines the auto mode for voice settings. Defaults to false.



35
36
37
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 35

def auto_mode
  @auto_mode
end

#caching_enabledBoolean (readonly)

Returns This is the flag to toggle voice caching for the assistant.

Returns:

  • (Boolean)

    This is the flag to toggle voice caching for the assistant.



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

def caching_enabled
  @caching_enabled
end

#chunk_planVapi::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.



41
42
43
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 41

def chunk_plan
  @chunk_plan
end

#enable_ssml_parsingBoolean (readonly)

Returns This enables the use of elevenlabs.io/docs/speech-synthesis/prompting#pronunciation. Defaults to false to save latency. @default false.

Returns:



33
34
35
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 33

def enable_ssml_parsing
  @enable_ssml_parsing
end

#fallback_planVapi::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.



48
49
50
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 48

def fallback_plan
  @fallback_plan
end

#languageString (readonly)

This is the language (ISO 639-1) that is enforced for the model. Currently only Turbo v2.5 supports language enforcement. For other models, an error will be returned if language code is provided.

Returns:

  • (String)

    This is the language (ISO 639-1) that is enforced for the model. Currently only Turbo v2.5 supports language enforcement. For other models, an error will be returned if language code is provided.



45
46
47
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 45

def language
  @language
end

#modelVapi::ElevenLabsVoiceModel (readonly)

Returns This is the model that will be used. Defaults to ‘eleven_turbo_v2’ if not specified.

Returns:



38
39
40
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 38

def model
  @model
end

#optimize_streaming_latencyFloat (readonly)

Returns Defines the optimize streaming latency for voice settings. Defaults to 3.

Returns:

  • (Float)

    Defines the optimize streaming latency for voice settings. Defaults to 3.



28
29
30
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 28

def optimize_streaming_latency
  @optimize_streaming_latency
end

#similarity_boostFloat (readonly)

Returns Defines the similarity boost for voice settings.

Returns:

  • (Float)

    Defines the similarity boost for voice settings.



20
21
22
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 20

def similarity_boost
  @similarity_boost
end

#speedFloat (readonly)

Returns Defines the speed for voice settings.

Returns:

  • (Float)

    Defines the speed for voice settings.



26
27
28
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 26

def speed
  @speed
end

#stabilityFloat (readonly)

Returns Defines the stability for voice settings.

Returns:

  • (Float)

    Defines the stability for voice settings.



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

def stability
  @stability
end

#styleFloat (readonly)

Returns Defines the style for voice settings.

Returns:

  • (Float)

    Defines the style for voice settings.



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

def style
  @style
end

#use_speaker_boostBoolean (readonly)

Returns Defines the use speaker boost for voice settings.

Returns:

  • (Boolean)

    Defines the use speaker boost for voice settings.



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

def use_speaker_boost
  @use_speaker_boost
end

#voice_idVapi::ElevenLabsVoiceId (readonly)

Returns This is the provider-specific ID that will be used. Ensure the Voice is present in your 11Labs Voice Library.

Returns:

  • (Vapi::ElevenLabsVoiceId)

    This is the provider-specific ID that will be used. Ensure the Voice is present in your 11Labs Voice Library.



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

def voice_id
  @voice_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ElevenLabsVoice

Deserialize a JSON object to an instance of ElevenLabsVoice

Parameters:

  • json_object (String)

Returns:



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 123

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  caching_enabled = parsed_json["cachingEnabled"]
  if parsed_json["voiceId"].nil?
    voice_id = nil
  else
    voice_id = parsed_json["voiceId"].to_json
    voice_id = Vapi::ElevenLabsVoiceId.from_json(json_object: voice_id)
  end
  stability = parsed_json["stability"]
  similarity_boost = parsed_json["similarityBoost"]
  style = parsed_json["style"]
  use_speaker_boost = parsed_json["useSpeakerBoost"]
  speed = parsed_json["speed"]
  optimize_streaming_latency = parsed_json["optimizeStreamingLatency"]
  enable_ssml_parsing = parsed_json["enableSsmlParsing"]
  auto_mode = parsed_json["autoMode"]
  model = parsed_json["model"]
  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
  language = parsed_json["language"]
  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(
    caching_enabled: caching_enabled,
    voice_id: voice_id,
    stability: stability,
    similarity_boost: similarity_boost,
    style: style,
    use_speaker_boost: use_speaker_boost,
    speed: speed,
    optimize_streaming_latency: optimize_streaming_latency,
    enable_ssml_parsing: enable_ssml_parsing,
    auto_mode: auto_mode,
    model: model,
    chunk_plan: chunk_plan,
    language: language,
    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)


187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 187

def self.validate_raw(obj:)
  obj.caching_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.caching_enabled is not the expected type, validation failed.")
  Vapi::ElevenLabsVoiceId.validate_raw(obj: obj.voice_id)
  obj.stability&.is_a?(Float) != false || raise("Passed value for field obj.stability is not the expected type, validation failed.")
  obj.similarity_boost&.is_a?(Float) != false || raise("Passed value for field obj.similarity_boost is not the expected type, validation failed.")
  obj.style&.is_a?(Float) != false || raise("Passed value for field obj.style is not the expected type, validation failed.")
  obj.use_speaker_boost&.is_a?(Boolean) != false || raise("Passed value for field obj.use_speaker_boost 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.optimize_streaming_latency&.is_a?(Float) != false || raise("Passed value for field obj.optimize_streaming_latency is not the expected type, validation failed.")
  obj.enable_ssml_parsing&.is_a?(Boolean) != false || raise("Passed value for field obj.enable_ssml_parsing is not the expected type, validation failed.")
  obj.auto_mode&.is_a?(Boolean) != false || raise("Passed value for field obj.auto_mode is not the expected type, validation failed.")
  obj.model&.is_a?(Vapi::ElevenLabsVoiceModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.")
  obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan)
  obj.language&.is_a?(String) != false || raise("Passed value for field obj.language is not the expected type, validation failed.")
  obj.fallback_plan.nil? || Vapi::FallbackPlan.validate_raw(obj: obj.fallback_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ElevenLabsVoice to a JSON object

Returns:

  • (String)


177
178
179
# File 'lib/vapi_server_sdk/types/eleven_labs_voice.rb', line 177

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