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, acknowledgement_phrases: OMIT, interruption_phrases: 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

  • acknowledgement_phrases (Array<String>) (defaults to: OMIT)

    These are the phrases that will never interrupt the assistant, even if numWords threshold is met. These are typically acknowledgement or backchanneling phrases.

  • interruption_phrases (Array<String>) (defaults to: OMIT)

    These are the phrases that will always interrupt the assistant immediately, regardless of numWords. These are typically phrases indicating disagreement or desire to stop.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(num_words: OMIT, voice_seconds: OMIT, backoff_seconds: OMIT, acknowledgement_phrases: OMIT,
               interruption_phrases: 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
  @acknowledgement_phrases = acknowledgement_phrases if acknowledgement_phrases != OMIT
  @interruption_phrases = interruption_phrases if interruption_phrases != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "numWords": num_words,
    "voiceSeconds": voice_seconds,
    "backoffSeconds": backoff_seconds,
    "acknowledgementPhrases": acknowledgement_phrases,
    "interruptionPhrases": interruption_phrases
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#acknowledgement_phrasesArray<String> (readonly)

Returns These are the phrases that will never interrupt the assistant, even if numWords threshold is met. These are typically acknowledgement or backchanneling phrases.

Returns:

  • (Array<String>)

    These are the phrases that will never interrupt the assistant, even if numWords threshold is met. These are typically acknowledgement or backchanneling phrases.



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

def acknowledgement_phrases
  @acknowledgement_phrases
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



44
45
46
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 44

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

#interruption_phrasesArray<String> (readonly)

Returns These are the phrases that will always interrupt the assistant immediately, regardless of numWords. These are typically phrases indicating disagreement or desire to stop.

Returns:

  • (Array<String>)

    These are the phrases that will always interrupt the assistant immediately, regardless of numWords. These are typically phrases indicating disagreement or desire to stop.



42
43
44
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 42

def interruption_phrases
  @interruption_phrases
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:



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 106

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"]
  acknowledgement_phrases = parsed_json["acknowledgementPhrases"]
  interruption_phrases = parsed_json["interruptionPhrases"]
  new(
    num_words: num_words,
    voice_seconds: voice_seconds,
    backoff_seconds: backoff_seconds,
    acknowledgement_phrases: acknowledgement_phrases,
    interruption_phrases: interruption_phrases,
    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)


137
138
139
140
141
142
143
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 137

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.")
  obj.acknowledgement_phrases&.is_a?(Array) != false || raise("Passed value for field obj.acknowledgement_phrases is not the expected type, validation failed.")
  obj.interruption_phrases&.is_a?(Array) != false || raise("Passed value for field obj.interruption_phrases 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)


127
128
129
# File 'lib/vapi_server_sdk/types/stop_speaking_plan.rb', line 127

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