import type { StreamingPlayback } from "../platform.js"; /** A running utterance started by `VoxShot.play()`. */ export interface SpeechPlayback { /** Resolves when playback finished or was stopped; rejects on error. */ readonly done: Promise; /** Stop playing and discard everything, including unsynthesized chunks. */ stop(): Promise; /** Jump past the chunk that is currently audible. */ skip(): Promise; /** Playback gain. Applied immediately, also mid-utterance. */ setVolume(volume: number): void; } export interface SpeechPlaybackInput { /** Text chunks in speaking order. */ chunks: readonly string[]; /** * Render one chunk. Called with a one-chunk lookahead. * * `signal` aborts when playback stops. Honouring it matters because the * engine serialises renders: a lookahead nobody is waiting for still holds * the single execution slot until it finishes (#67). */ synthesize(chunk: string, signal: AbortSignal): Promise; /** Open the output stream. Called once, lazily. */ open(): Promise; /** Initial gain. */ volume?: number; /** * Stops playback when it aborts, exactly as {@link SpeechPlayback.stop} * would. * * Held here rather than by the caller so the subscription can be dropped the * moment the utterance ends. A page-lifetime signal — one stop button — would * otherwise collect a listener per utterance, each holding a finished * playback. Watching `done` from outside would do it too, but attaching a * handler marks its rejection as handled, and a caller who never reads `done` * would stop hearing about failures purely because they passed a signal. */ signal?: AbortSignal; } /** * Drive a chunked utterance through a {@link StreamingPlayback}. * * While chunk *n* is playing, chunk *n + 1* is being synthesized — exactly one * chunk of lookahead, so stopping wastes at most one render and memory stays * bounded. Device backpressure comes from `write()`, which resolves when the * stream wants the next chunk. */ export declare function startSpeechPlayback(input: SpeechPlaybackInput): SpeechPlayback; //# sourceMappingURL=speech-playback.d.ts.map