Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub models_dir: Option<PathBuf>,
    pub asr_model: ModelSpec,
    pub normalizer: Option<ModelSpec>,
    pub normalize_options: NormalizeOptions,
    pub language: Option<String>,
    pub max_capture: Duration,
    pub silence_floor: f32,
    pub diagnostics_dir: Option<PathBuf>,
    pub digest_cache_dir: Option<PathBuf>,
}
Expand description

Configuration for one dictation engine.

Construct via ConfigBuilder rather than populating directly. Values are validated where they are used, never here: an unreadable models directory surfaces from crate::prepare, not from ConfigBuilder::build.

Fields§

§models_dir: Option<PathBuf>

Directory holding model files. None resolves to a subdirectory of the platform cache directory.

§asr_model: ModelSpec

Speech recognition model.

§normalizer: Option<ModelSpec>

Model that rewrites raw recognition output into clean text. None leaves the recognition output as-is and fetches nothing for it.

When set, the engine loads it beside the recognition model and rewrites every transcript: crate::Transcript::text carries the result and asr the recognised text it came from. When None the two are equal, which is a supported configuration rather than a degraded one.

§normalize_options: NormalizeOptions

How the normalizer rewrites text, when one is configured.

styling is the axis a person picks per recording; k and ngram are decoder tuning and do not belong in a user-facing picker beside it. Overridable per call via crate::Engine::transcribe_with, so this is the default rather than a fixed choice.

§language: Option<String>

Spoken language hint. None autodetects.

§max_capture: Duration

Upper bound on a single capture. A capture nobody stops ends itself here rather than holding the input device indefinitely.

Costs memory eagerly: the whole cap is reserved when recording starts, at 4 bytes a sample, so the 30 min default reserves about 110 MiB and an hour reserves 219 MiB, whatever the utterance turns out to be. Reserved rather than grown because the audio callback must not allocate. Clamped to an hour.

§silence_floor: f32

Peak input level, in dBFS, below which a capture counts as silence rather than as an empty transcript.

§diagnostics_dir: Option<PathBuf>

Directory the crate writes per-take diagnostics into: the capture audio and every transcription stage, best-effort, under crate::diagnostics. None writes nothing - diagnostics are the host’s choice of directory, never a requirement.

§digest_cache_dir: Option<PathBuf>

Directory the crate records verified model digests in, keyed on each file’s size and modification time, so a file unchanged since it was last verified is not read end to end again.

None disables the cache and hashes every time: a caller with no machine-local directory of its own to put it in keeps the old cost rather than having one invented for it.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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