WhisperEngine
Loads a whisper.cpp ggml model and returns a ready WhisperEngine.
The model is loaded on the new engine's own dedicated thread. backendConfig is enforced at load time:
ComputeBackend.CPU_ONLY sets
whisper_context_params.use_gpu = falsebeforewhisper_init_from_file_with_params(), so ggml never creates a GPU backend. On iOS all work then runs on Apple Accelerate / ARM NEON, which remains legal while the app is in the background.ComputeBackend.GPU_METAL / ComputeBackend.GPU_VULKAN set
use_gpu = trueon that device kind.ComputeBackend.NPU_COREML additionally enables the Core ML encoder (iOS builds with
WHISPER_COREML); it uses<model>-encoder.mlmodelcnext to the model when present and otherwise falls back to Metal/CPU.ComputeBackend.AUTO picks the first available of CoreML, Metal, Vulkan, CPU on Apple platforms and the JVM desktop, and always the CPU on Android, where whisper runs several times slower on OpenCL / Vulkan than on the CPU (see WhisperAutoPolicy). An explicit
GPU_OPENCLorGPU_VULKANrequest still uses that GPU. On the iOS simulator Metal (and with it CoreML) is unavailable, because the simulator's Metal device aborts the process on whisper's buffer allocations: thereAUTOresolves to the CPU, and an explicitGPU_METALorNPU_COREMLfalls back to it (or throws com.donfuldauer.kggml.core.BackendUnavailableException when WhisperEngineOptions.allowBackendFallback isfalse).
BackendConfig.useFlashAttention maps to whisper's flash attention (on when null, matching whisper.cpp; about twice as fast as without on mobile CPUs) and cpuThreads to the decoder thread count (BackendConfig.AUTO_THREADS = number of performance cores). gpuLayers and useMmap do not apply to Whisper models and are ignored.
Throws
if the file is missing or not a whisper model.
if the backend is unavailable and WhisperEngineOptions.allowBackendFallback is false.
if the native libraries cannot be loaded.