Class: Vapi::FallbackRimeAiVoice

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/fallback_rime_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:, caching_enabled: OMIT, model: OMIT, speed: OMIT, pause_between_brackets: OMIT, phonemize_between_brackets: OMIT, reduce_latency: OMIT, inline_speed_alpha: OMIT, chunk_plan: OMIT, additional_properties: nil) ⇒ Vapi::FallbackRimeAiVoice

Parameters:

  • caching_enabled (Boolean) (defaults to: OMIT)

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

  • voice_id (Vapi::FallbackRimeAiVoiceId)

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

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

    This is the model that will be used. Defaults to ‘mistv2’ when not specified.

  • speed (Float) (defaults to: OMIT)

    This is the speed multiplier that will be used.

  • pause_between_brackets (Boolean) (defaults to: OMIT)

    This is a flag that controls whether to add slight pauses using angle brackets. Example: “Hi. <200> I’d love to have a conversation with you.” adds a 200ms pause between the first and second sentences.

  • phonemize_between_brackets (Boolean) (defaults to: OMIT)

    This is a flag that controls whether text inside brackets should be phonemized (converted to phonetic pronunciation) - Example: “Vapi::FallbackRimeAiVoice.h’Elh’El.o World” will pronounce “Hello” as expected.

  • reduce_latency (Boolean) (defaults to: OMIT)

    This is a flag that controls whether to optimize for reduced latency in streaming. docs.rime.ai/api-reference/endpoint/websockets#param-reduce-latency

  • inline_speed_alpha (String) (defaults to: OMIT)

    This is a string that allows inline speed control using alpha notation. docs.rime.ai/api-reference/endpoint/websockets#param-inline-speed-alpha

  • 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



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
# File 'lib/vapi_server_sdk/types/fallback_rime_ai_voice.rb', line 64

def initialize(voice_id:, caching_enabled: OMIT, model: OMIT, speed: OMIT, pause_between_brackets: OMIT,
               phonemize_between_brackets: OMIT, reduce_latency: OMIT, inline_speed_alpha: OMIT, chunk_plan: OMIT, additional_properties: nil)
  @caching_enabled = caching_enabled if caching_enabled != OMIT
  @voice_id = voice_id
  @model = model if model != OMIT
  @speed = speed if speed != OMIT
  @pause_between_brackets = pause_between_brackets if pause_between_brackets != OMIT
  @phonemize_between_brackets = phonemize_between_brackets if phonemize_between_brackets != OMIT
  @reduce_latency = reduce_latency if reduce_latency != OMIT
  @inline_speed_alpha = inline_speed_alpha if inline_speed_alpha != OMIT
  @chunk_plan = chunk_plan if chunk_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "cachingEnabled": caching_enabled,
    "voiceId": voice_id,
    "model": model,
    "speed": speed,
    "pauseBetweenBrackets": pause_between_brackets,
    "phonemizeBetweenBrackets": phonemize_between_brackets,
    "reduceLatency": reduce_latency,
    "inlineSpeedAlpha": inline_speed_alpha,
    "chunkPlan": chunk_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



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

def additional_properties
  @additional_properties
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.



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

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.



36
37
38
# File 'lib/vapi_server_sdk/types/fallback_rime_ai_voice.rb', line 36

def chunk_plan
  @chunk_plan
end

#inline_speed_alphaString (readonly)

Returns This is a string that allows inline speed control using alpha notation. docs.rime.ai/api-reference/endpoint/websockets#param-inline-speed-alpha.

Returns:



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

def inline_speed_alpha
  @inline_speed_alpha
end

#modelVapi::FallbackRimeAiVoiceModel (readonly)

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

Returns:



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

def model
  @model
end

#pause_between_bracketsBoolean (readonly)

Returns This is a flag that controls whether to add slight pauses using angle brackets. Example: “Hi. <200> I’d love to have a conversation with you.” adds a 200ms pause between the first and second sentences.

Returns:

  • (Boolean)

    This is a flag that controls whether to add slight pauses using angle brackets. Example: “Hi. <200> I’d love to have a conversation with you.” adds a 200ms pause between the first and second sentences.



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

def pause_between_brackets
  @pause_between_brackets
end

#phonemize_between_bracketsBoolean (readonly)

Returns This is a flag that controls whether text inside brackets should be phonemized (converted to phonetic pronunciation) - Example: “Vapi::FallbackRimeAiVoice.h’Elh’El.o World” will pronounce “Hello” as expected.

Returns:

  • (Boolean)

    This is a flag that controls whether text inside brackets should be phonemized (converted to phonetic pronunciation) - Example: “Vapi::FallbackRimeAiVoice.h’Elh’El.o World” will pronounce “Hello” as expected.



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

def phonemize_between_brackets
  @phonemize_between_brackets
end

#reduce_latencyBoolean (readonly)

Returns This is a flag that controls whether to optimize for reduced latency in streaming. docs.rime.ai/api-reference/endpoint/websockets#param-reduce-latency.

Returns:



30
31
32
# File 'lib/vapi_server_sdk/types/fallback_rime_ai_voice.rb', line 30

def reduce_latency
  @reduce_latency
end

#speedFloat (readonly)

Returns This is the speed multiplier that will be used.

Returns:

  • (Float)

    This is the speed multiplier that will be used.



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

def speed
  @speed
end

#voice_idVapi::FallbackRimeAiVoiceId (readonly)

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

Returns:



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

def voice_id
  @voice_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::FallbackRimeAiVoice

Deserialize a JSON object to an instance of FallbackRimeAiVoice

Parameters:

  • json_object (String)

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/vapi_server_sdk/types/fallback_rime_ai_voice.rb', line 95

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::FallbackRimeAiVoiceId.from_json(json_object: voice_id)
  end
  model = parsed_json["model"]
  speed = parsed_json["speed"]
  pause_between_brackets = parsed_json["pauseBetweenBrackets"]
  phonemize_between_brackets = parsed_json["phonemizeBetweenBrackets"]
  reduce_latency = parsed_json["reduceLatency"]
  inline_speed_alpha = parsed_json["inlineSpeedAlpha"]
  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(
    caching_enabled: caching_enabled,
    voice_id: voice_id,
    model: model,
    speed: speed,
    pause_between_brackets: pause_between_brackets,
    phonemize_between_brackets: phonemize_between_brackets,
    reduce_latency: reduce_latency,
    inline_speed_alpha: inline_speed_alpha,
    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)


144
145
146
147
148
149
150
151
152
153
154
# File 'lib/vapi_server_sdk/types/fallback_rime_ai_voice.rb', line 144

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::FallbackRimeAiVoiceId.validate_raw(obj: obj.voice_id)
  obj.model&.is_a?(Vapi::FallbackRimeAiVoiceModel) != 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.pause_between_brackets&.is_a?(Boolean) != false || raise("Passed value for field obj.pause_between_brackets is not the expected type, validation failed.")
  obj.phonemize_between_brackets&.is_a?(Boolean) != false || raise("Passed value for field obj.phonemize_between_brackets is not the expected type, validation failed.")
  obj.reduce_latency&.is_a?(Boolean) != false || raise("Passed value for field obj.reduce_latency is not the expected type, validation failed.")
  obj.inline_speed_alpha&.is_a?(String) != false || raise("Passed value for field obj.inline_speed_alpha 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 FallbackRimeAiVoice to a JSON object

Returns:

  • (String)


134
135
136
# File 'lib/vapi_server_sdk/types/fallback_rime_ai_voice.rb', line 134

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