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, code_switching_enabled: OMIT, keywords: OMIT, endpointing: 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: https://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: https://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.

  • code_switching_enabled (Boolean) (defaults to: OMIT) —

    This automatically switches the transcriber's language when the customer's language changes. Defaults to false. Usage:

    • If your customers switch languages mid-call, you can set this to true. Note:
    • To detect language changes, Vapi uses a custom trained model. Languages supported (X = limited support):
    1. Arabic
    2. Bengali
    3. Cantonese
    4. Chinese
    5. Chinese Simplified (X)
    6. Chinese Traditional (X)
    7. English
    8. Farsi (X)
    9. French
    10. German
    11. Haitian Creole (X)
    12. Hindi
    13. Italian
    14. Japanese
    15. Korean
    16. Portuguese
    17. Russian
    18. Spanish
    19. Thai
    20. Urdu
    21. Vietnamese
    • To receive language-change-detected webhook events, add it to assistant.serverMessages. @default false
  • 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.

  • 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: https://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.
    • If neither 10 nor 300 work, contact [email protected] and we'll find another solution. @default 10
  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 134

def initialize(model: OMIT, language: OMIT, smart_format: OMIT, code_switching_enabled: OMIT, keywords: OMIT,
               endpointing: OMIT, additional_properties: nil)
  @model = model if model != OMIT
  @language = language if language != OMIT
  @smart_format = smart_format if smart_format != OMIT
  @code_switching_enabled = code_switching_enabled if code_switching_enabled != OMIT
  @keywords = keywords if keywords != OMIT
  @endpointing = endpointing if endpointing != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "model": model,
    "language": language,
    "smartFormat": smart_format,
    "codeSwitchingEnabled": code_switching_enabled,
    "keywords": keywords,
    "endpointing": endpointing
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



71
72
73
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 71

def additional_properties
  @additional_properties
end

#code_switching_enabled ⇒ Boolean (readonly)

Returns This automatically switches the transcriber's language when the customer's language changes. Defaults to false. Usage:

  • If your customers switch languages mid-call, you can set this to true. Note:
  • To detect language changes, Vapi uses a custom trained model. Languages supported (X = limited support):
  1. Arabic
  2. Bengali
  3. Cantonese
  4. Chinese
  5. Chinese Simplified (X)
  6. Chinese Traditional (X)
  7. English
  8. Farsi (X)
  9. French
  10. German
  11. Haitian Creole (X)
  12. Hindi
  13. Italian
  14. Japanese
  15. Korean
  16. Portuguese
  17. Russian
  18. Spanish
  19. Thai
  20. Urdu
  21. Vietnamese
  • To receive language-change-detected webhook events, add it to assistant.serverMessages. @default false.

Returns:

  • (Boolean) —

    This automatically switches the transcriber's language when the customer's language changes. Defaults to false. Usage:

    • If your customers switch languages mid-call, you can set this to true. Note:
    • To detect language changes, Vapi uses a custom trained model. Languages supported (X = limited support):
    1. Arabic
    2. Bengali
    3. Cantonese
    4. Chinese
    5. Chinese Simplified (X)
    6. Chinese Traditional (X)
    7. English
    8. Farsi (X)
    9. French
    10. German
    11. Haitian Creole (X)
    12. Hindi
    13. Italian
    14. Japanese
    15. Korean
    16. Portuguese
    17. Russian
    18. Spanish
    19. Thai
    20. Urdu
    21. Vietnamese
    • To receive language-change-detected webhook events, add it to assistant.serverMessages. @default false


51
52
53
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 51

def code_switching_enabled
  @code_switching_enabled
end

#endpointing ⇒ Float (readonly)

Returns This is the timeout after which Deepgram will send transcription on user silence. You can read in-depth documentation here: https://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.
  • If neither 10 nor 300 work, contact [email protected] and we'll find another 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: https://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.
    • If neither 10 nor 300 work, contact [email protected] and we'll find another solution. @default 10


69
70
71
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 69

def endpointing
  @endpointing
end

#keywords ⇒ Array<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.



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

def keywords
  @keywords
end

#language ⇒ Vapi::DeepgramTranscriberLanguage (readonly)

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

Returns:



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

def language
  @language
end

#model ⇒ Vapi::DeepgramTranscriberModel (readonly)

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

Returns:



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

def model
  @model
end

#smart_format ⇒ Boolean (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.



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

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:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 159

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"]
  code_switching_enabled = parsed_json["codeSwitchingEnabled"]
  keywords = parsed_json["keywords"]
  endpointing = parsed_json["endpointing"]
  new(
    model: model,
    language: language,
    smart_format: smart_format,
    code_switching_enabled: code_switching_enabled,
    keywords: keywords,
    endpointing: endpointing,
    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)


192
193
194
195
196
197
198
199
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 192

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

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of DeepgramTranscriber to a JSON object

Returns:

  • (String)


182
183
184
# File 'lib/vapi_server_sdk/types/deepgram_transcriber.rb', line 182

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