import { MaybeObservable, DeepMaybeObservable, Supportable, ReadonlyObservable } from '@usels/core'; import { ConfigurableWindow } from '../../shared/configurable.mjs'; import '@legendapp/state'; type UseSpeechSynthesisStatus = "init" | "play" | "pause" | "end"; interface UseSpeechSynthesisErrorData { error: string; charIndex: number; elapsedTime: number; } interface UseSpeechSynthesisOptions extends ConfigurableWindow { /** Language for synthesis. Default: "en-US" */ lang?: string; /** Pitch (0-2). Default: 1 */ pitch?: number; /** Rate (0.1-10). Default: 1 */ rate?: number; /** Volume (0-1). Default: 1 */ volume?: number; /** Voice to use */ voice?: SpeechSynthesisVoice; } interface UseSpeechSynthesisReturn extends Supportable { /** Whether speech is currently playing */ isPlaying$: ReadonlyObservable; /** Current status */ status$: ReadonlyObservable; /** Speech error */ error$: ReadonlyObservable; /** Start speaking the text */ speak: () => void; /** Stop speaking */ stop: () => void; /** Toggle speaking */ toggle: (value?: boolean) => void; } /** * Framework-agnostic reactive wrapper around the * [SpeechSynthesis API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis). * * Each `speak()` call constructs a fresh `SpeechSynthesisUtterance` using the * latest text and option values. Cleanup (`speechSynthesis.cancel()`) is * registered via `onUnmount`. */ declare function createSpeechSynthesis(text: MaybeObservable, options?: DeepMaybeObservable): UseSpeechSynthesisReturn; export { type UseSpeechSynthesisErrorData, type UseSpeechSynthesisOptions, type UseSpeechSynthesisReturn, type UseSpeechSynthesisStatus, createSpeechSynthesis };