fix: resolve all P1 hardcoded model paths at runtime (A-4.2 P1)

Issues: 6 P1 locations with hardcoded model paths
- asr.rs:81 - whisper model
- scene_classification.rs:68 - resnet18 model
- qwen_vl_manager.rs:25,26 - Qwen model + mmproj
- rust_vad.rs:18 - silero_vad model
- facenet_embedding.swift:24 - already fixed (A-11)

Impact: Missing models cause silent degradation (A-12)
        No embeddings → TKG 0 nodes (020.mp4 root cause)

Solution: Use path_utils::resolve_asset_path for all model paths
- Resolves via MOMENTRY_MODELS_DIR env var
- Falls back to current_exe sibling
- Final fallback to models/ directory

Changes:
1. asr.rs: Resolve whisper model dir
2. scene_classification.rs: Resolve resnet18 model path
3. qwen_vl_manager.rs: Resolve Qwen model + mmproj paths
4. rust_vad.rs: Resolve silero_vad model via env or relative

Benefits:
- All P1 models now configurable via MOMENTRY_MODELS_DIR
- No more silent failures when models missing
- Models can be placed in release bundle

Verification:
- cargo check --lib passes
- cargo build --release --bin rust_vad passes

Next steps: Address P2 (41 locations) and P3 (35 locations)

References:
- A-4.2 P1 in Momentry_Release_Requirements_20261004.md v1.1
- A-11, A-12
- G-3 gate condition
This commit is contained in:
Accusys
2026-10-04 15:59:56 +08:00
parent 0d11c60163
commit 2f5e2c1314
4 changed files with 35 additions and 9 deletions
+20 -3
View File
@@ -15,7 +15,7 @@ struct Cli {
audio: String,
/// ONNX model path
#[arg(long, default_value = "/Users/accusys/models/silero_vad.onnx")]
#[arg(long, default_value = "")]
model: String,
/// Speech probability threshold
@@ -42,9 +42,26 @@ struct Cli {
fn main() -> Result<()> {
let cli = Cli::parse();
println!("[VAD] Loading model: {}", cli.model);
// Resolve model path if not provided
let model_path = if cli.model.is_empty() {
std::env::var("MOMENTRY_MODELS_DIR")
.map(|d| std::path::PathBuf::from(d).join("silero_vad.onnx"))
.unwrap_or_else(|_| {
// Try relative to current exe
std::env::current_exe()
.ok()
.and_then(|p| p.parent().map(|d| d.join("models/silero_vad.onnx")))
.unwrap_or_else(|| std::path::PathBuf::from("models/silero_vad.onnx"))
})
.to_string_lossy()
.to_string()
} else {
cli.model
};
println!("[VAD] Loading model: {}", model_path);
let start_load = Instant::now();
let mut vad = SileroVad::new(&cli.model)?;
let mut vad = SileroVad::new(&model_path)?;
println!("[VAD] Model loaded in {:.2}s", start_load.elapsed().as_secs_f32());
println!("[VAD] Loading audio: {}", cli.audio);