Skip to main content

TurnFeed

Struct TurnFeed 

Source
pub struct TurnFeed<V, K> { /* private fields */ }
Available on crate feature 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>

Source

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().

Source

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.

Source

pub fn speech(&self) -> &SpeechMap

Source

pub fn timeline(&self) -> Option<&Timeline>

None when no tracker runs.

Source

pub fn drop_tracker(&mut self)

Stops judging voices. The detector goes on, and the audio only the tracker still needed is freed.

Source

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.

Source

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.

Source

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.

Source

pub fn waker(&self) -> RecordingWaker

Wakes a Self::wait_for_audio in progress.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<V, K> Freeze for TurnFeed<V, K>

§

impl<V, K> RefUnwindSafe for TurnFeed<V, K>

§

impl<V, K> Send for TurnFeed<V, K>
where SpeechDetector<V>: Send, Option<K>: Send,

§

impl<V, K> Sync for TurnFeed<V, K>
where SpeechDetector<V>: Sync, Option<K>: Sync,

§

impl<V, K> Unpin for TurnFeed<V, K>

§

impl<V, K> UnsafeUnpin for TurnFeed<V, K>

§

impl<V, K> UnwindSafe for TurnFeed<V, K>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more