import { VSBuffer } from "../../../base/common/buffer.js"; import { Event } from "../../../sessions/sessions.web.main.internal.js"; import { ILocalTranscriptionModelStatus, ILocalTranscriptionResult, ILocalTranscriptionModelImportResult } from "./localTranscription.js"; export declare const ILocalTranscriptionService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; /** * On-device speech-to-text using a downloaded model. Transcription runs through * Microsoft's Foundry Local streaming ASR engine (onnxruntime + onnxruntime-genai * native runtime), which handles decoding, VAD and endpointing internally. The * default model is NVIDIA's multilingual Nemotron 3.5 streaming RNN-T. The model * is chosen by the `dictation.model` setting. Runs in a utility process. A * single transcription session is active at a time (dictation is a singleton * in the renderer). * * The renderer streams PCM16 mono 16 kHz audio via `pushAudio`; the service * emits interim transcripts on `onDidTranscribe` and a final one after `stop`. */ export interface ILocalTranscriptionService { readonly _serviceBrand: undefined; /** * Whether on-device transcription can run in this environment. False on web * (no utility process) and on desktop platforms/architectures without a * Foundry Local native runtime. When false, dictation is unavailable — there * is no cloud fallback. */ readonly isSupported: boolean; /** Fires as the model downloads/loads so the UI can show progress. */ readonly onDidChangeModelStatus: Event; /** Fires with interim (and, after stop, final) transcripts. */ readonly onDidTranscribe: Event; /** Current model status (e.g. to gate the dictation UI). */ getModelStatus(): Promise; /** * Imports the default on-device model from an official Foundry Local expansion * pack or a prepared model directory into `cacheDir`. */ importModel(options: { readonly sourcePath: string; readonly cacheDir: string; }): Promise; /** * Ensure the model is downloaded/loaded (idempotent) and begin a new * transcription session. `cacheDir` is where model files are stored. `model` * selects the on-device Foundry Local model; when omitted the service default * is used. `language` optionally hints the spoken language. * * `proxyUrl`/`noProxy` bridge VS Code's `http.proxy`/`http.noProxy` settings * into this utility process: when set, they are applied as the standard proxy * environment variables before any download, so both the native runtime CDN * download and the Foundry Local *model* download route through the proxy. * When they are omitted, the process's inherited OS environment proxy vars * still apply. * * `proxyStrictSSL === false` (VS Code's `http.proxyStrictSSL`) disables TLS * certificate verification for the JavaScript download legs. `proxyAuthorization` * (VS Code's `http.proxyAuthorization`, a `Basic ` value) is folded into * the proxy URL's credentials so both our fetches and the native model download * authenticate to the proxy. TLS-intercepting proxies otherwise rely on the CA * being in the OS trust store (matching `@vscode/proxy-agent` and the desktop * app). * * `runtimeUrlTemplate`/`runtimeVersion` come from `product.dictationRuntime` * (stamped by `build/dictation-runtime/produce.ts`). When set, the native * runtime (Foundry Local addons + shared libraries) is downloaded from VS * Code's CDN for this host's target. When omitted (local dev builds), the * runtime falls back to the SDK's own `node_modules` payload and nothing is * downloaded. */ start(options: { readonly cacheDir: string; readonly model?: string; readonly language?: string; readonly proxyUrl?: string; readonly noProxy?: string; readonly proxyStrictSSL?: boolean; readonly proxyAuthorization?: string; readonly runtimeUrlTemplate?: string; readonly runtimeVersion?: string; }): Promise; /** Append captured audio (raw little-endian PCM16 mono 16 kHz). */ pushAudio(chunk: VSBuffer): Promise; /** Finish the session; resolves with the final transcript. */ stop(): Promise; /** Abort the session, discarding the transcript. */ cancel(): Promise; }