-
Notifications
You must be signed in to change notification settings - Fork 0
[08/09] logs: prune noisy hot paths; telemetry tweaks #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
21e540f
4e92bb1
6646ec3
494cd08
611318f
9274fa6
3b20c06
55c554d
027cf52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,16 +21,20 @@ pub struct VadMicCheck; | |
|
|
||
| impl VadMicCheck { | ||
| pub async fn run(ctx: &TestContext) -> Result<LiveTestResult, TestError> { | ||
| let device_name = ctx.device.clone(); | ||
| // HARDCODED: Always use HyperX QuadCast for now to bypass broken device detection | ||
| let device_name = Some("HyperX QuadCast".to_string()); | ||
| let duration = ctx.duration; | ||
|
|
||
|
Comment on lines
23
to
33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The VAD microphone test now unconditionally assigns Useful? React with 👍 / 👎. |
||
| tracing::info!("VAD Mic Test: Hardcoded to use HyperX QuadCast device"); | ||
|
|
||
| let config = AudioConfig::default(); | ||
|
|
||
| // Prepare ring buffer and spawn capture thread | ||
| let rb = AudioRingBuffer::new(16_384); | ||
| let (audio_producer, audio_consumer) = rb.split(); | ||
| let (capture_thread, dev_cfg, _config_rx, _device_event_rx) = | ||
| AudioCaptureThread::spawn(config, audio_producer, device_name).map_err(|e| { | ||
| let audio_producer = Arc::new(parking_lot::Mutex::new(audio_producer)); | ||
| let (capture_thread, dev_cfg, device_cfg_rx, _device_event_rx) = | ||
| AudioCaptureThread::spawn(config, audio_producer, device_name, false).map_err(|e| { | ||
| TestError { | ||
| kind: TestErrorKind::Setup, | ||
| message: format!("Failed to create audio capture thread: {}", e), | ||
|
|
@@ -42,10 +46,10 @@ impl VadMicCheck { | |
| // Create metrics for this test instance | ||
| let metrics = Arc::new(PipelineMetrics::default()); | ||
|
|
||
| // Periodic metrics logging every 30s | ||
| // Periodic metrics logging every 2s (short tests) | ||
| let metrics_clone = metrics.clone(); | ||
| let log_handle = tokio::spawn(async move { | ||
| let mut interval = tokio::time::interval(Duration::from_secs(30)); | ||
| let mut interval = tokio::time::interval(Duration::from_secs(2)); | ||
|
||
| loop { | ||
| interval.tick().await; | ||
| let cap_fps = metrics_clone | ||
|
|
@@ -89,14 +93,18 @@ impl VadMicCheck { | |
| Some(metrics.clone()), | ||
| ); | ||
| let chunker = AudioChunker::new(frame_reader, audio_tx.clone(), chunker_cfg) | ||
| .with_metrics(metrics.clone()); | ||
| .with_metrics(metrics.clone()) | ||
| .with_device_config(device_cfg_rx); | ||
| let chunker_handle = chunker.spawn(); | ||
|
|
||
| let vad_cfg = UnifiedVadConfig { | ||
| mode: VadMode::Silero, | ||
| silero: coldvox_vad::config::SileroConfig { | ||
| threshold: 0.2, | ||
| ..Default::default() | ||
| }, | ||
| frame_size_samples: 512, | ||
| sample_rate_hz: 16000, // Silero requires 16kHz - resampler will handle conversion | ||
| ..Default::default() | ||
| }; | ||
|
|
||
| let vad_audio_rx = audio_tx.subscribe(); | ||
|
|
@@ -149,35 +157,64 @@ impl VadMicCheck { | |
| let elapsed = start_time.elapsed(); | ||
|
|
||
| // Calculate metrics | ||
| let mut metrics = HashMap::new(); | ||
| metrics.insert("vad_events_count".to_string(), json!(vad_events.len())); | ||
| metrics.insert("speech_segments".to_string(), json!(speech_segments)); | ||
| metrics.insert( | ||
| let mut result_metrics = HashMap::new(); | ||
| result_metrics.insert("vad_events_count".to_string(), json!(vad_events.len())); | ||
| result_metrics.insert("speech_segments".to_string(), json!(speech_segments)); | ||
| result_metrics.insert( | ||
| "total_speech_duration_ms".to_string(), | ||
| json!(total_speech_duration_ms), | ||
| ); | ||
| metrics.insert( | ||
| result_metrics.insert( | ||
| "test_duration_secs".to_string(), | ||
| json!(elapsed.as_secs_f64()), | ||
| ); | ||
| metrics.insert("device_sample_rate".to_string(), json!(dev_cfg.sample_rate)); | ||
| metrics.insert("device_channels".to_string(), json!(dev_cfg.channels)); | ||
| result_metrics.insert("device_sample_rate".to_string(), json!(dev_cfg.sample_rate)); | ||
| result_metrics.insert("device_channels".to_string(), json!(dev_cfg.channels)); | ||
| // Runtime FPS/buffer metrics snapshot | ||
| result_metrics.insert( | ||
| "capture_fps".to_string(), | ||
| json!(metrics | ||
| .capture_fps | ||
| .load(std::sync::atomic::Ordering::Relaxed)), | ||
| ); | ||
| result_metrics.insert( | ||
| "chunker_fps".to_string(), | ||
| json!(metrics | ||
| .chunker_fps | ||
| .load(std::sync::atomic::Ordering::Relaxed)), | ||
| ); | ||
| result_metrics.insert( | ||
| "vad_fps".to_string(), | ||
| json!(metrics.vad_fps.load(std::sync::atomic::Ordering::Relaxed)), | ||
| ); | ||
| result_metrics.insert( | ||
| "capture_buffer_fill".to_string(), | ||
| json!(metrics | ||
| .capture_buffer_fill | ||
| .load(std::sync::atomic::Ordering::Relaxed)), | ||
| ); | ||
| result_metrics.insert( | ||
| "chunker_buffer_fill".to_string(), | ||
| json!(metrics | ||
| .chunker_buffer_fill | ||
| .load(std::sync::atomic::Ordering::Relaxed)), | ||
| ); | ||
|
|
||
| // Calculate speech ratio | ||
| let speech_ratio = if elapsed.as_millis() > 0 { | ||
| total_speech_duration_ms as f64 / elapsed.as_millis() as f64 | ||
| } else { | ||
| 0.0 | ||
| }; | ||
| metrics.insert("speech_ratio".to_string(), json!(speech_ratio)); | ||
| result_metrics.insert("speech_ratio".to_string(), json!(speech_ratio)); | ||
|
|
||
| // Evaluate results | ||
| let (pass, notes) = evaluate_vad_performance(&metrics, &vad_events); | ||
| let (pass, notes) = evaluate_vad_performance(&result_metrics, &vad_events); | ||
|
|
||
| Ok(LiveTestResult { | ||
| test: "vad_mic".to_string(), | ||
| pass, | ||
| metrics, | ||
| metrics: result_metrics, | ||
| notes: Some(notes), | ||
| artifacts: vec![], | ||
| }) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded device name creates a maintenance burden and will fail on systems without this specific device. Consider adding a fallback mechanism or making this configurable through environment variables or test parameters.