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: tests

Louis Beaumont9a6d53c60d87
diff --git a/screenpipe-audio/examples/stt.rs b/screenpipe-audio/examples/stt.rs
index 4e65ee5af..849d967b6 100644
--- a/screenpipe-audio/examples/stt.rs
+++ b/screenpipe-audio/examples/stt.rs
@@ -1,4 +1,6 @@
use futures::future::join_all;
+use screenpipe_audio::pyannote::embedding::EmbeddingExtractor;
+use screenpipe_audio::pyannote::identify::EmbeddingManager;
use screenpipe_audio::stt::{prepare_segments, stt};
use screenpipe_audio::vad_engine::{SileroVad, VadEngine};
use screenpipe_audio::whisper::WhisperModel;
@@ -51,12 +53,31 @@ async fn main() {
Arc::new(Mutex::new(Box::new(SileroVad::new().await.unwrap())));
let output_path = Arc::new(PathBuf::from("test_output"));
+ let project_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let segmentation_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("segmentation-3.0.onnx");
+
+ let embedding_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("wespeaker_en_voxceleb_CAM++.onnx");
+
+ let embedding_extractor = Arc::new(std::sync::Mutex::new(
+ EmbeddingExtractor::new(embedding_model_path.to_str().unwrap()).unwrap(),
+ ));
+ let embedding_manager = EmbeddingManager::new(usize::MAX);
+
let mut tasks = Vec::new();
for (audio_file, expected_transcription) in test_cases {
let whisper_model = Arc::clone(&whisper_model);
let vad_engine = Arc::clone(&vad_engine);
let output_path = Arc::clone(&output_path);
+ let segmentation_model_path = segmentation_model_path.clone();
+ let embedding_extractor = Arc::clone(&embedding_extractor);
+ let embedding_manager = embedding_manager.clone();
let task = tokio::spawn(async move {
let audio_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(audio_file);
@@ -70,9 +91,15 @@ async fn main() {
device: Arc::new(screenpipe_audio::default_input_device().unwrap()),
};
- let mut segments = prepare_segments(&audio_input, vad_engine.clone())
- .await
- .unwrap();
+ let mut segments = prepare_segments(
+ &audio_input,
+ vad_engine.clone(),
+ &segmentation_model_path,
+ embedding_manager,
+ embedding_extractor,
+ )
+ .await
+ .unwrap();
let mut whisper_model_guard = whisper_model.lock().await;
let mut transcription = String::new();
diff --git a/screenpipe-audio/tests/accuracy_test.rs b/screenpipe-audio/tests/accuracy_test.rs
index 33729f7dd..be5411873 100644
--- a/screenpipe-audio/tests/accuracy_test.rs
+++ b/screenpipe-audio/tests/accuracy_test.rs
@@ -1,4 +1,6 @@
use futures::future::join_all;
+use screenpipe_audio::pyannote::embedding::EmbeddingExtractor;
+use screenpipe_audio::pyannote::identify::EmbeddingManager;
use screenpipe_audio::stt::{prepare_segments, stt};
use screenpipe_audio::vad_engine::{SileroVad, VadEngine};
use screenpipe_audio::whisper::WhisperModel;
@@ -53,10 +55,28 @@ async fn test_transcription_accuracy() {
let mut tasks = Vec::new();
+ let project_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let segmentation_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("segmentation-3.0.onnx");
+
+ let embedding_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("wespeaker_en_voxceleb_CAM++.onnx");
+
+ let embedding_extractor = Arc::new(std::sync::Mutex::new(
+ EmbeddingExtractor::new(embedding_model_path.to_str().unwrap()).unwrap(),
+ ));
+
for (audio_file, expected_transcription) in test_cases {
let whisper_model = Arc::clone(&whisper_model);
let vad_engine = Arc::clone(&vad_engine);
let output_path = Arc::clone(&output_path);
+ let embedding_extractor = Arc::clone(&embedding_extractor);
+ let embedding_manager = EmbeddingManager::new(usize::MAX);
+ let segmentation_model_path = segmentation_model_path.clone();
let task = tokio::spawn(async move {
let audio_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(audio_file);
@@ -70,9 +90,15 @@ async fn test_transcription_accuracy() {
device: Arc::new(screenpipe_audio::default_input_device().unwrap()),
};
- let mut segments = prepare_segments(&audio_input, vad_engine.clone())
- .await
- .unwrap();
+ let mut segments = prepare_segments(
+ &audio_input,
+ vad_engine.clone(),
+ &segmentation_model_path,
+ embedding_manager,
+ embedding_extractor,
+ )
+ .await
+ .unwrap();
let mut whisper_model_guard = whisper_model.lock().await;
let mut transcription = String::new();
diff --git a/screenpipe-audio/tests/core_tests.rs b/screenpipe-audio/tests/core_tests.rs
index 2079974cf..2e50c7aaa 100644
--- a/screenpipe-audio/tests/core_tests.rs
+++ b/screenpipe-audio/tests/core_tests.rs
@@ -1,7 +1,10 @@
#[cfg(test)]
mod tests {
+ use anyhow::anyhow;
use chrono::Utc;
use log::{debug, LevelFilter};
+ use screenpipe_audio::pyannote::embedding::EmbeddingExtractor;
+ use screenpipe_audio::pyannote::identify::EmbeddingManager;
use screenpipe_audio::stt::{prepare_segments, stt};
use screenpipe_audio::vad_engine::{SileroVad, VadEngine, VadEngineEnum, VadSensitivity};
use screenpipe_audio::whisper::WhisperModel;
@@ -307,9 +310,39 @@ mod tests {
device: Arc::new(screenpipe_audio::default_input_device().unwrap()),
};
- let mut segments = prepare_segments(&audio_input, vad_engine.clone())
- .await
- .unwrap();
+ let start_time = Instant::now();
+
+ // Create the missing parameters
+ let project_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let segmentation_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("segmentation-3.0.onnx");
+ let embedding_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("wespeaker_en_voxceleb_CAM++.onnx");
+
+ let embedding_extractor = Arc::new(std::sync::Mutex::new(
+ EmbeddingExtractor::new(
+ embedding_model_path
+ .to_str()
+ .ok_or_else(|| anyhow!("Invalid embedding model path"))
+ .unwrap(),
+ )
+ .unwrap(),
+ ));
+ let embedding_manager = EmbeddingManager::new(usize::MAX);
+
+ let mut segments = prepare_segments(
+ &audio_input,
+ vad_engine.clone(),
+ &segmentation_model_path,
+ embedding_manager,
+ embedding_extractor,
+ )
+ .await
+ .unwrap();
let mut whisper_model_guard = whisper_model.lock().await;
let mut transcription_result = String::new();
@@ -370,6 +403,28 @@ mod tests {
device: Arc::new(default_output_device().unwrap()),
};
+ let project_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let segmentation_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("segmentation-3.0.onnx");
+ let embedding_model_path = project_dir
+ .join("models")
+ .join("pyannote")
+ .join("wespeaker_en_voxceleb_CAM++.onnx");
+
+ let embedding_extractor = Arc::new(std::sync::Mutex::new(
+ EmbeddingExtractor::new(
+ embedding_model_path
+ .to_str()
+ .ok_or_else(|| anyhow!("Invalid embedding model path"))
+ .unwrap(),
+ )
+ .unwrap(),
+ ));
+
+ let embedding_manager = EmbeddingManager::new(usize::MAX);
+
// Initialize the WhisperModel
let mut whisper_model = WhisperModel::new(&AudioTranscriptionEngine::WhisperLargeV3Turbo)
.expect("Failed to initialize WhisperModel");
@@ -381,9 +436,15 @@ mod tests {
// Measure transcription time
let start_time = Instant::now();
- let mut segments = prepare_segments(&audio_input, vad_engine.clone())
- .await
- .unwrap();
+ let mut segments = prepare_segments(
+ &audio_input,
+ vad_engine.clone(),
+ &segmentation_model_path,
+ embedding_manager,
+ embedding_extractor,
+ )
+ .await
+ .unwrap();
let mut transcription = String::new();
while let Some(segment) = segments.recv().await {
diff --git a/screenpipe-audio/tests/speaker_identification.rs b/screenpipe-audio/tests/speaker_identification.rs
index fc33897fb..219964371 100644
--- a/screenpipe-audio/tests/speaker_identification.rs
+++ b/screenpipe-audio/tests/speaker_identification.rs
@@ -2,6 +2,7 @@ mod tests {
use log::LevelFilter;
use screenpipe_audio::pyannote::segment::get_segments;
use std::path::PathBuf;
+ use std::sync::{Arc, Mutex};
fn setup() {
// Initialize the logger with an info level filter
@@ -29,13 +30,15 @@ mod tests {
.join("pyannote")
.join("segmentation-3.0.onnx");
- let embedding_extractor = screenpipe_audio::pyannote::embedding::EmbeddingExtractor::new(
- embedding_model_path
- .to_str()
- .ok_or_else(|| anyhow::anyhow!("Invalid embedding model path"))
- .unwrap(),
- )
- .unwrap();
+ let embedding_extractor = Arc::new(Mutex::new(
+ screenpipe_audio::pyannote::embedding::EmbeddingExtractor::new(
+ embedding_model_path
+ .to_str()
+ .ok_or_else(|| anyhow::anyhow!("Invalid embedding model path"))
+ .unwrap(),
+ )
+ .unwrap()
+ ));
let embedding_manager =
screenpipe_audio::pyannote::identify::EmbeddingManager::new(usize::MAX);
diff --git a/screenpipe-server/tests/endpoint_test.rs b/screenpipe-server/tests/endpoint_test.rs
index 6aa3b7244..8df8698db 100644
--- a/screenpipe-server/tests/endpoint_test.rs
+++ b/screenpipe-server/tests/endpoint_test.rs
@@ -46,6 +46,7 @@ mod tests {
frame_cache: Some(Arc::new(
FrameCache::new(PathBuf::from(""), db).await.unwrap(),
)),
+ ui_monitoring_enabled: false,
});
let router = create_router();
@@ -148,6 +149,7 @@ mod tests {
0,
"",
&AudioDevice::new("test".to_string(), DeviceType::Input),
+ None,
)
.await
.unwrap();
@@ -211,6 +213,7 @@ mod tests {
0,
"",
&AudioDevice::new("test".to_string(), DeviceType::Input),
+ None,
)
.await
.unwrap();
@@ -270,6 +273,7 @@ mod tests {
0,
"",
&AudioDevice::new("test1".to_string(), DeviceType::Input),
+ None,
)
.await
.unwrap();
@@ -281,6 +285,7 @@ mod tests {
0,
"",
&AudioDevice::new("test2".to_string(), DeviceType::Input),
+ None,
)
.await
.unwrap();
@@ -401,6 +406,7 @@ mod tests {
0,
"",
&AudioDevice::new("test1".to_string(), DeviceType::Input),
+ None,
)
.await
.unwrap();
@@ -411,6 +417,7 @@ mod tests {
0,
"",
&AudioDevice::new("test2".to_string(), DeviceType::Input),
+ None,
)
.await
.unwrap();
@@ -557,6 +564,7 @@ mod tests {
0,
"",
&AudioDevice::new("test".to_string(), DeviceType::Input),
+ None,
)
.await
.unwrap();
diff --git a/screenpipe-server/tests/tags_test.rs b/screenpipe-server/tests/tags_test.rs
index f18c7c753..f79d490a6 100644
--- a/screenpipe-server/tests/tags_test.rs
+++ b/screenpipe-server/tests/tags_test.rs
@@ -38,6 +38,7 @@ async fn setup_test_app() -> (Router, Arc<AppState>) {
frame_cache: Some(Arc::new(
FrameCache::new(PathBuf::from(""), db).await.unwrap(),
)),
+ ui_monitoring_enabled: false,
});
let app = create_router().with_state(app_state.clone());
@@ -153,6 +154,9 @@ async fn test_add_tags_and_search() {
assert!(fts.tags.contains(&"test".to_string()));
assert!(fts.tags.contains(&"vision".to_string()));
}
+ ContentItem::UI(_) => {
+ assert!(false);
+ }
}
}
}
@@ -354,6 +358,9 @@ async fn test_search_by_multiple_tags() {
assert!(fts.tags.contains(&"work".to_string()));
assert!(fts.tags.contains(&"meeting".to_string()));
}
+ ContentItem::UI(_) => {
+
+ }
}
}
}
@@ -391,6 +398,7 @@ async fn insert_test_data(db: &Arc<DatabaseManager>) {
0,
"test_engine",
&AudioDevice::new("test".to_string(), DeviceType::Output),
+ None,
)
.await
.unwrap();