Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(audio): align ort and ort-sys versions, add macOS download-binaries

Louis Beaumont5c87ed8c36e2
diff --git a/Cargo.lock b/Cargo.lock
index 3ed8e7be3..38f55d06a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -635,7 +635,7 @@ dependencies = [
"bitflags 2.9.0",
"cexpr",
"clang-sys",
- "itertools 0.10.5",
+ "itertools 0.13.0",
"proc-macro2",
"quote",
"regex",
@@ -653,7 +653,7 @@ dependencies = [
"bitflags 2.9.0",
"cexpr",
"clang-sys",
- "itertools 0.10.5",
+ "itertools 0.13.0",
"log",
"prettyplease",
"proc-macro2",
@@ -1287,7 +1287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [
"lazy_static",
- "windows-sys 0.59.0",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -5108,9 +5108,9 @@ dependencies = [
[[package]]
name = "ort-sys"
-version = "2.0.0-rc.8"
+version = "2.0.0-rc.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4780a8b8681e653b2bed85c7f0e2c6e8547224c3e983e5ad27bf0457e012407"
+checksum = "b4174960a7b93a17564a05b26e05889f0dea9ee70e68db5841f27b40c0c9804e"
dependencies = [
"flate2",
"pkg-config",
@@ -6265,7 +6265,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "screenpipe-audio"
-version = "0.2.75"
+version = "0.2.76"
dependencies = [
"anyhow",
"bytemuck",
@@ -6318,7 +6318,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.2.75"
+version = "0.2.76"
dependencies = [
"accessibility",
"accessibility-sys 0.2.0",
@@ -6361,7 +6361,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.2.75"
+version = "0.2.76"
dependencies = [
"anyhow",
"chrono",
@@ -6383,7 +6383,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.2.75"
+version = "0.2.76"
dependencies = [
"anyhow",
"chrono",
@@ -6401,7 +6401,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.2.75"
+version = "0.2.76"
dependencies = [
"anyhow",
"image 0.25.5",
@@ -6416,7 +6416,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.2.75"
+version = "0.2.76"
dependencies = [
"anyhow",
"axum",
@@ -6478,7 +6478,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.2.75"
+version = "0.2.76"
dependencies = [
"accessibility-sys 0.1.3",
"anyhow",
@@ -8892,7 +8892,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys 0.48.0",
]
[[package]]
diff --git a/screenpipe-audio/Cargo.toml b/screenpipe-audio/Cargo.toml
index a3c2598df..43f7bc2fb 100644
--- a/screenpipe-audio/Cargo.toml
+++ b/screenpipe-audio/Cargo.toml
@@ -31,7 +31,7 @@ clap = { version = "4.3", features = ["derive"] }
chrono = { version = "0.4.31", features = ["serde"] }
# Local Embeddings + STT
-vad-rs = "0.1.4"
+vad-rs = "=0.1.4"
anyhow = "1.0.86"
hf-hub = "0.3.2"
# https://github.com/pdeljanov/Symphonia/tree/master?tab=readme-ov-file#optimizations
@@ -73,8 +73,8 @@ lazy_static = { version = "1.4.0" }
realfft = "3.4.0"
ndarray = "0.16"
ort = "=2.0.0-rc.6"
+ort-sys = "=2.0.0-rc.6"
knf-rs = { git = "https://github.com/Neptune650/knf-rs.git" }
-ort-sys = "=2.0.0-rc.8"
futures = "0.3.31"
deepgram = "0.6.4"
bytes = { version = "1.9.0", features = ["serde"] }
@@ -94,6 +94,7 @@ libsamplerate-sys = "0.1.10"
[target.'cfg(target_os = "macos")'.dependencies]
once_cell = "1.17.1"
objc = "0.2.7"
+ort = { version = "=2.0.0-rc.6", features = ["download-binaries"] }
[dev-dependencies]
tempfile = "3.3.0"
diff --git a/screenpipe-audio/tests/onnx_model_test.rs b/screenpipe-audio/tests/onnx_model_test.rs
new file mode 100644
index 000000000..d439a966d
--- /dev/null
+++ b/screenpipe-audio/tests/onnx_model_test.rs
@@ -0,0 +1,177 @@
+/// Tests for ONNX Runtime model loading and inference
+/// These tests verify that the ort crate is properly configured and working
+/// on the current platform (especially important for macOS Apple Silicon).
+
+#[cfg(test)]
+mod tests {
+ use anyhow::Result;
+ use log::LevelFilter;
+ use screenpipe_audio::speaker::embedding::EmbeddingExtractor;
+ use screenpipe_audio::speaker::models::{get_or_download_model, PyannoteModel};
+ use screenpipe_audio::vad::silero::SileroVad;
+ use screenpipe_audio::vad::VadEngine;
+ use std::time::Instant;
+
+ fn setup() {
+ let _ = env_logger::builder()
+ .filter_level(LevelFilter::Debug)
+ .filter_module("tokenizers", LevelFilter::Error)
+ .try_init();
+ }
+
+ /// Test that we can create an ONNX session for the embedding model
+ /// This tests the core ort::Session creation which is where segfaults typically occur
+ #[tokio::test]
+ async fn test_onnx_embedding_model_loads() -> Result<()> {
+ setup();
+ println!("Testing ONNX embedding model loading...");
+
+ let start = Instant::now();
+
+ // Download/locate the embedding model
+ let embedding_model_path = get_or_download_model(PyannoteModel::Embedding).await?;
+ println!(
+ "Model path: {:?} (downloaded in {:?})",
+ embedding_model_path,
+ start.elapsed()
+ );
+
+ // Create the ONNX session - this is where segfaults typically occur
+ let start = Instant::now();
+ let extractor = EmbeddingExtractor::new(&embedding_model_path)?;
+ println!("EmbeddingExtractor created in {:?}", start.elapsed());
+
+ // Verify we can access the extractor (it's not a null/invalid session)
+ println!("EmbeddingExtractor debug: {:?}", extractor);
+
+ println!("ONNX embedding model test PASSED");
+ Ok(())
+ }
+
+ /// Test that we can create an ONNX session for the segmentation model
+ #[tokio::test]
+ async fn test_onnx_segmentation_model_loads() -> Result<()> {
+ setup();
+ println!("Testing ONNX segmentation model loading...");
+
+ let start = Instant::now();
+
+ // Download/locate the segmentation model
+ let segmentation_model_path = get_or_download_model(PyannoteModel::Segmentation).await?;
+ println!(
+ "Model path: {:?} (downloaded in {:?})",
+ segmentation_model_path,
+ start.elapsed()
+ );
+
+ // Create the ONNX session directly using the speaker module's create_session
+ let start = Instant::now();
+ let session = screenpipe_audio::speaker::create_session(&segmentation_model_path)?;
+ println!("Segmentation session created in {:?}", start.elapsed());
+
+ // Basic validation - check session has expected inputs/outputs
+ let inputs = session.inputs.len();
+ let outputs = session.outputs.len();
+ println!("Session has {} inputs and {} outputs", inputs, outputs);
+
+ assert!(inputs > 0, "Session should have at least one input");
+ assert!(outputs > 0, "Session should have at least one output");
+
+ println!("ONNX segmentation model test PASSED");
+ Ok(())
+ }
+
+ /// Test that SileroVad can initialize (uses ONNX via vad-rs crate)
+ #[tokio::test]
+ async fn test_silero_vad_initializes() -> Result<()> {
+ setup();
+ println!("Testing SileroVad initialization (uses ONNX via vad-rs)...");
+
+ let start = Instant::now();
+ let mut vad = SileroVad::new().await?;
+ println!("SileroVad initialized in {:?}", start.elapsed());
+
+ // Test basic inference with silence (all zeros)
+ let silence: Vec<f32> = vec![0.0; 1600]; // 100ms at 16kHz
+ let start = Instant::now();
+ let is_speech = vad.is_voice_segment(&silence)?;
+ println!(
+ "VAD inference completed in {:?}, is_speech={}",
+ start.elapsed(),
+ is_speech
+ );
+
+ // Silence should not be detected as speech
+ assert!(!is_speech, "Silence should not be detected as speech");
+
+ println!("SileroVad test PASSED");
+ Ok(())
+ }
+
+ /// Test that EmbeddingExtractor can run inference
+ #[tokio::test]
+ async fn test_embedding_extractor_inference() -> Result<()> {
+ setup();
+ println!("Testing EmbeddingExtractor inference...");
+
+ // Download/locate the embedding model
+ let embedding_model_path = get_or_download_model(PyannoteModel::Embedding).await?;
+
+ // Create the extractor
+ let mut extractor = EmbeddingExtractor::new(&embedding_model_path)?;
+ println!("EmbeddingExtractor created");
+
+ // Generate some test audio data (1 second of silence at 16kHz)
+ let test_audio: Vec<f32> = vec![0.0; 16000];
+
+ // Run inference
+ let start = Instant::now();
+ let embeddings: Vec<f32> = extractor.compute(&test_audio)?.collect();
+ println!(
+ "Embedding inference completed in {:?}, output size: {}",
+ start.elapsed(),
+ embeddings.len()
+ );
+
+ // Embeddings should have some dimensionality
+ assert!(!embeddings.is_empty(), "Embeddings should not be empty");
+ println!("Embedding dimensions: {}", embeddings.len());
+
+ println!("EmbeddingExtractor inference test PASSED");
+ Ok(())
+ }
+
+ /// Combined test that mimics the startup initialization sequence
+ /// This tests all ONNX models in the order they're loaded during app startup
+ #[tokio::test]
+ async fn test_onnx_startup_sequence() -> Result<()> {
+ setup();
+ println!("Testing ONNX startup sequence (mimics app initialization)...");
+ println!("---");
+
+ // Step 1: Initialize SileroVad (first ONNX model loaded)
+ println!("Step 1: Initializing SileroVad...");
+ let start = Instant::now();
+ let _vad = SileroVad::new().await?;
+ println!(" SileroVad OK ({:?})", start.elapsed());
+
+ // Step 2: Download/load embedding model
+ println!("Step 2: Loading embedding model...");
+ let start = Instant::now();
+ let embedding_path = get_or_download_model(PyannoteModel::Embedding).await?;
+ let _embedding_extractor = EmbeddingExtractor::new(&embedding_path)?;
+ println!(" EmbeddingExtractor OK ({:?})", start.elapsed());
+
+ // Step 3: Download/load segmentation model
+ println!("Step 3: Loading segmentation model...");
+ let start = Instant::now();
+ let segmentation_path = get_or_download_model(PyannoteModel::Segmentation).await?;
+ let _segmentation_session = screenpipe_audio::speaker::create_session(&segmentation_path)?;
+ println!(" Segmentation session OK ({:?})", start.elapsed());
+
+ println!("---");
+ println!("All ONNX models loaded successfully!");
+ println!("ONNX startup sequence test PASSED");
+ Ok(())
+ }
+}