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 test & bench

Louis Beaumont27057dc332b4
diff --git a/screenpipe-audio/benches/record_and_transcribe_benchmark.rs b/screenpipe-audio/benches/record_and_transcribe_benchmark.rs
index 28bf1b476..b69452745 100644
--- a/screenpipe-audio/benches/record_and_transcribe_benchmark.rs
+++ b/screenpipe-audio/benches/record_and_transcribe_benchmark.rs
@@ -18,10 +18,13 @@ async fn setup_test() -> (
let audio_device = default_input_device().unwrap(); // TODO feed voice in automatically somehow
let output_path = PathBuf::from("/tmp/test_audio.mp4");
// let (whisper_sender, _) = mpsc::unbounded_channel();
- let (whisper_sender, _) =
- create_whisper_channel(Arc::new(AudioTranscriptionEngine::WhisperDistilLargeV3))
- .await
- .unwrap();
+ let (whisper_sender, _, _) = create_whisper_channel(
+ Arc::new(AudioTranscriptionEngine::WhisperDistilLargeV3),
+ screenpipe_audio::VadEngineEnum::Silero,
+ None,
+ )
+ .await
+ .unwrap();
let is_running = Arc::new(AtomicBool::new(true));
(
@@ -34,17 +37,17 @@ async fn setup_test() -> (
fn bench_record_and_transcribe(c: &mut Criterion) {
let runtime = tokio::runtime::Builder::new_multi_thread()
- .worker_threads(4) // Adjust based on your system
- .enable_all()
- .build()
- .unwrap();
+ .worker_threads(4) // Adjust based on your system
+ .enable_all()
+ .build()
+ .unwrap();
let mut group = c.benchmark_group("Record and Transcribe");
group.sample_size(10);
group.measurement_time(Duration::from_secs(90)); // Increased from 30 to 60 seconds
group.bench_function(BenchmarkId::new("Performance", ""), |b| {
- b.to_async(&rt).iter_custom(|iters| async move {
+ b.to_async(&runtime).iter_custom(|iters| async move {
let mut total_duration = Duration::new(0, 0);
for _ in 0..iters {
diff --git a/screenpipe-audio/benches/stt_benchmark.rs b/screenpipe-audio/benches/stt_benchmark.rs
index a5cc18c74..38da8044f 100644
--- a/screenpipe-audio/benches/stt_benchmark.rs
+++ b/screenpipe-audio/benches/stt_benchmark.rs
@@ -1,6 +1,9 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use memory_stats::memory_stats;
-use screenpipe_audio::{create_whisper_channel, stt, AudioTranscriptionEngine, WhisperModel};
+use screenpipe_audio::vad_engine::SileroVad;
+use screenpipe_audio::{
+ create_whisper_channel, stt, AudioTranscriptionEngine, VadEngineEnum, WhisperModel,
+};
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
@@ -18,16 +21,23 @@ fn criterion_benchmark(c: &mut Criterion) {
group.bench_function("create_whisper_channel", |b| {
b.iter(|| {
- let _ = create_whisper_channel(black_box(audio_transcription_engine.clone()));
+ let _ = create_whisper_channel(
+ black_box(audio_transcription_engine.clone()),
+ black_box(VadEngineEnum::Silero),
+ None,
+ );
})
});
group.bench_function("stt", |b| {
b.iter(|| {
+ let mut vad_engine = Box::new(SileroVad::new().unwrap());
let _ = stt(
black_box(test_file_path.to_string_lossy().as_ref()),
black_box(&whisper_model),
black_box(audio_transcription_engine.clone()),
+ &mut *vad_engine,
+ None,
);
})
});
@@ -38,10 +48,13 @@ fn criterion_benchmark(c: &mut Criterion) {
for _ in 0..iters {
let start = std::time::Instant::now();
let before = memory_stats().unwrap().physical_mem;
+ let mut vad_engine = Box::new(SileroVad::new().unwrap());
let _ = stt(
test_file_path.to_string_lossy().as_ref(),
&whisper_model,
audio_transcription_engine.clone(),
+ &mut *vad_engine,
+ None,
);
let after = memory_stats().unwrap().physical_mem;
let duration = start.elapsed();
diff --git a/screenpipe-audio/tests/core_tests.rs b/screenpipe-audio/tests/core_tests.rs
index d47e624e9..ff6ea96ef 100644
--- a/screenpipe-audio/tests/core_tests.rs
+++ b/screenpipe-audio/tests/core_tests.rs
@@ -2,6 +2,7 @@
mod tests {
use chrono::Utc;
use log::{debug, LevelFilter};
+ use screenpipe_audio::vad_engine::{VadEngineEnum, WebRtcVad};
use screenpipe_audio::{
default_output_device, list_audio_devices, stt, AudioTranscriptionEngine, WhisperModel,
};
@@ -13,8 +14,7 @@ mod tests {
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::mpsc::unbounded_channel;
- use screenpipe_audio::vad_engine::{VadEngineEnum, WebRtcVad};
-
+
fn setup() {
// Initialize the logger with an info level filter
match env_logger::builder()
@@ -56,7 +56,8 @@ mod tests {
"./test_data/selah.mp4",
&whisper_model,
Arc::new(AudioTranscriptionEngine::WhisperTiny),
- &mut vad_engine
+ &mut vad_engine,
+ None,
)
.unwrap();
let duration = start.elapsed();
@@ -233,13 +234,13 @@ mod tests {
let output_path =
PathBuf::from(format!("test_output_{}.mp4", Utc::now().timestamp_millis()));
let output_path_2 = output_path.clone();
- let (whisper_sender, mut whisper_receiver, _) =
- create_whisper_channel(
- Arc::new(AudioTranscriptionEngine::WhisperTiny),
- VadEngineEnum::WebRtc
- )
- .await
- .unwrap();
+ let (whisper_sender, mut whisper_receiver, _) = create_whisper_channel(
+ Arc::new(AudioTranscriptionEngine::WhisperTiny),
+ VadEngineEnum::WebRtc,
+ None,
+ )
+ .await
+ .unwrap();
let is_running = Arc::new(AtomicBool::new(true));
// Start recording in a separate thread
let recording_thread = tokio::spawn(async move {
diff --git a/screenpipe-vision/benches/vision_benchmark.rs b/screenpipe-vision/benches/vision_benchmark.rs
index f7d3e99e1..7440c9ee0 100644
--- a/screenpipe-vision/benches/vision_benchmark.rs
+++ b/screenpipe-vision/benches/vision_benchmark.rs
@@ -3,8 +3,6 @@
// cargo bench --bench vision_benchmark
// ! not very useful bench
-use std::sync::Arc;
-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use screenpipe_vision::monitor::get_default_monitor;
use screenpipe_vision::{continuous_capture, OcrEngine};
@@ -19,7 +17,7 @@ async fn benchmark_continuous_capture(duration_secs: u64) -> f64 {
result_tx,
Duration::from_millis(100),
false,
- Arc::new(OcrEngine::Tesseract),
+ OcrEngine::Tesseract,
get_default_monitor().await.id(),
&[],
&[],