Class: Vapi::CustomTranscriber
- Inherits:
-
Object
- Object
- Vapi::CustomTranscriber
- Defined in:
- lib/vapi_server_sdk/types/custom_transcriber.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#server ⇒ Vapi::Server
readonly
This is where the transcription request will be sent.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::CustomTranscriber
Deserialize a JSON object to an instance of CustomTranscriber.
-
.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.
Instance Method Summary collapse
- #initialize(server:, additional_properties: nil) ⇒ Vapi::CustomTranscriber constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CustomTranscriber to a JSON object.
Constructor Details
#initialize(server:, additional_properties: nil) ⇒ Vapi::CustomTranscriber
86 87 88 89 90 |
# File 'lib/vapi_server_sdk/types/custom_transcriber.rb', line 86 def initialize(server:, additional_properties: nil) @server = server @additional_properties = additional_properties @_field_set = { "server": server } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
44 45 46 |
# File 'lib/vapi_server_sdk/types/custom_transcriber.rb', line 44 def additional_properties @additional_properties end |
#server ⇒ Vapi::Server (readonly)
Returns This is where the transcription request will be sent. Usage:
- Vapi will initiate a websocket connection with
server.url. - Vapi will send an initial text frame with the sample rate. Format:
{
"type": "start",
"encoding": "linear16", // 16-bit raw PCM format
"container": "raw",
"sampleRate": {{sampleRate}},
"channels": 2 // customer is channel 0, assistant is channel 1
}
- Vapi will send the audio data in 16-bit raw PCM format as binary frames.
- You can read the messages something like this:
ws.on('message', (data, isBinary) => {
if (isBinary) {
pcmBuffer = Buffer.concat([pcmBuffer, data]);
console.log(`Received PCM data, buffer size: ${pcmBuffer.length}`);
} else {
console.log('Received message:', JSON.parse(data.toString()));
}
});
- You will respond with transcriptions as you have them. Format:
{
"type": "transcriber-response",
"transcription": "Hello, world!",
"channel": "customer" | "assistant"
}
```.
42 43 44 |
# File 'lib/vapi_server_sdk/types/custom_transcriber.rb', line 42 def server @server end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::CustomTranscriber
Deserialize a JSON object to an instance of CustomTranscriber
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/vapi_server_sdk/types/custom_transcriber.rb', line 96 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["server"].nil? server = nil else server = parsed_json["server"].to_json server = Vapi::Server.from_json(json_object: server) end new(server: server, 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.
121 122 123 |
# File 'lib/vapi_server_sdk/types/custom_transcriber.rb', line 121 def self.validate_raw(obj:) Vapi::Server.validate_raw(obj: obj.server) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CustomTranscriber to a JSON object
111 112 113 |
# File 'lib/vapi_server_sdk/types/custom_transcriber.rb', line 111 def to_json(*_args) @_field_set&.to_json end |