Class: Vapi::StopSpeakingPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num_words: OMIT, voice_seconds: OMIT, backoff_seconds: OMIT, additional_properties: nil) ⇒ Vapi::StopSpeakingPlan

Parameters:

  • num_words (Float) (defaults to: OMIT)

    This is the number of words that the customer has to say before the assistant will stop talking. Words like "stop", "actually", "no", etc. will always interrupt immediately regardless of this value. Words like "okay", "yeah", "right" will never interrupt. When set to 0, voiceSeconds is used in addition to the transcriptions to determine the customer has started speaking. Defaults to 0. @default 0

  • voice_seconds (Float) (defaults to: OMIT)

    This is the seconds customer has to speak before the assistant stops talking. This uses the VAD (Voice Activity Detection) spike to determine if the customer has started speaking. Considerations:

    • A lower value might be more responsive but could potentially pick up non-speech sounds.
    • A higher value reduces false positives but might slightly delay the detection of speech onset. This is only used if numWords is set to 0. Defaults to 0.2 @default 0.2
  • backoff_seconds (Float) (defaults to: OMIT)

    This is the seconds to wait before the assistant will start talking again after being interrupted. Defaults to 1. @default 1

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 69

def initialize(num_words: OMIT, voice_seconds: OMIT, backoff_seconds: OMIT, additional_properties: nil)
  @num_words = num_words if num_words != OMIT
  @voice_seconds = voice_seconds if voice_seconds != OMIT
  @backoff_seconds = backoff_seconds if backoff_seconds != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "numWords": num_words,
    "voiceSeconds": voice_seconds,
    "backoffSeconds": backoff_seconds
  }.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



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

def additional_properties
  @additional_properties
end

#backoff_secondsFloat (readonly)

Returns This is the seconds to wait before the assistant will start talking again after being interrupted. Defaults to 1. @default 1.

Returns:

  • (Float)

    This is the seconds to wait before the assistant will start talking again after being interrupted. Defaults to 1. @default 1



34
35
36
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 34

def backoff_seconds
  @backoff_seconds
end

#num_wordsFloat (readonly)

Returns This is the number of words that the customer has to say before the assistant will stop talking. Words like "stop", "actually", "no", etc. will always interrupt immediately regardless of this value. Words like "okay", "yeah", "right" will never interrupt. When set to 0, voiceSeconds is used in addition to the transcriptions to determine the customer has started speaking. Defaults to 0. @default 0.

Returns:

  • (Float)

    This is the number of words that the customer has to say before the assistant will stop talking. Words like "stop", "actually", "no", etc. will always interrupt immediately regardless of this value. Words like "okay", "yeah", "right" will never interrupt. When set to 0, voiceSeconds is used in addition to the transcriptions to determine the customer has started speaking. Defaults to 0. @default 0



17
18
19
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 17

def num_words
  @num_words
end

#voice_secondsFloat (readonly)

Returns This is the seconds customer has to speak before the assistant stops talking. This uses the VAD (Voice Activity Detection) spike to determine if the customer has started speaking. Considerations:

  • A lower value might be more responsive but could potentially pick up non-speech sounds.
  • A higher value reduces false positives but might slightly delay the detection of speech onset. This is only used if numWords is set to 0. Defaults to 0.2 @default 0.2.

Returns:

  • (Float)

    This is the seconds customer has to speak before the assistant stops talking. This uses the VAD (Voice Activity Detection) spike to determine if the customer has started speaking. Considerations:

    • A lower value might be more responsive but could potentially pick up non-speech sounds.
    • A higher value reduces false positives but might slightly delay the detection of speech onset. This is only used if numWords is set to 0. Defaults to 0.2 @default 0.2


29
30
31
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 29

def voice_seconds
  @voice_seconds
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::StopSpeakingPlan

Deserialize a JSON object to an instance of StopSpeakingPlan

Parameters:

  • json_object (String)

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 87

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  num_words = parsed_json["numWords"]
  voice_seconds = parsed_json["voiceSeconds"]
  backoff_seconds = parsed_json["backoffSeconds"]
  new(
    num_words: num_words,
    voice_seconds: voice_seconds,
    backoff_seconds: backoff_seconds,
    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)


114
115
116
117
118
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 114

def self.validate_raw(obj:)
  obj.num_words&.is_a?(Float) != false || raise("Passed value for field obj.num_words is not the expected type, validation failed.")
  obj.voice_seconds&.is_a?(Float) != false || raise("Passed value for field obj.voice_seconds is not the expected type, validation failed.")
  obj.backoff_seconds&.is_a?(Float) != false || raise("Passed value for field obj.backoff_seconds is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of StopSpeakingPlan to a JSON object

Returns:

  • (String)


104
105
106
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 104

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