import type OpenAI from "openai"; import { type StreamSpeech, type StreamSpeechResult } from "@use-crux/core"; import { type OpenAISpeechExtra, type OpenAISpeechVoice } from "./speech"; /** OpenAI streaming extras; Crux owns the native binary stream mode. */ export type OpenAISpeechStreamExtra = OpenAISpeechExtra; /** Exact completed result of an OpenAI Speech API body stream. */ export type OpenAIStreamSpeechResult = StreamSpeechResult; /** * Genuine OpenAI speech byte stream attached to a bound adapter. * * Append `audio-delta` bytes in sequence order for progressive playback. The * deltas remain provisional and enforcing output-media Safety may retain them * until the assembled final audio passes validation. Every `fullStream` reader * replays one in-memory history; returning from a reader only detaches it, * while `cancel()` aborts the operation. The first published event commits * routing. The final `audio` event and `completion.audio` share one validated * asset, which Crux never persists implicitly. * * @example * ```ts * const result = await openai.streamSpeech({ * model: 'gpt-4o-mini-tts', * text: 'Welcome aboard', * voice: 'alloy', * outputFormat: 'mp3', * }) * * for await (const event of result.fullStream) { * if (event.type === 'audio-delta') player.append(event.data) * } * * const { audio } = await result.completion * ``` */ export type OpenAIStreamSpeech = StreamSpeech; /** Define native OpenAI Speech API response-body streaming mechanics. */ export declare function createOpenAISpeechStreamingOperation(client: OpenAI): import("@use-crux/core/adapter").StreamingOperationDefinition | undefined; guardrails?: readonly import("@use-crux/core").Guardrail[]; safety?: import("@use-crux/core/safety").SafetyTuneOptions; extra?: OpenAISpeechExtra | undefined; }>, { model: string; text: string; voice?: string | OpenAI.Audio.Speech.SpeechCreateParams.ID | undefined; outputFormat?: string; instructions?: string; speed?: number; language?: string; abortSignal?: AbortSignal; timeout?: Readonly<{ totalMs?: number; stepMs?: number; }> | undefined; guardrails?: readonly import("@use-crux/core").Guardrail[]; safety?: import("@use-crux/core/safety").SafetyTuneOptions; extra?: OpenAISpeechExtra | undefined; }, Readonly<{ data: Uint8Array; sequence: number; }>, Readonly<{ raw: Response; audio: Blob; }>, { type: "audio-delta"; data: Uint8Array; mediaType: string; sequence: number; }, import("@use-crux/core/adapter").GenerateSpeechPayload, { kind: "audio"; size: number | undefined; }>;