@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
48 lines (47 loc) • 2.38 kB
TypeScript
/**
* Batch transcription orchestration behind `neurolink.transcribe()`:
*
* load audio → resolve provider → transcribe (+ second opinion in parallel)
* → fallback → correction → TranscribeResult
*
* Everything that touches the SDK (handlers, credentials, `tryDecide`, the
* rewrite model) arrives through `TranscribeDeps`, so this module stays free
* of provider plumbing. Nothing here may lose words: a failed second opinion
* or fallback keeps the primary text, and a correction that comes back empty
* keeps the engine text.
*
* @module voice/transcribe
*/
import type { STTOptions, TranscribeAudioInput, TranscribeDeps, TranscribeOptions, TranscribeResult, TTSAudioFormat } from "../types/index.js";
/** The container a path or URL names by its extension, if it is a known one. */
export declare function audioFormatFromName(name: string): TTSAudioFormat | undefined;
/**
* The container a buffer's leading bytes identify: WAV, MP3 and Ogg via the
* shared detector, plus FLAC, WebM/Matroska and ISO-BMFF (m4a/mp4).
*/
export declare function audioFormatFromBytes(buffer: Buffer): TTSAudioFormat | undefined;
/**
* Read a batch audio input into a Buffer: bytes as they are, a local path or
* `file://` URL from disk, an `http(s)://` URL over the network. A format
* implied by the path or URL is returned alongside.
*
* @throws STTError when the input is a frame stream, or cannot be read
*/
export declare function loadTranscribeAudio(input: TranscribeAudioInput, timeoutMs?: number): Promise<{
buffer: Buffer;
formatHint?: TTSAudioFormat;
}>;
/**
* The handler options for one engine. Fields only the orchestration reads
* (dictionary, correction, fallback, streaming, credentials) are dropped;
* the correction context rides along in the prompt for engines that take one.
*/
export declare function buildEngineOptions(options: Omit<TranscribeOptions, "audio">, format: TTSAudioFormat | undefined, model: string | undefined): STTOptions;
/**
* Transcribe one recording with every configured layer. See the module
* comment for the order of operations.
*
* @throws STTError when the audio cannot be loaded, the provider is unknown,
* or the primary engine fails with no fallback that covers errors
*/
export declare function runTranscribe(options: TranscribeOptions, deps: TranscribeDeps): Promise<TranscribeResult>;