@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
56 lines (55 loc) • 2.77 kB
TypeScript
/**
* Transcription sessions: one call, several speakers, every listener in the
* languages they chose.
*
* Each speaker is its own `transcribeStream()` (a call platform gives one
* track per participant). The session's output languages are the union of
* what its listeners read right now, read once per utterance, so ten
* listeners in Spanish cost one rendering and a language nobody reads costs
* nothing. A listener receives the transcript events of the speakers it
* follows and only the `output` events of its own languages.
*
* Late joiners get the backlog: the last `backlog` utterances, with every
* rendering that was made for them. A language added later applies from the
* next utterance on.
*
* @module voice/session/transcriptionSession
*/
import type { NeuroLink } from "../../neurolink.js";
import type { TranscribeStreamOptions, TranscriptionSessionEvent, TranscriptionSessionOptions, TranscriptionSubscriberOptions, TranscriptionSubscription } from "../../types/index.js";
export declare class TranscriptionSession {
private readonly neurolink;
private readonly options;
readonly id: string;
private readonly subscribers;
/** Settled events per `speaker:utterance`, oldest group first. */
private readonly backlog;
private readonly backlogSize;
private readonly maxLanguages;
private readonly speakers;
private _unnamed;
private closed;
constructor(neurolink: Pick<NeuroLink, "transcribeStream">, options?: TranscriptionSessionOptions);
/** The output languages listeners read now, in order of first request, capped. */
languages(): string[];
/** Speakers whose audio is being transcribed now. */
activeSpeakers(): string[];
get listenerCount(): number;
get isClosed(): boolean;
/** A fallback name no speaker in this session holds (a counter, so a leaver's name is not reused). */
private _unnamedSpeaker;
/**
* Transcribe one speaker until its audio ends (or the session closes).
* Every event goes to the session's listeners; `onEvent`, when given, sees
* them too (the speaker's own captions). The speaker's own
* `output.languages`, if any, are rendered in addition to the listeners'.
*/
addSpeaker(speaker: string, options: TranscribeStreamOptions, onEvent?: (event: TranscriptionSessionEvent) => void): Promise<void>;
/** Follow the session. With `backlog` (the default), the last utterances are replayed first. */
subscribe(options: TranscriptionSubscriberOptions, onEvent: (event: TranscriptionSessionEvent) => void): TranscriptionSubscription;
/** Stop delivering; speakers' streams end at their next event. */
close(): void;
private remember;
private broadcast;
private safeDeliver;
}