/** * The microphone, shared by every leg that opens it. * * `capture` is the one permission ask and the echo-cancelled stream it returns. * `tap` turns that stream into raw 16 kHz pcm16, a frame at a time, for the two * legs that stream audio rather than record it: the talk socket (/v1/voice) and * the growing transcript (/v1/audio/transcript). Both speak little-endian int16, * mono, 16 kHz, so the conversion is written once. */ /** The rate both streaming endpoints take audio at. */ export declare const RATE = 16000; /** * The microphone every later `capture` opens, by `MediaDeviceInfo.deviceId`; * null is the system's default. A device that has gone falls back to the * default rather than refusing. */ export declare function choose(id: string | null): void; /** The permission ask, and the echo-cancelled stream that comes back. */ export declare function capture(scope: unknown): Promise; /** getUserMedia's DOMException names, in this package's vocabulary. */ export declare function refusal(error: unknown): "denied" | "absent"; /** A running tap. Closing it releases the audio graph and its context, not the * stream. */ export interface Tap { /** The context the tap runs in, for a leg that also plays audio back. */ context: AudioContext; close(): void; } /** * An AudioContext, made NOW. Call it inside the click that opens the mic, before * any await: Safari only lets a context run that was made or resumed in a user * gesture, and one made after the permission prompt sits suspended, taps nothing * and plays nothing. Resumed for the browsers that start it suspended anyway. */ export declare function audioContext(scope?: unknown): AudioContext; /** * Stream `stream` as 16 kHz pcm16 in chunks of `frame` samples. * * Each sample out is the AVERAGE of the input samples it covers, not one picked * from among them: the average is the low-pass a plain decimation leaves out, so * a 48 kHz microphone does not fold its upper band down into the speech band. * The level (0..1) of each chunk rides with it, for a meter. */ export declare function tap(stream: MediaStream, frame: number, on: (pcm: Int16Array, level: number) => void, scope?: unknown, made?: AudioContext): Promise; /** pcm16 as base64, the encoding the realtime protocol carries audio in. */ export declare function base64(pcm: Int16Array): string; /** base64 pcm16 back to samples in -1..1, for playback. */ export declare function samples(b64: string): Float32Array; //# sourceMappingURL=mic.d.ts.map