diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 64e0373..af7fe59 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -119,8 +119,15 @@ fn load_transcriber( backend: BackendId, whisper_model: &Path, ) -> Result<(Box, BackendId), crate::transcription::TrxError> { + use crate::hardware::{resolve_accel, AccelPath}; + + // Resolve how this backend is actually served in *this* build (CUDA/Vulkan + // baked in? NPU/DirectML runtime present?) rather than assuming a GPU + // backend has a working accel path just because the hardware exists. + let path = resolve_accel(backend); + #[cfg(feature = "npu")] - if backend == BackendId::Npu { + if path == AccelPath::OnnxOpenVino { use crate::transcription::{onnx_models, OnnxNpuTranscriber}; if onnx_models::is_installed(onnx_models::DEFAULT_ONNX_MODEL) { let dir = onnx_models::model_dir(onnx_models::DEFAULT_ONNX_MODEL); @@ -134,10 +141,18 @@ fn load_transcriber( ); } } - match WhisperTranscriber::load(whisper_model, backend) { - Ok(t) => Ok((Box::new(t), backend)), - Err(e) if backend != BackendId::Cpu => { - tracing::warn!("backend {backend:?} failed to load ({e}); falling back to CPU"); + + // whisper.cpp path: only ask for GPU offload when the resolver picked a + // whisper GPU backend that's compiled in — otherwise a bogus `use_gpu` for a + // vendor with no accel path just no-ops. Anything else decodes on the CPU. + let whisper_backend = match path { + AccelPath::WhisperCuda | AccelPath::WhisperVulkan => backend, + _ => BackendId::Cpu, + }; + match WhisperTranscriber::load(whisper_model, whisper_backend) { + Ok(t) => Ok((Box::new(t), whisper_backend)), + Err(e) if whisper_backend != BackendId::Cpu => { + tracing::warn!("backend {whisper_backend:?} failed to load ({e}); falling back to CPU"); WhisperTranscriber::load(whisper_model, BackendId::Cpu) .map(|t| (Box::new(t) as Box, BackendId::Cpu)) }