import * as core from "../../../../core/index.js"; import type * as SarvamAI from "../../../index.js"; export declare namespace TextToSpeechStreamingSocket { interface Args { socket: core.ReconnectingWebSocket; } type Response = SarvamAI.AudioOutput | SarvamAI.EventResponse | SarvamAI.ErrorResponse; type EventHandlers = { open?: () => void; message?: (message: Response) => void; close?: (event: core.CloseEvent) => void; error?: (error: Error) => void; }; } export declare class TextToSpeechStreamingSocket { readonly socket: core.ReconnectingWebSocket; protected readonly eventHandlers: TextToSpeechStreamingSocket.EventHandlers; private handleOpen; private handleMessage; private handleClose; private handleError; constructor(args: TextToSpeechStreamingSocket.Args); /** The current state of the connection; this is one of the readyState constants. */ get readyState(): number; /** * @param event - The event to attach to. * @param callback - The callback to run when the event is triggered. * Usage: * ```typescript * this.on('open', () => { * console.log('The websocket is open'); * }); * ``` */ on(event: T, callback: TextToSpeechStreamingSocket.EventHandlers[T]): void; /** * Configure the connection with various options including output audio codec. * Accepts both formats: * - Flat params: { speaker: "anushka", target_language_code: "hi-IN", ... } * - Wire format: { type: "config", data: { speaker: "anushka", target_language_code: "hi-IN", ... } } */ configureConnection(config: SarvamAI.ConfigureConnection | { target_language_code: SarvamAI.ConfigureConnection.Data.TargetLanguageCode; speaker?: SarvamAI.ConfigureConnection.Data.Speaker; pitch?: number; pace?: number; loudness?: number; speech_sample_rate?: number; enable_preprocessing?: boolean; output_audio_codec?: SarvamAI.ConfigureConnection.Data.OutputAudioCodec; output_audio_bitrate?: SarvamAI.ConfigureConnection.Data.OutputAudioBitrate; min_buffer_size?: number; max_chunk_length?: number; /** The ID of a pronunciation dictionary to apply during synthesis. Only supported by bulbul:v3. */ dict_id?: string; }): void; convert(text: string): void; flush(): void; ping(): void; /** Connect to the websocket and register event handlers. */ connect(): TextToSpeechStreamingSocket; /** Close the websocket and unregister event handlers. */ close(): void; /** Returns a promise that resolves when the websocket is open. */ waitForOpen(): Promise; /** Asserts that the websocket is open. */ private assertSocketIsOpen; /** Send a binary payload to the websocket. */ protected sendBinary(payload: ArrayBufferLike | Blob | ArrayBufferView): void; /** Send a JSON payload to the websocket. */ protected sendJson(payload: SarvamAI.ConfigureConnection | SarvamAI.SendText | SarvamAI.FlushSignal | SarvamAI.PingSignal): void; }