@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
36 lines (35 loc) • 1.58 kB
TypeScript
/**
* Push-driven async iterable shared by the transcription sockets: socket
* frames are pushed in, `transcribeStream()` pulls them out.
*
* The queue reports its level to whoever feeds it, so a socket can be paused
* when audio arrives faster than the engine takes it and resumed once the
* backlog drains (TCP backpressure, instead of buffering the whole burst).
* Every queue also charges its bytes to one process-wide budget, so a burst
* of uploads across many sockets cannot exhaust the process.
*
* @module server/websocket/frameQueue
*/
/** What every queue in the process holds right now, for caps and tests. */
export declare function totalQueuedFrameBytes(): number;
/** Push-driven async iterable: socket frames in, `transcribeStream()` pulls. */
export declare class FrameQueue implements AsyncIterable<Buffer> {
private readonly frames;
private waiting;
private ended;
private onLevel;
queuedBytes: number;
/** Called after every change of `queuedBytes`, with the new level. */
setLevelListener(listener: ((queuedBytes: number) => void) | undefined): void;
push(frame: Buffer): void;
/**
* No more frames will arrive; the ones already queued are still handed
* out, so a recording whose `end` frame followed its audio is transcribed
* whole. The consumer's `return()` (see below) is what discards.
*/
end(): void;
/** The consumer is gone: whatever it did not pull leaves the process budget. */
private discard;
private charge;
[Symbol.asyncIterator](): AsyncIterator<Buffer>;
}