pub struct TurnFeed<V, K> { /* private fields */ }silero and non-target_family=wasm only.Expand description
Feeds one recording to its speech detector and then to its tracker, on a fork of its own, so turns are cut where the audio pauses, not where a decoder finalizes. The tracker hears only what the detector has scored.
Implementations§
Source§impl<V: VoiceActivityDetector, K: SpeakerTracker> TurnFeed<V, K>
impl<V: VoiceActivityDetector, K: SpeakerTracker> TurnFeed<V, K>
Sourcepub fn start(
recording: &mut RecordingReader,
speech: SpeechDetector<V>,
tracker: Option<K>,
) -> Self
pub fn start( recording: &mut RecordingReader, speech: SpeechDetector<V>, tracker: Option<K>, ) -> Self
Forks recording, so call it before anything reads from it: the fork
starts where the reader stands. speech and tracker must start at
recording.held_from().
Sourcepub fn held_from(&self) -> u64
pub fn held_from(&self) -> u64
The first sample the feed still holds: where the recording starts, until the feed has heard some of it.
pub fn speech(&self) -> &SpeechMap
Sourcepub fn drop_tracker(&mut self)
pub fn drop_tracker(&mut self)
Stops judging voices. The detector goes on, and the audio only the tracker still needed is freed.
Sourcepub fn hear_through(&mut self, position: u64) -> bool
pub fn hear_through(&mut self, position: u64) -> bool
Paced by a decoder: the detector, then the tracker, hear the audio up
to stream position. Words a decoder has read never end past where
it read, so their turns are cut by then. Returns whether the
recording reached position.
Sourcepub fn hear_ahead(
&mut self,
piece: Duration,
max_lag: Option<Duration>,
) -> Ahead
pub fn hear_ahead( &mut self, piece: Duration, max_lag: Option<Duration>, ) -> Ahead
Paced by itself: the detector takes all the audio that has arrived,
the tracker at most piece of it. A tracker more than max_lag
behind the detector first skips to it.
Sourcepub fn wait_for_audio(&self, timeout: Duration, stopped: impl Fn() -> bool)
pub fn wait_for_audio(&self, timeout: Duration, stopped: impl Fn() -> bool)
Waits up to timeout for audio not heard yet, for capture to end,
or for stopped. A stop that rings Self::waker ends the wait at
once; one that is only polled is seen at the timeout.
Sourcepub fn waker(&self) -> RecordingWaker
pub fn waker(&self) -> RecordingWaker
Wakes a Self::wait_for_audio in progress.
Sourcepub fn hear_rest(&mut self)
pub fn hear_rest(&mut self)
Hears the rest of the recording, waiting for capture to end, and judges what is still open, so every held segment can be decided.
Sourcepub fn forget_before(&mut self, at: u64)
pub fn forget_before(&mut self, at: u64)
Forgets the map, and the tracker’s timeline, before at, though
never what the detector or the tracker still reads.