Skip to main content

Crate forge_dictate

Crate forge_dictate 

Source
Expand description

Local dictation: audio in, text out.

The crate owns its model files, speech recognition and text normalization, and knows nothing about the program embedding it.

prepare fetches whatever models a Config names and checks each one against its recorded size and SHA-256 before anything opens it. A file whose size and modification time still match a digest already verified against that same spec is not read again. A truncated model does not fail at download time; it fails much later, inside a model runtime, as an offset error that reads like a bad build. Verifying first is what turns that into a sentence naming the file.

§Audio is 16 kHz mono

A take is fed mono frames at 16 kHz; the device half - opening an input, downmixing its channels, resampling - is forge-capture’s, wherever a host opens it. Rate conversion is not implemented, so an AudioSource declaring another rate is refused rather than silently resampled. Adding it means a real filtered resampler (rubato), because decimating without one folds everything above the new Nyquist back into the speech band and yields confident wrong words instead of obvious noise.

§Every entry point here blocks

This crate is runtime-agnostic on purpose, so nothing in it is async and nothing in it may be called from a runtime thread. An async caller wraps each entry point in tokio::task::spawn_blocking or its equivalent. Calling one directly from an async context panics in a debug build (“Cannot drop a runtime in a context where blocking is not allowed”) and, worse, succeeds in a release build having held a runtime worker for the entire operation - so a release smoke test passes while dev crashes.

Re-exports§

pub use audio::AudioSource;
pub use audio::Samples;
pub use config::Config;
pub use config::ConfigBuilder;
pub use config::ModelFacts;
pub use config::ModelSpec;
pub use config::spec_for_download;
pub use engine::Capture;
pub use engine::CaptureMeter;
pub use engine::Engine;
pub use engine::FrameSink;
pub use engine::Outcome;
pub use engine::Stages;
pub use engine::StreamCapture;
pub use engine::Ticket;
pub use engine::Transcript;
pub use engine::WindowProgress;
pub use error::Error;
pub use fetch::Progress;
pub use fetch::prepare;
pub use normalize::NormalizeError;
pub use normalize::NormalizeOptions;
pub use normalize::Normalizer;

Modules§

audio 🔒
The audio a transcription reads from.
bench
The bench’s corpus: the audio a run scores against, taken from this machine’s own material and from the slice the binary carries.
capture 🔒
The take’s own sample buffer: what a host’s pushed frames grow, and what the segmenter cuts windows off.
catalogue
The transcribe.cpp catalogue: the per-variant feed the runtime publishes.
cleanup
The cleanup feed: the normalizers the Hub carries, as the page’s cleanup candidates.
config 🔒
Configuration for a dictation engine.
diagnostics 🔒
Per-take diagnostics written to disk, best-effort.
engine 🔒
The transcription engine and the tickets it hands back.
error 🔒
Error taxonomy for the crate.
fetch 🔒
Model fetch: download, resume, and verify before use.
normalize
Repairs raw speech-recognition output into written text.

Structs§

CancelToken
A clonable cancellation handle. Clones share one underlying flag, so a worker thread can hold a clone and cancel a run executing on another thread.

Constants§

SAMPLE_RATE
Sample rate every model in this crate expects, which is the rate capture opens a device at: one constant, so the two cannot drift. Sample rate every model in forge reads, and the rate open delivers.

Functions§

resample_mono
A buffer at another rate, brought to SAMPLE_RATE with the capture path’s own filtered resampler: the one way a source declaring another rate becomes a source this crate accepts. A buffer of mono audio at from, converted to to with the input path’s own filter. The same rate hands the buffer straight back.