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: usizeFirst 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: usizeHow 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
impl TakeSegmenter
fn run(self, finish: &Receiver<FinishTake>)
Sourcefn poll_cut(&mut self)
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.
Sourcefn submit_region(&mut self, pcm: Vec<f32>)
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.
Sourcefn collect_ready(&mut self)
fn collect_ready(&mut self)
Take every answer already waiting, in submission order.
Sourcefn drain_pending(&mut self)
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.
fn record(&mut self, answer: Result<Outcome, Error>)
fn stamp_settled(&mut self)
Sourcefn finish(self, finish: FinishTake)
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.
Sourcefn normalize_join(
&self,
joined: &str,
options: NormalizeOptions,
) -> Result<Outcome, Error>
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.