Expand description
The transcription engine and the tickets it hands back.
Re-exportsΒ§
use std::path::Path;πuse std::path::PathBuf;πuse std::sync::atomic::AtomicBool;πuse std::sync::atomic::Ordering;πuse std::sync::mpsc::Receiver;πuse std::sync::mpsc::RecvTimeoutError;πuse std::sync::mpsc::Sender;πuse std::sync::mpsc::channel;πuse std::sync::Arc;πuse std::sync::Condvar;πuse std::sync::Mutex;πuse std::sync::Once;πuse std::sync::PoisonError;πuse std::time::Duration;πuse std::time::Instant;πuse transcribe_cpp::CancelToken;πuse transcribe_cpp::Feature;πuse transcribe_cpp::Model;πuse transcribe_cpp::RunOptions;πuse transcribe_cpp::Session;πuse crate::audio::AudioSource;πuse crate::audio::SAMPLE_RATE;πuse crate::diagnostics;πuse crate::normalize::NormalizeOptions;πuse crate::Config;πuse crate::Error;π
StructsΒ§
- Capture
- One take in flight: the recording it grows, its segmenter, and the
channels
finishhands on. - Capture
Meter - The polling view of a live capture: the level read and the cap
flag, over a shared handle to the recording.
SyncandSend, so an async host can hold it across await points. - Engine
- Loads the models and runs transcriptions, one at a time.
- Finish
Take π - What the host hands a pipelined take at finish: the normalizer options for the one join pass, and whether the recording stopped itself at the cap.
- Frame
Sink - The write half of a stream-fed take.
- Job π
- One queued transcription.
- JobOutcome π
- What one jobβs answer and diagnostics record come to.
- Loaded π
- Every configured model, in memory.
- Readiness π
- How the weights ended up, once the worker has resolved them.
- Stages
- Where the time went in one transcription.
- Stream
Capture - A take fed by frames from somewhere other than a device: what
Engine::capture_streamhands back. - Take
Parts π - The take side both capture paths share, from
Engine::begin_take: the recording samples land in, the segmenter cutting it, and the channels a capture hands on at finish. - Take
Segmenter π - 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.
- Take
Shared π - The channels a takeβs segmenter shares with its capture and ticket.
- Take
State π - The takeβs accumulated state across its windows.
- Ticket
- A transcription in flight. On the pipelined capture path this is the takeβs AGGREGATE: it resolves once every segment and the tail have run and the join has been normalized once.
- Transcript
- Clean text, plus what it was before normalization.
- Window
Progress - How far a takeβs transcription has got, for a host that shows
progress while the recording runs.
donecounts the segments that have settled, in order;totalisNoneuntil finish has submitted the tail, because a live recording does not know how many segments it will produce. A single-segment take reports twice at stop, at 0 of 1 and 1 of 1, and no host has to special-case it.
EnumsΒ§
- Aggregate π
- What a takeβs settled parts come to, before normalization.
- Outcome
- What a finished transcription produced.
- Part π
- One settled piece of a pipelined take, in submission order.
- Window
Action π - What one windowβs run outcome tells the take to do next.
ConstantsΒ§
- ENERGY_
FRAME π - 20 ms energy frames for pause-seeking.
- SEGMENT_
POLL π - How often the segmenter looks for the next window boundary. The cut
needs no samples past
WINDOW_TARGETafter the previous cut, so this cadence bounds how long a segment can run past its ideal cut. - WINDOW_
MIN π - Shortest a sought window may be, so pause-seeking cannot shred a take into fragments too short to transcribe well. The takeβs final window is exempt: it is whatever audio is left.
- WINDOW_
TARGET π - Long takes are transcribed in windows rather than as one pass: the recognition runtime decodes a whole buffer against one encoder output, and past about two minutes the decoder derails into repetition loops and skip-ahead re-syncs that drop mid-take audio with nothing flagged. The ceiling is measured, not assumed: a four-minute ten-paragraph take loses whole paragraphs at a 90 s ceiling and lands complete at 60 s, so 60 is the shipping value.
StaticsΒ§
- ROUTE_
NATIVE_ πLOGS - Native diagnostics are routed once per process, before any model is loaded: unrouted, one load plus one inference writes 122 lines straight to stderr and corrupts any host that owns it.
FunctionsΒ§
- aggregate_
parts π - Fold a takeβs parts in submission order. A failure fails the take only when no part produced words; when any part did, the take keeps them and carries the first failure to the caller, which marks the transcript truncated. A cancel is the one exception: an abandoned take keeps nothing. Any recognized part sends the take down the join path, and only a take with nothing above the floor anywhere reads as silence.
- audio_
duration π - Samples to wall-clock at the one rate the models accept. Integer maths so a long buffer cannot drift through a float cast.
- diagnostic_
outcome π - The store entry a jobβs answer earns:
Nonekeeps nothing. - failure_
before_ πanswer - The failure a job answers with, decided before its answer is built.
- finalize_
transcript π - The joined raw recognition, and the rewritten text over it, in that order. The order is load-bearing: the normalizer reads the whole take at once, so a sentence crossing a window boundary is repaired with full context - normalizing per window would rewrite each fragment without the context around the cut.
- finish_
after_ πjoin - The answer a finished join amounts to.
- finish_
job π - Finish one job: read its token, build the answer, decide its record.
- fold_
stages π - Sum of the partsβ recognition work, for the takeβs own stages and the diagnostics record.
- join_
window_ πtexts - Window texts back into one transcript. Trims and drops empties, so a silent stretch inside a take vanishes at the join instead of leaving a doubled space.
- keep_
job_ πrecord - Keep one direct jobβs diagnostics record.
- kept_
diagnostics π - The store entry a finished answer earns, read with the cancel token at the write decision.
- load_
models π - Load the recognition model, and the normalizer when one is configured.
- next_
cut π - Where the next window past
startends, once more thanWINDOW_TARGEThas accrued past it: the quietestENERGY_FRAMEblock betweenWINDOW_MINandWINDOW_TARGETpaststart.Nonewhile the region is still short. - normalize_
text π - Rewrite recognition output, recording what it cost.
- peak_
dbfs π - Loudest sample in
pcm, in dBFS. - quietest_
frame π - Sample offset of the quietest
ENERGY_FRAMEblock by summed square. Ties go to the latest block, so a window runs as long as the reliability ceiling allows and a flat pause cuts at its end. Zero for a region shorter than one block. - take_
is_ πtruncated - Whether a take that kept some words is still incomplete: a segmentβs own truncation, the capture cap, or a failed segment.
- window_
action π - window_
bounds π - Sample ranges tiling
pcm, each at mostWINDOW_TARGETlong, cutting at the quietestENERGY_FRAMEblock betweenWINDOW_MINandWINDOW_TARGETpast the previous cut. A take that fits one window comes back whole, which is the exact buffer the recognition runtime saw before windowing existed. - worker π
- Owns the weights and drains the queue.