@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
49 lines (48 loc) • 2.67 kB
TypeScript
/**
* OpenAI Realtime transcription protocol over `transcribeStream()`.
*
* A client connects to `/v1/realtime?intent=transcription` and speaks OpenAI's
* Realtime transcription protocol, so the stock LiveKit
* `openai.STT(base_url=…, use_realtime=True)` plugin, Pipecat or the OpenAI
* SDK stream to NeuroLink with no adapter:
*
* - config: `session.update` (`session.type: "transcription"`, audio under
* `session.audio.input`) or the beta `transcription_session.update`;
* - audio: `input_audio_buffer.append` with base64 PCM16 at the declared rate
* (24 kHz for both dialects' default);
* - `input_audio_buffer.commit` closes the open utterance; so does an audio
* gap, since a client that stops sending (a muted mic) sends nothing else.
*
* Each utterance is one conversation item. Its events go out in this order:
* - `input_audio_buffer.speech_started`;
* - `…input_audio_transcription.delta` per newly agreed words. A client
* appends deltas, so only the prefix two passes agreed on is sent; words
* still in flux never reach it;
* - `input_audio_buffer.speech_stopped`, `input_audio_buffer.committed`;
* - `…input_audio_transcription.completed` with the corrected text (or the
* raw final; see `ServerSTTRealtimeProfile.completed`).
*
* Items complete strictly in order: a client keeps one running text, so a
* later utterance's deltas wait until the earlier one has completed.
* NeuroLink's own detail goes out as extra event types a stock client ignores:
* `neurolink.final`, `neurolink.corrected` and `neurolink.output`.
*
* Everything NeuroLink-specific (engine, fallback, dictionary, correction,
* output languages) comes from the profile the client's `model` names; a
* realtime client cannot send it.
*
* @module server/websocket/realtimeTranscription
*/
import type { IncomingMessage } from "node:http";
import type { NeuroLink } from "../../neurolink.js";
import type { ServerRealtimeSocket, ServerSTTRealtimeProfile } from "../../types/index.js";
/**
* Operator profiles: `NEUROLINK_STT_REALTIME_PROFILES` (JSON), overlaid by
* the attach option. An invalid env value is logged and ignored.
*/
export declare function resolveRealtimeProfiles(fromOptions?: Readonly<Record<string, ServerSTTRealtimeProfile>>, env?: NodeJS.ProcessEnv): Readonly<Record<string, ServerSTTRealtimeProfile>>;
/**
* Serve one realtime transcription connection. The upgrade has already
* passed the origin and token checks.
*/
export declare function serveRealtimeTranscription(client: ServerRealtimeSocket, req: IncomingMessage, neurolink: NeuroLink, profiles: Readonly<Record<string, ServerSTTRealtimeProfile>>): void;