diff --git a/scripts/rust_processors/src/bin/rust_vad.rs b/scripts/rust_processors/src/bin/rust_vad.rs index 34adcd37..a44d6461 100644 --- a/scripts/rust_processors/src/bin/rust_vad.rs +++ b/scripts/rust_processors/src/bin/rust_vad.rs @@ -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); diff --git a/src/core/processor/asr.rs b/src/core/processor/asr.rs index db296ffe..957c5b34 100644 --- a/src/core/processor/asr.rs +++ b/src/core/processor/asr.rs @@ -74,11 +74,15 @@ pub async fn process_asr( .parent() .context("Invalid output path")?; + // Resolve whisper model directory + let models_dir = crate::core::path_utils::resolve_asset_path("MOMENTRY_MODELS_DIR", "models"); + let whisper_model_dir = models_dir.join("whisper-small-mlx"); + let output = tokio::process::Command::new(whisper_cli) .args(&[ video_path, "--model", "small", - "--model_dir", "/Users/accusys/models/whisper-small-mlx", + "--model_dir", whisper_model_dir.to_str().unwrap(), "--output_dir", output_dir.to_str().unwrap(), "--output_format", "json", "--verbose", "False", diff --git a/src/core/processor/scene_classification.rs b/src/core/processor/scene_classification.rs index 1f71f094..ca3d70de 100644 --- a/src/core/processor/scene_classification.rs +++ b/src/core/processor/scene_classification.rs @@ -65,11 +65,14 @@ pub async fn process_scene_classification( }); } - let coreml_path = "/Users/accusys/models/resnet18_places365.mlpackage"; + // Resolve scene classification model path + let models_dir = crate::core::path_utils::resolve_asset_path("MOMENTRY_MODELS_DIR", "models"); + let coreml_path = models_dir.join("resnet18_places365.mlpackage"); + let mut args = vec![video_path, output_path]; - if std::path::Path::new(coreml_path).exists() { + if coreml_path.exists() { args.push("--model"); - args.push(coreml_path); + args.push(coreml_path.to_str().unwrap()); } executor diff --git a/src/core/vision/qwen_vl_manager.rs b/src/core/vision/qwen_vl_manager.rs index bb6a9b43..1c28d219 100644 --- a/src/core/vision/qwen_vl_manager.rs +++ b/src/core/vision/qwen_vl_manager.rs @@ -20,10 +20,12 @@ pub struct QwenVLManager { impl QwenVLManager { pub fn new() -> Self { + let models_dir = crate::core::path_utils::resolve_asset_path("MOMENTRY_MODELS_DIR", "models"); + Self { port: 8086, - model_path: PathBuf::from("/Users/accusys/models/Qwen3VL-8B-Instruct-Q8_0.gguf"), - mmproj_path: PathBuf::from("/Users/accusys/models/mmproj-Qwen3VL-8B-Instruct-F16.gguf"), + model_path: models_dir.join("Qwen3VL-8B-Instruct-Q8_0.gguf"), + mmproj_path: models_dir.join("mmproj-Qwen3VL-8B-Instruct-F16.gguf"), log_file: PathBuf::from("logs/qwen3vl_8086.log"), pid_file: PathBuf::from("/tmp/qwen3vl.pid"), start_script: PathBuf::from("scripts/start_qwen3vl.sh"),