import type { Blocker, Refusal, Speech, State } from "./types.js"; /** What a live transcript reports while it is open. */ export interface Transcribed { /** Everything heard so far in this sitting: the settled text and the tail * still being decoded. It grows, and its tail may still change. */ partial(text: string): void; /** Text that has settled since the last time: it will not change again. */ settled(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 transcript. */ refused(error: Error): void; } export interface Live { open(): Promise; /** Stop listening and settle the tail. */ close(): Promise; } /** * How long, in ms, a live transcript keeps trying to deliver what it heard before * it calls the platform gone. A rate limit, a server fault or a dropped connection * is a wait, not a refusal: the audio stays queued and goes up in order once the * platform takes it. A minute because that is the gateway's rate window, so a * `Retry-After` it sends always lands inside it; a wait it names past the window * ends the transcript at once rather than after a minute of hoping. */ export declare const RETRY_WINDOW = 60000; /** * A session the platform no longer holds: 404 (gone, or idle past its life) or 409 * (opened by an instance that has since been replaced — a deploy restarts the * process that holds the window). A new transcript carries on in its place. */ export declare function gone(error: unknown): boolean; /** * How long to wait before trying a call again, or null when the answer is final. * Final: 402 and 403 (no funds, no permission), every other refusal of the * request itself (401, 404 and 409 for a session that is gone, 413), and a 429 * that names a spent allowance. Passing: any other 429, a 5xx, and a fetch that * never reached the platform. */ export declare function backoff(error: unknown, attempt: number): number | null; /** * A live transcript on `/v1/audio/transcript`: the microphone streams up as * 16 kHz pcm16 and the text grows as it is heard. * * The endpoint admits one push at a time, so audio heard while a push is in * flight waits and rides with the next one, up to the most a push may carry. A * push the platform cannot take yet (`backoff`) is sent again after the wait * while new audio queues behind it, so nothing heard is dropped or reordered; it * refuses only on a final answer or after `RETRY_WINDOW` without delivering. A * transcript accepts a bounded length of audio, so near its end it is closed — * which settles its tail — and the next one opened in the same breath. A session * the platform loses (`gone`: a deploy replaces the process that held it) is * replaced the same way, its text kept and the audio it never answered for sent to * the new one. Silence is not billed: the speech service decodes and meters only * what it hears. */ export declare function transcript(speech: Speech, heard: Transcribed, options?: { language?: string; scope?: unknown; }): Live; export interface TranscriptOptions { /** The platform's speech services; the live transcript is `speech.stream`. */ speech: Speech; language?: string; /** Everything heard so far in this sitting, tail included. */ onPartial?: (text: string) => void; /** Text that has settled and will not change. */ onSettled?: (text: string) => void; } /** A live transcript, drawn by `` like the other machines are. */ export interface TranscriptMachine { state: State; open: boolean; level: number; blocked: Blocker | null; reason: string | null; refusal: Refusal | null; toggle: () => void; } /** A live transcript that a click opens and a click settles, one per hook. */ export declare function useTranscript(options: TranscriptOptions): TranscriptMachine; //# sourceMappingURL=transcript.d.ts.map