import { EarsError } from '../errors.js'; import type { WhisperModelId } from '../config.js'; import { type WhisperModelState } from './whisper-models.js'; import type { LibVariant } from '@fugood/whisper.node'; export interface WhisperAccelerationCapabilities { readonly available: readonly LibVariant[]; readonly default: LibVariant; } export declare const WHISPER_RESTART_REQUIRED_CODE: "whisper.restartRequired"; export declare const WHISPER_NATIVE_UNAVAILABLE_CODE: "whisper.nativeUnavailable"; export declare class WhisperRestartRequiredError extends EarsError { readonly loadedVariant: LibVariant; readonly requestedVariant: LibVariant; constructor(loadedVariant: LibVariant, requestedVariant: LibVariant); } export declare class WhisperNativeUnavailableError extends EarsError { readonly packageName: string; constructor(packageName: string, cause: unknown); } export declare function whisperNativePackageName(variant?: LibVariant, platform?: NodeJS.Platform, arch?: string): string; /** * Return the native acceleration packages supported by the current platform * and installed dependency tree without initializing whisper.node. `default` * is the automatic selection: prefer the platform-default binary when it is * installed, otherwise use the first available platform variant. */ export declare function whisperAccelerationCapabilities(platform?: NodeJS.Platform, arch?: string, requirePackage?: NodeRequire): WhisperAccelerationCapabilities; /** * Load and validate exactly the platform package requested by whisper.node. * This is only a preflight: inference still goes through @fugood/whisper.node. */ export declare function preflightWhisperNativePackage(variant?: LibVariant, requirePackage?: NodeRequire): string; /** The variant that this process first initialized through the strict runtime. */ export declare function getLoadedWhisperVariant(): LibVariant | undefined; export interface LocalWhisperOptions { readonly audio: Uint8Array; readonly mimeType: string; readonly language: string; readonly model: WhisperModelId; readonly signal: AbortSignal; /** Optional test/integration override; production uses the managed model path. */ readonly modelPath?: string; /** Native backend variant; default uses the platform default binary. */ readonly variant?: LibVariant; /** Defaults to Metal on macOS arm64, and to the explicit GPU variants elsewhere. */ readonly useGpu?: boolean; readonly timeoutMs?: number; } /** * Process-local whisper.node runtime. Owns one model context at a time, * serializes work on that context, and releases native resources on disposal. */ export declare class LocalWhisperRuntime { private context; private activeJob; private queue; private disposed; private loadedVariant; transcribe(options: LocalWhisperOptions): Promise; releaseContext(): Promise; /** * Run an operation while no transcription can start between releasing the * native context and the operation. This is used for model deletion, where * releasing the context and removing the backing file must be one barrier. */ withContextReleased(operation: () => Promise): Promise; dispose(): Promise; private drainAndReleaseContext; private releaseContextNow; private transcribeNow; private ensureContext; } export declare function disposeWhisperRuntime(): Promise; export declare function releaseWhisperModelContext(): Promise; export declare function withWhisperModelContextReleased(operation: () => Promise): Promise; export declare function defaultWhisperUseGpu(variant?: LibVariant, platform?: NodeJS.Platform, arch?: string): boolean; /** Check the exact native package without loading whisper.node's process-global module cache. */ export declare function isWhisperAvailable(variant?: LibVariant, signal?: AbortSignal, requirePackage?: NodeRequire): Promise; export declare function validateWhisperTranscription(state: WhisperModelState): void; export declare function transcribeWithWhisper(options: LocalWhisperOptions): Promise;