import { DebugOption } from '../../logger/types.js'; import { TTSAdapter } from './adapter.js'; import { StreamChunk, TTSResult } from '../../types.js'; /** The adapter kind this activity handles */ export declare const kind: "tts"; /** * Extract provider options from a TTSAdapter via ~types. */ export type TTSProviderOptions = TAdapter extends TTSAdapter ? TAdapter['~types']['providerOptions'] : object; /** * Options for the TTS activity. * The model is extracted from the adapter's model property. * * @template TAdapter - The TTS adapter type * @template TStream - Whether to stream the output */ export interface TTSActivityOptions>, TStream extends boolean = false> { /** The TTS adapter to use (must be created with a model) */ adapter: TAdapter & { kind: typeof kind; }; /** The text to convert to speech */ text: string; /** The voice to use for generation */ voice?: string; /** The output audio format */ format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm'; /** The speed of the generated audio (0.25 to 4.0) */ speed?: number; /** Provider-specific options for TTS generation */ modelOptions?: TTSProviderOptions; /** * Whether to stream the generation result. * When true, returns an AsyncIterable for streaming transport. * When false or not provided, returns a Promise. * * @default false */ stream?: TStream; /** * Enable debug logging. Pass `true` to enable all categories, `false` to * silence everything including errors, or a `DebugConfig` object for granular * control and/or a custom `Logger`. */ debug?: DebugOption; } /** * Result type for the TTS activity. * - If stream is true: AsyncIterable * - Otherwise: Promise */ export type TTSActivityResult = TStream extends true ? AsyncIterable : Promise; /** * TTS activity - generates speech from text. * * Uses AI text-to-speech models to create audio from natural language text. * * @example Generate speech from text * ```ts * import { generateSpeech } from '@tanstack/ai' * import { openaiSpeech } from '@tanstack/ai-openai' * * const result = await generateSpeech({ * adapter: openaiSpeech('tts-1-hd'), * text: 'Hello, welcome to TanStack AI!', * voice: 'nova' * }) * * console.log(result.audio) // base64-encoded audio * ``` * * @example With format and speed options * ```ts * const result = await generateSpeech({ * adapter: openaiSpeech('tts-1'), * text: 'This is slower speech.', * voice: 'alloy', * format: 'wav', * speed: 0.8 * }) * ``` */ export declare function generateSpeech>, TStream extends boolean = false>(options: TTSActivityOptions): TTSActivityResult; /** * Create typed options for the generateSpeech() function without executing. */ export declare function createSpeechOptions>, TStream extends boolean = false>(options: TTSActivityOptions): TTSActivityOptions; export type { TTSAdapter, TTSAdapterConfig, AnyTTSAdapter } from './adapter.js'; export { BaseTTSAdapter } from './adapter.js';