Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/wavekat-turn/src/audio/pipecat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,14 @@ impl AudioTurnDetector for PipecatSmartTurn {
(TurnState::Unfinished, 1.0 - probability)
};

let audio_duration_ms = (self.ring_buffer.len() as u64 * 1000) / SAMPLE_RATE as u64;

Ok(TurnPrediction {
state,
confidence,
latency_ms,
stage_times,
audio_duration_ms,
})
}

Expand Down
6 changes: 6 additions & 0 deletions crates/wavekat-turn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ pub struct TurnPrediction {
pub latency_ms: u64,
/// Per-stage timing breakdown in pipeline order.
pub stage_times: Vec<StageTiming>,
/// Duration of audio in the detector's buffer at prediction time (ms).
///
/// For PipecatSmartTurn this reflects how much of the 8 s ring buffer
/// was filled. With soft reset the buffer may span multiple speech
/// segments, so this can exceed the current segment duration.
pub audio_duration_ms: u64,
}

/// A single turn in the conversation, for context-aware text detectors.
Expand Down
2 changes: 2 additions & 0 deletions crates/wavekat-turn/tests/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ impl AudioTurnDetector for MockDetector {
TurnState::Unfinished => 0.80,
TurnState::Wait => 0.70,
};
let audio_duration_ms = (self.buffer_len as u64 * 1000) / 16000;
Ok(TurnPrediction {
state,
confidence,
latency_ms: 0,
stage_times: vec![],
audio_duration_ms,
})
}

Expand Down