/** * Lightweight wrapper around the Web Speech Synthesis API. * * This utility centralizes speaking simple, short prompts with sane defaults and * consistent behavior (always cancel any ongoing speech before speaking next). * * Environment * - Requires a browser environment with `window.speechSynthesis` support. * - Will throw at construction time if the API is unavailable. * * Defaults * - Language: auto-detected from the browser locale (configurable via constructor) * - Rate: 1.0, Pitch: 1.0, Volume: 1.0 * * Notes * - The constructor primes the synthesizer by issuing an empty utterance. This * can help some engines load voices before the first real `speak()` call. * * Example * ```ts * const speaker = new SpeechSynthesizer() // auto-detects language from the browser * speaker.speak('Stand upright') * // later * speaker.cancel() // stop any in-progress speech * ``` */ export declare class SpeechSynthesizer { private language; private voice; private readonly isMobile; private readonly onVoicesChanged; /** * Create a SpeechSynthesizer with an optional preferred BCP 47 language tag. * If not provided, language is auto-detected from the browser locale. * * @throws Error if the Speech Synthesis API is not supported by the browser. */ constructor(); /** * Speak the provided text. * * Cancels any ongoing speech before speaking to avoid overlapping prompts. * * @param text - The text to synthesize. */ speak(text: string): void; /** * Cancel any ongoing speech immediately. */ cancel(): void; /** * Build a configured SpeechSynthesisUtterance with default parameters. */ private utterance; /** * Select the best matching voice for the current language. */ private selectBestVoice; /** * Map base language codes to region-specific tags for mobile voice selection. */ private normalizeLanguageForMobile; }