Class: Vapi::DeepgramTranscriber

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model: OMIT, language: OMIT, smart_format: OMIT, mip_opt_out: OMIT, numerals: OMIT, confidence_threshold: OMIT, keywords: OMIT, keyterm: OMIT, endpointing: OMIT, fallback_plan: OMIT, additional_properties: nil) ⇒ Vapi::DeepgramTranscriber

Parameters:

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

    This is the Deepgram model that will be used. A list of models can be found here: developers.deepgram.com/docs/models-languages-overview

  • language (Vapi::DeepgramTranscriberLanguage) (defaults to: OMIT)

    This is the language that will be set for the transcription. The list of languages Deepgram supports can be found here: developers.deepgram.com/docs/models-languages-overview

  • smart_format (Boolean) (defaults to: OMIT)

    This will be use smart format option provided by Deepgram. It’s default disabled because it can sometimes format numbers as times but it’s getting better.

  • mip_opt_out (Boolean) (defaults to: OMIT)

    If set to true, this will add mip_opt_out=true as a query parameter of all API requests. See gram.com/docs/the-deepgram-model-improvement-partnership-program#want-to-opt-out This will only be used if you are using your own Deepgram API key. @default false

  • numerals (Boolean) (defaults to: OMIT)

    If set to true, this will cause deepgram to convert spoken numbers to literal numerals. For example, “my phone number is nine-seven-two…” would become “my phone number is 972…” @default false

  • confidence_threshold (Float) (defaults to: OMIT)

    Transcripts below this confidence threshold will be discarded. @default 0.4

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

    These keywords are passed to the transcription model to help it pick up use-case specific words. Anything that may not be a common word, like your company name, should be added here.

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

    Keyterm Prompting allows you improve Keyword Recall Rate (KRR) for important keyterms or phrases up to 90%.

  • endpointing (Float) (defaults to: OMIT)

    This is the timeout after which Deepgram will send transcription on user silence. You can read in-depth documentation here: developers.deepgram.com/docs/endpointing. Here are the most important bits:

    • Defaults to 10. This is recommended for most use cases to optimize for

    latency.

    • 10 can cause some missing transcriptions since because of the shorter context.

    This mostly happens for one-word utterances. For those uses cases, it’s recommended to try 300. It will add a bit of latency but the quality and reliability of the experience will be better.

    solution. @default 10

  • fallback_plan (Vapi::FallbackTranscriberPlan) (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



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 107

def initialize(model: OMIT, language: OMIT, smart_format: OMIT, mip_opt_out: OMIT, numerals: OMIT,
               confidence_threshold: OMIT, keywords: OMIT, keyterm: OMIT, endpointing: OMIT, fallback_plan: OMIT, additional_properties: nil)
  @model = model if model != OMIT
  @language = language if language != OMIT
  @smart_format = smart_format if smart_format != OMIT
  @mip_opt_out = mip_opt_out if mip_opt_out != OMIT
  @numerals = numerals if numerals != OMIT
  @confidence_threshold = confidence_threshold if confidence_threshold != OMIT
  @keywords = keywords if keywords != OMIT
  @keyterm = keyterm if keyterm != OMIT
  @endpointing = endpointing if endpointing != OMIT
  @fallback_plan = fallback_plan if fallback_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "model": model,
    "language": language,
    "smartFormat": smart_format,
    "mipOptOut": mip_opt_out,
    "numerals": numerals,
    "confidenceThreshold": confidence_threshold,
    "keywords": keywords,
    "keyterm": keyterm,
    "endpointing": endpointing,
    "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



60
61
62
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 60

def additional_properties
  @additional_properties
end

#confidence_thresholdFloat (readonly)

Returns Transcripts below this confidence threshold will be discarded. @default 0.4.

Returns:

  • (Float)

    Transcripts below this confidence threshold will be discarded. @default 0.4



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

def confidence_threshold
  @confidence_threshold
end

#endpointingFloat (readonly)

Returns This is the timeout after which Deepgram will send transcription on user silence. You can read in-depth documentation here: developers.deepgram.com/docs/endpointing. Here are the most important bits:

  • Defaults to 10. This is recommended for most use cases to optimize for

latency.

  • 10 can cause some missing transcriptions since because of the shorter context.

This mostly happens for one-word utterances. For those uses cases, it’s recommended to try 300. It will add a bit of latency but the quality and reliability of the experience will be better.

solution. @default 10.

Returns:

  • (Float)

    This is the timeout after which Deepgram will send transcription on user silence. You can read in-depth documentation here: developers.deepgram.com/docs/endpointing. Here are the most important bits:

    • Defaults to 10. This is recommended for most use cases to optimize for

    latency.

    • 10 can cause some missing transcriptions since because of the shorter context.

    This mostly happens for one-word utterances. For those uses cases, it’s recommended to try 300. It will add a bit of latency but the quality and reliability of the experience will be better.

    solution. @default 10



55
56
57
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 55

def endpointing
  @endpointing
end

#fallback_planVapi::FallbackTranscriberPlan (readonly)

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

Returns:



58
59
60
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 58

def fallback_plan
  @fallback_plan
end

#keytermArray<String> (readonly)

Returns Keyterm Prompting allows you improve Keyword Recall Rate (KRR) for important keyterms or phrases up to 90%.

Returns:

  • (Array<String>)

    Keyterm Prompting allows you improve Keyword Recall Rate (KRR) for important keyterms or phrases up to 90%.



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

def keyterm
  @keyterm
end

#keywordsArray<String> (readonly)

Returns These keywords are passed to the transcription model to help it pick up use-case specific words. Anything that may not be a common word, like your company name, should be added here.

Returns:

  • (Array<String>)

    These keywords are passed to the transcription model to help it pick up use-case specific words. Anything that may not be a common word, like your company name, should be added here.



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

def keywords
  @keywords
end

#languageVapi::DeepgramTranscriberLanguage (readonly)

Returns This is the language that will be set for the transcription. The list of languages Deepgram supports can be found here: developers.deepgram.com/docs/models-languages-overview.

Returns:



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

def language
  @language
end

#mip_opt_outBoolean (readonly)

Returns If set to true, this will add mip_opt_out=true as a query parameter of all API requests. See gram.com/docs/the-deepgram-model-improvement-partnership-program#want-to-opt-out This will only be used if you are using your own Deepgram API key. @default false.

Returns:

  • (Boolean)

    If set to true, this will add mip_opt_out=true as a query parameter of all API requests. See gram.com/docs/the-deepgram-model-improvement-partnership-program#want-to-opt-out This will only be used if you are using your own Deepgram API key. @default false



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

def mip_opt_out
  @mip_opt_out
end

#modelVapi::DeepgramTranscriberModel (readonly)

Returns This is the Deepgram model that will be used. A list of models can be found here: developers.deepgram.com/docs/models-languages-overview.

Returns:



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

def model
  @model
end

#numeralsBoolean (readonly)

Returns If set to true, this will cause deepgram to convert spoken numbers to literal numerals. For example, “my phone number is nine-seven-two…” would become “my phone number is 972…” @default false.

Returns:

  • (Boolean)

    If set to true, this will cause deepgram to convert spoken numbers to literal numerals. For example, “my phone number is nine-seven-two…” would become “my phone number is 972…” @default false



31
32
33
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 31

def numerals
  @numerals
end

#smart_formatBoolean (readonly)

Returns This will be use smart format option provided by Deepgram. It’s default disabled because it can sometimes format numbers as times but it’s getting better.

Returns:

  • (Boolean)

    This will be use smart format option provided by Deepgram. It’s default disabled because it can sometimes format numbers as times but it’s getting better.



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

def smart_format
  @smart_format
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::DeepgramTranscriber

Deserialize a JSON object to an instance of DeepgramTranscriber

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  model = parsed_json["model"]
  language = parsed_json["language"]
  smart_format = parsed_json["smartFormat"]
  mip_opt_out = parsed_json["mipOptOut"]
  numerals = parsed_json["numerals"]
  confidence_threshold = parsed_json["confidenceThreshold"]
  keywords = parsed_json["keywords"]
  keyterm = parsed_json["keyterm"]
  endpointing = parsed_json["endpointing"]
  if parsed_json["fallbackPlan"].nil?
    fallback_plan = nil
  else
    fallback_plan = parsed_json["fallbackPlan"].to_json
    fallback_plan = Vapi::FallbackTranscriberPlan.from_json(json_object: fallback_plan)
  end
  new(
    model: model,
    language: language,
    smart_format: smart_format,
    mip_opt_out: mip_opt_out,
    numerals: numerals,
    confidence_threshold: confidence_threshold,
    keywords: keywords,
    keyterm: keyterm,
    endpointing: endpointing,
    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)


186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 186

def self.validate_raw(obj:)
  obj.model&.is_a?(Vapi::DeepgramTranscriberModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.")
  obj.language&.is_a?(Vapi::DeepgramTranscriberLanguage) != false || raise("Passed value for field obj.language is not the expected type, validation failed.")
  obj.smart_format&.is_a?(Boolean) != false || raise("Passed value for field obj.smart_format is not the expected type, validation failed.")
  obj.mip_opt_out&.is_a?(Boolean) != false || raise("Passed value for field obj.mip_opt_out is not the expected type, validation failed.")
  obj.numerals&.is_a?(Boolean) != false || raise("Passed value for field obj.numerals is not the expected type, validation failed.")
  obj.confidence_threshold&.is_a?(Float) != false || raise("Passed value for field obj.confidence_threshold is not the expected type, validation failed.")
  obj.keywords&.is_a?(Array) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.")
  obj.keyterm&.is_a?(Array) != false || raise("Passed value for field obj.keyterm is not the expected type, validation failed.")
  obj.endpointing&.is_a?(Float) != false || raise("Passed value for field obj.endpointing is not the expected type, validation failed.")
  obj.fallback_plan.nil? || Vapi::FallbackTranscriberPlan.validate_raw(obj: obj.fallback_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of DeepgramTranscriber to a JSON object

Returns:

  • (String)


176
177
178
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 176

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