UNPKG

@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

40 lines (39 loc) • 1.95 kB
/** * Guards on raw engine output, applied before LocalAgreement, the dictionary * and the rewrite ever see a text. They catch the two ways a speech engine * produces words that were never said: * * - a decoding loop ("Same one. Same one. Same one. …" for hundreds of * words), which Qwen3-ASR falls into on long or noisy chunks, and which the * correction layer cannot repair on purpose (removing the repeats would * trip the never-lose-words drop guard); * - a prompt echo, where an engine answers a near-silent chunk with the * vocabulary prompt it was given ("Names and terms used: …"). * * Both are deterministic and cheap, so they run on every pass. * * @module voice/correction/guards */ /** * Collapse runaway repetition: any phrase of 1 to {@link MAX_NGRAM} words that * repeats itself {@link LOOP_MIN_REPEATS} or more times in a row is cut down to * {@link KEEP_REPEATS} occurrences. Returns the text and how many words were * removed; `removed` is 0 when the text was left alone. Spacing between the * surviving words is normalised to single spaces. */ export declare function collapseRepetitions(text: string): { text: string; removed: number; }; /** * True when an engine's output is the prompt it was given, or a subset of * it: every word of the output occurs in `promptTerms` (the vocabulary * terms and the fixed phrasing around them), AND it reads like the prompt * rather than speech — it carries the fixed phrasing, or lists two or more * distinct terms. A speaker who says only "Juspay." said a term; that is * speech and is kept. An output with no words is not an echo; the empty * path handles it. */ export declare function isPromptEcho(text: string, promptTerms: readonly string[]): boolean; /** Share of a text's words that came from a collapsed loop, for a "mostly loop" decision. */ export declare function loopShare(removed: number, originalWordCount: number): number;