import { Event } from "../../../../../sessions/sessions.web.main.internal.js"; import { IPttDiagnostic } from "./micCaptureService.js"; export declare const IMicCaptureService: import("../../../../../platform/instantiation/common/instantiation.js").ServiceIdentifier; export interface IMicCaptureService { readonly _serviceBrand: undefined; /** * Store a window reference for later lazy mic acquisition without actually * acquiring the microphone. The mic is acquired on `pttDown()` and released * on `pttUp()`. */ prepare(window: Window & typeof globalThis): void; /** Start capturing audio from the microphone. */ startCapture(window: Window & typeof globalThis): Promise; /** Stop capturing and release mic resources. */ stopCapture(): void; readonly isCapturing: boolean; /** * Fired when a PTT segment begins (mic ready). The boolean payload is the * `passive` flag captured at the corresponding `pttDown` call (see there). */ readonly onPttStart: Event; /** Fired during PTT hold with base64-encoded raw PCM16 chunks. */ readonly onPttAudioChunk: Event; /** Fired when a PTT segment ends. All chunks have been sent before this fires. */ readonly onPttEnd: Event; /** * Fired after the diagnostic window closes (~1s after `pttUp`) with * per-press telemetry. Always fires AFTER `onPttEnd` for normal * presses. Used for tail-loss diagnosis; safe to ignore for normal * operation. */ readonly onPttDiagnostic: Event; /** The AnalyserNode for visualisation, available while capturing. */ readonly analyserNode: AnalyserNode | undefined; /** The captured microphone stream, available after {@link startCapture}. */ readonly mediaStream: MediaStream | undefined; /** * Begin a PTT segment. Lazily acquires the microphone if not already * capturing. Returns a promise that resolves once the mic is ready to * record (or rejects if acquisition fails). * * `turnId` is an opaque per-press identifier propagated into the * eventual `onPttDiagnostic` payload for correlation with backend logs. * Pass empty string when no correlation is needed. * * `passive` marks this press as a hands-free barge-in listen (mic opened * during assistant playback, not a real user press). It is captured * immutably at call time and carried on the `onPttStart` emission. This * stays correct even if the caller's own state changes during the async * mic acquire. */ pttDown(turnId: string, passive?: boolean): Promise; /** * End a PTT segment. Sends any remaining audio chunks, then fires pttEnd. */ pttUp(): void; /** * Abort the current PTT segment WITHOUT firing ``onPttEnd`` and WITHOUT * tearing down the warm mic. Used when the backend ends the turn itself * (server VAD silence / stop phrase): streaming stops immediately for this * press so no further audio is shipped, but no client ``ptt_end`` is * emitted for the turn. Safe to call when no press is active. */ abortPtt(): void; isMuted: boolean; /** Suppress mic output until the given timestamp (AEC gating). */ suppressUntil(timestamp: number): void; }