/**
 * This file was auto-generated by Fern from our API Definition.
 */
import * as core from "../../../../core/index.js";
import * as Respeecher from "../../../index.js";
export declare namespace TtsSocket {
    interface Args {
        socket: core.ReconnectingWebSocket;
    }
    type Response = Respeecher.tts.Response;
    type EventHandlers = {
        open?: () => void;
        message?: (message: Response) => void;
        close?: (event: core.CloseEvent) => void;
        error?: (error: Error) => void;
    };
}
export declare class TtsSocket {
    readonly socket: core.ReconnectingWebSocket;
    protected readonly eventHandlers: TtsSocket.EventHandlers;
    private handleOpen;
    private handleMessage;
    private handleClose;
    private handleError;
    constructor(args: TtsSocket.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<T extends keyof TtsSocket.EventHandlers>(event: T, callback: TtsSocket.EventHandlers[T]): void;
    sendGenerate(message: Respeecher.tts.ContextfulGenerationRequest): void;
    sendCancel(message: Respeecher.tts.CancellationRequest): void;
    /** Connect to the websocket and register event handlers. */
    connect(): TtsSocket;
    /** Close the websocket and unregister event handlers. */
    close(): void;
    /** Returns a promise that resolves when the websocket is open. */
    waitForOpen(): Promise<core.ReconnectingWebSocket>;
    /** Asserts that the websocket is open. */
    private assertSocketIsOpen;
    /** Send a binary payload to the websocket. */
    private sendBinary;
}
