import { type TtsClientParamsInput, type RPCOptions, type TtsResponse, type TextToSpeechStreamClientParams, type TextToSpeechStreamSession, type TextToSpeechStreamResult } from "../../schemas/index"; /** * Fan-out queue that lets multiple consumers iterate the same TTS response * stream independently. Items are retained only until every active subscriber * has consumed them, then trimmed from the queue. * * The source is injected as an `AsyncIterable` so this class can * be unit-tested directly against the real implementation (without mocking * the RPC layer). Production callsites adapt `streamRpc(...)` via * `ttsResponseSource()` below. * * Exported for test use; not part of the public SDK surface. */ export declare class TtsMulticast { private readonly queue; private readonly waiters; private readonly subscriberIndexes; private ended; private fatal; private readonly resolvePumpDone; private readonly rejectPumpDone; readonly done: Promise; constructor(source: AsyncIterable); subscribe(): AsyncGenerator; private notify; private trimConsumed; private unsubscribe; private pump; private drain; } /** * Converts text to speech audio using a loaded TTS model. * * Three modes selected by `params.stream` and `params.sentenceStream`: * * - `stream: false` (default) — collect all PCM samples and resolve once via * `result.buffer` (`Promise`). `bufferStream` is empty. * - `stream: true` — yield PCM samples through `result.bufferStream` * (`AsyncGenerator`) as they arrive. `buffer` resolves to an empty * array. * - `stream: true, sentenceStream: true` — also exposes `result.chunkUpdates` * (`AsyncGenerator`) so callers can mux per-sentence * metadata with the audio. Multiple consumers can iterate the response * independently via the underlying `TtsMulticast`. * * `result.done` resolves to `true` when synthesis completes cleanly, `false` * if the consumer breaks out before the terminal frame, or rejects on a * pipeline error. Awaiting `done` is safe even when no stream is iterated. * * @param params - TTS request parameters (see `TtsClientParamsInput`). * @param options - Optional RPC options (timeout, profiling, force new connection). * @returns A `TextToSpeechStreamResult` with `bufferStream`, `buffer`, `done`, * and (when `sentenceStream: true`) `chunkUpdates`. * @throws {TextToSpeechStreamFailedError} When `sentenceStream: true` is paired * with `stream: false`, or when the underlying RPC stream errors. */ export declare function textToSpeech(params: TtsClientParamsInput, options?: RPCOptions): TextToSpeechStreamResult; /** * Duplex session: write UTF-8 text fragments (e.g. LLM token deltas) via `write`. Each string or * Buffer should be a complete UTF-8 fragment. The worker forwards them to ONNX TTS `runStreaming` * (optional sentence accumulation via request fields). Iterate the session for `TextToSpeechStreamResponse` * lines (PCM in `buffer`, optional `chunkIndex` / `sentenceChunk`) until `done`. */ export declare function textToSpeechStream(params: TextToSpeechStreamClientParams, options?: RPCOptions): Promise; //# sourceMappingURL=text-to-speech.d.ts.map