Files
WhispAssist/src-tauri/src/paths.rs
T

94 lines
3.0 KiB
Rust

//! Shared on-disk layout helpers (`docs/03-data-model.md`). Used by `storage`,
//! `commands`, and `lib` so the root/meetings/models/settings paths are computed
//! exactly one way.
use crate::models::MeetingId;
use std::path::PathBuf;
pub fn local_appdata() -> PathBuf {
PathBuf::from(std::env::var("LOCALAPPDATA").unwrap_or_else(|_| ".".to_string()))
}
pub fn wa_root() -> PathBuf {
local_appdata().join("WhispAssist")
}
pub fn db_path() -> PathBuf {
wa_root().join("wa.db")
}
pub fn settings_path() -> PathBuf {
wa_root().join("settings.json")
}
pub fn meetings_dir() -> PathBuf {
wa_root().join("meetings")
}
pub fn meeting_dir(id: &MeetingId) -> PathBuf {
meetings_dir().join(id)
}
pub fn models_dir() -> PathBuf {
wa_root().join("models")
}
/// Default model id used until the user picks one in Settings (T3.7).
pub const DEFAULT_WHISPER_MODEL: &str = "base.en-q5_1";
pub fn whisper_model_file(id: &str) -> PathBuf {
models_dir().join(format!("ggml-{id}.bin"))
}
pub fn whisper_model_path() -> PathBuf {
whisper_model_file(DEFAULT_WHISPER_MODEL)
}
/// On-demand NPU runtime (ONNX Runtime + OpenVINO EP DLLs, T3.4). Kept OUT of
/// the base installer to keep the binary lean (NFR-RES-1) — several hundred MB
/// of OpenVINO runtime is only fetched when an NPU is actually detected. The
/// download populates this dir; `ORT_DYLIB_PATH` is pointed at the ORT DLL here.
pub fn npu_runtime_dir() -> PathBuf {
wa_root().join("runtime").join("openvino")
}
/// The dlopen target for `ort` (load-dynamic). Its presence is the readiness
/// signal: an NPU is only "available" for routing once this exists on disk.
pub fn npu_runtime_dll() -> PathBuf {
npu_runtime_dir().join("onnxruntime.dll")
}
/// True once the NPU runtime has finished downloading (T3.4 step 2).
pub fn npu_runtime_ready() -> bool {
npu_runtime_dll().exists()
}
/// On-demand DirectML runtime (ONNX Runtime built with the DirectML EP, P2).
/// The non-Vulkan GPU path for AMD/Intel reuses the same Whisper-ONNX model as
/// the NPU path but needs a *different* `onnxruntime.dll` — Intel's OpenVINO ORT
/// build doesn't carry the DirectML EP — so it lives in its own runtime dir.
/// `DirectML.dll` itself ships with Windows 10 1903+, so the bundle is just ORT.
pub fn directml_runtime_dir() -> PathBuf {
wa_root().join("runtime").join("directml")
}
/// The dlopen target for `ort` (load-dynamic) on the DirectML path; its presence
/// is the readiness signal that gates AMD/Intel non-Vulkan availability.
pub fn directml_runtime_dll() -> PathBuf {
directml_runtime_dir().join("onnxruntime.dll")
}
/// True once the DirectML runtime has been staged (P2).
pub fn directml_runtime_ready() -> bool {
directml_runtime_dll().exists()
}
/// Fixed filenames pending T4.7 (diarization model management/selection in Settings).
pub fn diarization_segmentation_model_file() -> PathBuf {
models_dir().join("seg-pyannote-3.0.onnx")
}
pub fn diarization_embedding_model_file() -> PathBuf {
models_dir().join("spk-eres2net.onnx")
}