@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
42 lines (41 loc) • 1.97 kB
TypeScript
/**
* Text preparation for speech synthesis.
*
* Model output is written for a screen: markdown structure, URLs, emoji.
* Read aloud, every one of those is noise — "asterisk asterisk", a 90-character
* URL spelled letter by letter, "grinning face with smiling eyes". This module
* rewrites such text into what a voice should actually say.
*
* Every regular expression here is linear-time by construction: no nested
* quantifiers, no lazy scan to a closing token, and no unbounded greedy class
* followed by a required literal (the `[ \t]+\n` shape that goes quadratic on
* a long run of spaces). Where a closing token is required, the scan between
* the two is bounded AND excludes the opener's own character, so an unclosed
* opener fails at the next opener rather than walking the bound — a run of
* `[` costs one step per character, not one thousand. Block-level structure
* (fenced code, lists, tables, headings, blockquotes) is a line pass that
* toggles state, so an unterminated fence costs one scan rather than a
* backtracking search.
*
* @module utils/speechText
*/
import type { SpeechSanitizeOptions } from "../types/index.js";
/**
* Resolve a `TTSOptions.sanitize` value into options, or `undefined` when the
* pass is off. `true` means the defaults; an object tunes them.
*/
export declare function resolveSpeechSanitizeOptions(sanitize: boolean | SpeechSanitizeOptions | undefined): SpeechSanitizeOptions | undefined;
/**
* Rewrite `text` into what a TTS voice should say.
*
* Pure and deterministic: the same input and options always yield the same
* output, and nothing here reads the environment. Runs in time linear in the
* length of `text`.
*
* @example
* ```typescript
* prepareTextForSpeech("## Title\n\nSee **this** at https://docs.example.com/x 🎉");
* // → "Title\n\nSee this at docs.example.com"
* ```
*/
export declare function prepareTextForSpeech(text: string, opts?: SpeechSanitizeOptions): string;