Skip to main content

TakeSegmenter

Struct TakeSegmenter 

Source
struct TakeSegmenter {
Show 14 fields recording: Arc<Recording>, jobs: Sender<Job>, silence_floor: f32, diagnostics_dir: Option<PathBuf>, models: Arc<TakeModels>, take: TakeShared, last_cut: usize, cuts: Vec<(usize, usize)>, parts: Vec<Part>, pending: Vec<Receiver<Result<Outcome, Error>>>, settled: usize, first_queued_at: Option<Instant>, first_settled_at: Option<Instant>, failed: Option<(usize, String)>,
}
Expand description

One capture’s segmenter: cuts windows off the growing recording as they pass the reliability ceiling and queues each for recognition while the microphone keeps running; at finish it submits the tail, waits out every segment, and normalizes the join exactly once, on the worker where the normalizer lives. No partial text is ever produced - the only thing that leaves this thread before the answer is the progress count.

Fields§

§recording: Arc<Recording>§jobs: Sender<Job>§silence_floor: f32§diagnostics_dir: Option<PathBuf>§models: Arc<TakeModels>

The models the take ran under, named in its diagnostics record.

§take: TakeShared§last_cut: usize

First sample not yet handed to a segment.

§cuts: Vec<(usize, usize)>

Segment spans in submission order, for the diagnostics record.

§parts: Vec<Part>

Settled pieces, in submission order. Aligned with cuts: every cut contributes exactly one part, even a silence-gated one.

§pending: Vec<Receiver<Result<Outcome, Error>>>

Answers still awaited, in submission order. The worker is serial, so they complete in this order too.

§settled: usize

How many parts have settled. The progress stream’s done.

§first_queued_at: Option<Instant>

When the take’s first job was queued, and when its first part settled: the diagnostics start_lag_ms spans the two.

§first_settled_at: Option<Instant>§failed: Option<(usize, String)>

The first recognition failure and the segment it hit, for the diagnostics record. The take answers with the same error.

Implementations§

Source§

impl TakeSegmenter

Source

fn run(self, finish: &Receiver<FinishTake>)

Source

fn poll_cut(&mut self)

Cut the next window once enough audio has accrued past the last one - the only poll that copies, since a boundary arrives every 30 to 60 seconds against a 250 ms poll, and the early return is exactly next_cut’s own short-circuit. The decision runs the same function whole-buffer windowing does, over a copy of the uncut region, so a live cut lands exactly where the finished take’s would.

Source

fn submit_region(&mut self, pcm: Vec<f32>)

Silence-gate a region and queue it, recording whichever part it became. cuts and parts advance together, so the diagnostics record can name every segment’s span and raw text.

Source

fn collect_ready(&mut self)

Take every answer already waiting, in submission order.

Source

fn drain_pending(&mut self)

Wait out every answer still owed, in submission order. Only finish calls this, and the worker answers every job it takes, so this terminates.

Source

fn record(&mut self, answer: Result<Outcome, Error>)

Source

fn stamp_settled(&mut self)

Source

fn finish(self, finish: FinishTake)

Complete the take: wait out the remaining segments, submit the tail, and normalize the join once. The answer lands on the take’s channel as its last act; the only earlier output is the progress tally gaining its total.

Source

fn normalize_join( &self, joined: &str, options: NormalizeOptions, ) -> Result<Outcome, Error>

Queue the join for normalization on the worker and wait it out. No silence gate: the job carries text, not audio, and the gate reads samples.

Auto Trait Implementations§

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
§

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.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

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.
§

impl<T> WithSubscriber for T

§

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
§

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

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