@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.98 kB
TypeScript
/**
* Transcript correction: dictionary candidates → decision-model guard → LLM
* rewrite.
*
* Every layer fails open and none may lose words. With no decision provider,
* on a guard timeout or error, the dictionary is applied as is; on a rewrite
* timeout or error, or a rewrite that drops too many words, the
* dictionary-applied text is kept. The result's `steps` say which of those
* happened, so a silently degraded path is still visible to the caller.
*
* @module voice/correction
*/
import { applyDictionary, dictionaryBlock, dictionaryVocabulary, findDictionaryCandidates } from "./dictionary.js";
import { decideCandidates } from "./guard.js";
import { buildRewriteSystemPrompt, buildRewriteUserPrompt, rewriteLines, rewriteTranscript } from "./rewrite.js";
import type { STTCorrectionDeps, STTCorrectionInput, STTCorrectionOptions, STTCorrectionOutput, STTDecisionRecord, STTDictionaryEntry } from "../../types/index.js";
export { applyDictionary, buildRewriteSystemPrompt, buildRewriteUserPrompt, decideCandidates, dictionaryBlock, dictionaryVocabulary, findDictionaryCandidates, rewriteLines, rewriteTranscript, };
/** Correction is on when asked for, or by default when a dictionary or a rewrite is configured. */
export declare function isCorrectionEnabled(dictionary: readonly STTDictionaryEntry[] | undefined, options: STTCorrectionOptions | undefined): boolean;
/**
* Correct one transcript (a whole short recording, or one final utterance
* when streaming). Never throws on a layer's failure and never returns empty
* text when either transcript had words.
*
* When the primary engine reported a low language score
* (`languageDetected === false`) and a second opinion exists, the second
* opinion leads: an Indic engine on English speech produces confident-looking
* nonsense, and the English-oriented engine's text is the better base. The
* engine text then goes to the rewrite as the secondary transcript, so
* Indian-language words it did catch are not lost.
*/
export declare function correctTranscript(input: STTCorrectionInput, deps: STTCorrectionDeps): Promise<STTCorrectionOutput>;
/**
* Correct a long transcript line by line (file transcription, diarized
* turns). With the rewrite on, lines go to the model in numbered batches of
* 25 and the dictionary travels in the prompt — the model sees each alias in
* its sentence, which is the context the guard would otherwise supply. With
* `rewrite: false`, each line with candidates gets its own guard call (up to
* four at a time) and the dictionary is applied per line. The result always
* has exactly as many lines as the input.
*/
export declare function correctTranscriptLines(lines: readonly string[], dictionary: readonly STTDictionaryEntry[] | undefined, options: STTCorrectionOptions | undefined, deps: STTCorrectionDeps): Promise<{
lines: string[];
decisions: STTDecisionRecord[];
steps: string[];
timings: STTCorrectionOutput["timings"];
}>;