import { HostedSpeechEngine } from './hostedTtsSpeechEngine'; import { SpeechEngine } from './types'; export interface SpeechEngineConfig { /** Our proxy's URL. Empty/undefined keeps the device engine. */ endpoint?: string | null; getHeaders?: () => Record; fetchImpl?: typeof fetch; } /** * Point the assistant at a hosted TTS proxy. * * Called by the host shell's provider, exactly as `configureGeocoder` is. This * is the supported way to turn hosted speech on; the environment variable below * only ever works when this package is run directly (dev / standalone). * * ★ `getHeaders` is not optional in practice, only in the type. The proxy turns * text into audio the org is BILLED for, so an endpoint that accepts anonymous * POSTs is a metered API open to anyone who reads the bundle. The engine has * always supported per-request headers; until now nothing could reach that hook * from the host, which meant the only configuration this function could express * was an unauthenticated one. It is a function rather than a value because * access tokens expire and the engine outlives any one of them — reading a * token once at configure time would work until it rotated and then fail * exactly where it is hardest to notice, mid-reply. * * ★ Several callers may configure, and the LAST `getHeaders` given wins, without * rebuilding the engine. Only a change of ENDPOINT rebuilds it. A call that * repeats the endpoint without `getHeaders` keeps the existing source rather * than silently making every later request anonymous (and refused). */ export declare function configureSpeechEngine(options: { ttsEndpoint?: string | null; getHeaders?: () => Record; }): void; /** * Read the rollout config. * * Order matters: explicit runtime configuration, then a global the host can set * before the bundle loads, and only then the build-time variable — which is * eliminated in the published package and therefore useful for local dev only. */ export declare function readSpeechEngineConfig(): SpeechEngineConfig; /** * The engine to use, or the device engine when hosted TTS is not configured. * * Returns `null` for `hosted` when off, so callers can tell "hosted is not * configured" from "hosted is configured but cannot speak this language". */ export declare function createSpeechEngines(config?: SpeechEngineConfig): { device: SpeechEngine; hosted: HostedSpeechEngine | null; }; export declare function getSpeechEngine(): SpeechEngine; /** * Be told when `getSpeechEngine()` would return a different engine. * * ★★ Without this a panel mounted BEFORE the host configured hosted speech kept * the device engine it read at mount (BOFF-7283): `AssistantSpeechProvider` * read the engine as a default prop, so it only noticed the change if something * else happened to re-render it — and until then spoke with the device voice. * The provider subscribes through `useSyncExternalStore`. */ export declare function subscribeSpeechEngine(listener: () => void): () => void; /** * Drop the singleton so the next call re-reads the config, and tell subscribers. * * ★ The notification is DEFERRED to a microtask. `configureSpeechEngine` is * called during render by the product providers, and a synchronous notify would * update another component while this one is rendering — which React rejects. * Coalesced, so a burst of resets notifies once. */ export declare function resetSpeechEngine(): void; //# sourceMappingURL=createSpeechEngine.d.ts.map