Global

Methods

(async) addLanguages(room) → {Promise.<void>}

Publishes missing language tracks for all currently active languages and persists the language list to disk.
Parameters:
Name Type Description
room Room Connected LiveKit room instance.
Source:
Returns:
Type
Promise.<void>

(async) createToken(params) → {Promise.<string>}

Creates a LiveKit JWT for a participant.
Parameters:
Name Type Description
params Object Token creation input.
Properties
Name Type Attributes Description
roomName string Target room to join.
username string Participant identity.
metadata string <optional>
Optional participant metadata JSON string.
Source:
Returns:
Signed JWT token.
Type
Promise.<string>

enqueueFrame(language, frame) → {void}

Serializes frame publishing per language and drops frames if queue grows too large.
Parameters:
Name Type Description
language string Target language key for routing.
frame AudioFrame Frame to enqueue for publish.
Source:
Returns:
Type
void

getWriter(filename, frame) → {Object}

Returns (or lazily creates) a WAV writer for a publication name.
Parameters:
Name Type Description
filename string Logical output identifier, usually publication name.
frame Object First frame used to seed WAV header.
Source:
Returns:
Writable stream for PCM data.
Type
Object

(async) main(params) → {Promise.<void>}

Connects the backend bot, manages language track lifecycle, and bridges LiveKit audio with the Python translation child process.
Parameters:
Name Type Description
params Object Startup options.
Source:
Returns:
Type
Promise.<void>

(async) main(params) → {Promise.<void>}

Connects the mock client, subscribes to translated tracks, records incoming audio, and publishes prerecorded source audio.
Parameters:
Name Type Description
params Object Runtime options.
Properties
Name Type Description
roomName string LiveKit room name.
languages Array.<string> Track names to subscribe to.
Source:
Returns:
Type
Promise.<void>

parseWav(buffer) → {Object}

Parses core WAV metadata and finds the PCM data chunk.
Parameters:
Name Type Description
buffer Buffer Full WAV file bytes.
Source:
Throws:
If the file is not PCM WAV or no data chunk is found.
Type
Error
Returns:
Parsed WAV information.
Type
Object

(async) pipeIncomingToSource(inFrame, source, outSampleRateopt, outChannelsopt) → {Promise.<void>}

Normalizes an input frame and forwards it to a published audio source. Converts stereo to mono and linearly resamples when needed.
Parameters:
Name Type Attributes Default Description
inFrame AudioFrame Incoming frame from translator output.
source AudioSource Destination LiveKit audio source.
outSampleRate number <optional>
16000 Target sample rate.
outChannels number <optional>
1 Target channel count.
Source:
Returns:
Type
Promise.<void>

(async) pipePreRecordedToSource(language, source) → {Promise.<void>}

Streams a prerecorded WAV file to a language track.
Parameters:
Name Type Description
language string Target language code used in filename lookup.
source AudioSource Destination LiveKit audio source.
Source:
Returns:
Type
Promise.<void>

(async) publishAudioTrack(params) → {Promise.<AudioSource>}

Creates and publishes an outgoing translation audio track for a language.
Parameters:
Name Type Description
params Object Publish parameters.
Source:
Returns:
Audio source used to push translated frames.
Type
Promise.<AudioSource>

(async) publishTracks(params) → {Promise.<void>}

Publishes prerecorded audio to the room on the `translateAudio` track.
Parameters:
Name Type Description
params Object LiveKit room context.
Source:
Returns:
Type
Promise.<void>

saveFrameToFile(frame, trackToProcess, filename) → {void}

Appends a single audio frame to a WAV file for the given publication.
Parameters:
Name Type Description
frame Object Audio frame from LiveKit stream.
trackToProcess string Track identifier guard; if falsy, frame is ignored.
filename string Output grouping key and file suffix.
Source:
Returns:
Type
void

writeWavHeader(writer, frame) → {void}

Writes a 44-byte PCM WAV header with placeholder sizes.
Parameters:
Name Type Description
writer Object Destination writer.
frame Object Frame metadata used for format fields.
Source:
Returns:
Type
void