/** * speak-core — orchestrates per-call TTS synthesis through the SpeechProviderPlugin chain. * * Provider invocation goes through `plugin.synthesize` / `plugin.synthesizeStream`. * Streaming consumers (Telegram draft etc.) use `speakStream`; providers without * `synthesizeStream` automatically fall back to `synthesize` wrapped as a * single-chunk ReadableStream (see wrapBufferAsStream). * * Directive overrides are routed via per-provider buckets (`overrides.openai`, * `overrides.minimax`, …). The bucket whose key matches the currently active * provider id wins; cross-provider keys are ignored. * * `cfg: Config` is threaded through `SpeakOptions.appConfig`. The orchestrator * does NOT auto-summarize / preprocess for `speakStream` beyond the same path * as `speak`; streaming is a transport optimization, not a different semantic. */ import type { Config } from '../../config/schema.js'; import { type PreprocessOptions } from './preprocess.js'; import type { TTSConfig, TTSModelOverrideConfig, TTSOptions, TTSProvider, TTSResultWithTracking } from './types.js'; export interface SpeakOptions { tts?: TTSOptions; preprocess?: PreprocessOptions; parseDirectives?: boolean; modelOverrides?: TTSModelOverrideConfig; appConfig?: Config; /** Optional caller-supplied AbortSignal (currently passed through to providers via timeoutMs guard only). */ signal?: AbortSignal; } /** * Run the TTS chain (primary → fallback) and return the first successful result. */ export declare function speak(text: string, config: TTSConfig, options?: SpeakOptions): Promise; /** Single-provider variant; bypasses the fallback chain. */ export declare function speakWithProvider(text: string, config: TTSConfig, providerName: TTSProvider, options?: SpeakOptions): Promise; export interface SpeakStreamResult { /** Audio chunks. Caller is responsible for consuming the stream. */ audioStream: ReadableStream; outputFormat: string; fileExtension: string; voiceCompatible: boolean; /** Provider id that produced this stream. */ provider: TTSProvider; /** Cleanup hook (close sockets etc.). Always defined; no-op when nothing to release. */ release: () => Promise; /** Pre-flight metadata (after directive parse / preprocess / summarize). */ ttsText: string; wasPreprocessed: boolean; wasSummarized: boolean; } /** * Streaming TTS — tries the chain and returns the first provider's stream. * Providers without `synthesizeStream` are wrapped via wrapBufferAsStream. */ export declare function speakStream(text: string, config: TTSConfig, options?: SpeakOptions): Promise;