import type { Blocker, Refusal, State } from "./types.js"; export interface TalkConfig { /** Where `/v1/voice` lives. Defaults to the Hanzo gateway. */ baseUrl?: string; /** A bearer for the platform. The socket itself carries none: the bearer is * spent on the session call, which answers a one-use ticket. */ token?: string | (() => string | null | Promise); /** The organization to bill, when the bearer belongs to several. */ org?: string; fetch?: typeof fetch; } /** What the talk socket reports while a conversation is open. */ export interface Talked { /** `listening` while the floor is the person's, `speaking` while a reply plays. */ state(state: State): void; /** The reply's running transcript, as it is spoken. */ reply?(text: string): void; /** One whole reply. */ done?(text: string): void; /** The live input level, 0..1. */ level?(value: number): void; /** The microphone cannot open. */ fail(reason: Blocker): void; /** The platform refused the conversation, or ended it. */ refused(error: Error): void; /** The platform answered a turn with an error and kept the conversation. */ error?(message: string): void; } /** An open conversation. */ export interface Talk { open(): Promise; close(): void; } /** * A spoken conversation over one socket: `/v1/voice`, the OpenAI realtime wire. * * The microphone streams up as 16 kHz pcm16 and the reply streams down as 24 kHz * pcm16 with its transcript beside it. Turn-taking is the server's: it decides * when the person has finished, answers, and says so with * `input_audio_buffer.speech_started` when they talk over the reply, which is * where playback stops. Nothing here decides a turn. * * Two calls, because a browser cannot put a header on a WebSocket: the bearer is * spent on `POST /v1/voice/session`, and what goes in the socket's URL is the * one-use ticket that answers. */ export declare function talk(config: TalkConfig, heard: Talked, scope?: unknown): Talk; export interface TalkOptions extends TalkConfig { /** The reply's running transcript, as it is spoken. */ onReply?: (text: string) => void; /** One whole reply. */ onDone?: (text: string) => void; /** A turn the platform answered with an error. */ onError?: (message: string) => void; } /** A talk conversation, drawn by `` like the dictation machine is. */ export interface TalkMachine { state: State; open: boolean; /** The latest input level, 0..1. A getter: sample it, never render from it. */ level: number; blocked: Blocker | null; reason: string | null; refusal: Refusal | null; toggle: () => void; /** The reply being spoken, or the last one, until the next begins. */ reply: string; } /** * Talk mode: a hands-free spoken conversation on `/v1/voice`, one per hook. * * One click opens the microphone and the socket, the reply is spoken back and * its words arrive in `reply`; talking over it stops it. A second click hangs up, * as does unmounting the surface that drew it. */ export declare function useTalk(options: TalkOptions): TalkMachine; //# sourceMappingURL=talk.d.ts.map