Scenario globals

Top-level functions and type aliases available in every VoxEngine scenario.

View as Markdown

Functions

base64_decode

Decodes the data in the Base64 encoding

base64_decode(data: string): number[]

Parameters

data
stringRequired

base64_encode

Encodes a string or array of integers from 0 to 255 to the Base64 encoding

base64_encode(data: string | number[]): string

Parameters

data
string | number[]Required

bytes2hex

Creates a hex string from given bytes array.

bytes2hex(data: number[], toUpperCase: boolean): string

Parameters

data
number[]Required
toUpperCase
booleanRequired

bytes2str

Creates a string from an array of numbers with specified encoding

bytes2str(data: number[], encoding: string): string

Parameters

data
number[]Required
encoding
stringRequired

clearInterval

Cancels a timed, repeating action which is previously established by a call to setInterval().

clearInterval(intervalID: number): void

Parameters

intervalID
numberRequired

clearTimeout

Cancels a timeout previously established by calling setTimeout().

clearTimeout(timeoutID: number): void

Parameters

timeoutID
numberRequired

getLocalTime

Converts the date to the specified local timezone. Note that new Date() always returns time in the UTC+0 timezone.

getLocalTime(timezone: string, date: Date): Date

Parameters

timezone
stringRequired
date
DateRequired

hex2bytes

Creates an array of numbers from parsing a hex string

hex2bytes(data: string): number[]

Parameters

data
stringRequired

levenshtein_distance

Count the number of deletions, insertions, or substitutions required to transform str1 into str2. The number shows a measure of the similarity between two strings. It is also known as edit distance.

levenshtein_distance(str1: string, str2: string): number

Parameters

str1
stringRequired
str2
stringRequired

require

require(module: Modules): void

Parameters

module
ModulesRequired

setInterval

Repeatedly calls a function or executes a code snippet, with a fixed time delay between each call.

setInterval(callback: () => any, timeout?: number): number

Parameters

callback
() => anyRequired
timeout
number

setTimeout

Sets a timer which executes a function or specified piece of code once after the timer expires.

setTimeout(callback: () => any, timeout?: number): number

Parameters

callback
() => anyRequired
timeout
number

str2bytes

Creates an array of numbers from parsing string in specified codepage

str2bytes(data: string, encoding: string): number[]

Parameters

data
stringRequired
encoding
stringRequired

trace

trace(data: string): void

Parameters

data
stringRequired

uuidgen

Generates unique identifier and returns it is string representation.

uuidgen(): string

Type aliases

PlaybackParameters

Avatar voice channel playback parameters. Can be passed via the VoiceChannelParameters.playback parameter.

type PlaybackParameters = TTSPlaybackParameters | URLPlaybackParameters | SequencePlaybackParameters

RecorderLayoutPriority

An object that specifies video frame layout priority. Can be passed via the CallRecordParameters.videoParameters and RecorderParameters.videoParameters parameter. Add the following line to your scenario code to use the type:

require(Modules.Recorder);
type RecorderLayoutPriority = 'vad' | string[]

SequencePlaybackSegment

Sequence of the voice channel TTS and URL playback segments. Can be passed via the SequencePlaybackParameters.segments parameter.

type SequencePlaybackSegment = TTSPlaybackParameters | URLPlaybackParameters

SequencePlayerSegment

Sequence player segment, represented by TTS or URL Player. Can be passed via the SequencePlayerParameters.segments parameter.

type SequencePlayerSegment = TTSPlayerSegment | URLPlayerSegment

SmartQueue

Represents an instance of a Smart Queue. Queue identifier or queue name must be provided.

type SmartQueue = {
/**
* Queue's identification number.
*/
id: number;
/**
* Queue's name.
*/
name?: string;
} | {
/**
* Queue's identification number.
*/
id?: number;
/**
* Queue's name.
*/
name: string;
}

VoxMediaUnit

type VoxMediaUnit = Call | Player | SequencePlayer | ASR | Conference | Recorder | WebSocket | StreamingAgent | Gemini.LiveAPIClient | OpenAI.Beta.RealtimeAPIClient | OpenAI.RealtimeAPIClient | ElevenLabs.AgentsClient | Ultravox.WebSocketAPIClient | Cartesia.AgentsClient | Deepgram.VoiceAgentClient | XAI.VoiceAgentAPIClient | Silero.VAD | Pipecat.TurnDetector | DeepFilterNet.NoiseSuppression | Hush.NoiseSuppression