pub struct AlignChain { /* private fields */ }Expand description
Implementations§
Source§impl AlignChain
impl AlignChain
Sourcepub const HOLD_BLANK: u8 = 0
pub const HOLD_BLANK: u8 = 0
The transition that stays put and says nothing: silence, or a phone that has not started.
Sourcepub const HOLD_PHONE: u8 = 1
pub const HOLD_PHONE: u8 = 1
The transition that stays put sounding the phone it is on.
Sourcepub fn new(phones: impl Into<Vec<u32>>) -> Self
pub fn new(phones: impl Into<Vec<u32>>) -> Self
A reference every phone of which has to be given frames.
Skipping is forbidden until a caller asks for it, because a skip cost is
a claim about the phone; see with_skip_costs.
Column 0 is the blank, which is where a CTC model puts it;
with_blank moves it.
Sourcepub fn with_skip_costs(self, costs: &[f32]) -> Result<Self, OpenFstError>
pub fn with_skip_costs(self, costs: &[f32]) -> Result<Self, OpenFstError>
The cost of giving up each position, one per phone.
An infinite cost forbids the skip, and new leaves one
everywhere. A finite cost is a threshold: the phone is dropped
only when keeping it costs strictly more, so the number that matters is
how much acoustic evidence the phone is worth.
Skip costs belong to individual phones rather than to the utterance as a whole, so callers can make only the appropriate positions optional.
§Errors
A count that is not the number of phones, or a cost below zero or not a number. A negative cost would pay the alignment to throw the reference away.
Sourcepub fn with_uniform_skip_cost(self, cost: f32) -> Result<Self, OpenFstError>
pub fn with_uniform_skip_cost(self, cost: f32) -> Result<Self, OpenFstError>
Sourcepub fn with_blank(self, column: u32) -> Self
pub fn with_blank(self, column: u32) -> Self
The column meaning “no phone is sounding”. Column 0 by default.
Sourcepub fn num_phones(&self) -> usize
pub fn num_phones(&self) -> usize
The number of phones in the reference.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the reference is empty, in which case every frame is blank.
Sourcepub fn skip_costs(&self) -> &[f32]
pub fn skip_costs(&self) -> &[f32]
The cost of giving up each position, in order.
Sourcepub fn against<'a, A>(
&'a self,
dense: &'a DenseFst<'a, A>,
) -> Result<ChainTrellis<'a, A>, OpenFstError>
pub fn against<'a, A>( &'a self, dense: &'a DenseFst<'a, A>, ) -> Result<ChainTrellis<'a, A>, OpenFstError>
The chain against a matrix of scores, ready to be solved.
align is this plus best_path plus reading the answer back into
phones. Call it directly to get at the Path, whose codes are the
four below and whose positions are reference positions, or to run
posteriors with an accumulator of your
own.
§Errors
A phone, or the blank, naming a column the acoustic model does not have. Checked once here so that solving never has to.
Sourcepub const fn sounds(code: u8) -> bool
pub const fn sounds(code: u8) -> bool
Whether a transition sounds the phone of the position it lands in.
The four codes are listed best-first, which is the tie-break; see
ChainTrellis::steps_into.
§Panics
On a code this chain has no transition for.
Sourcepub fn to_fst<A: Arc>(
&self,
label_offset: i64,
) -> Result<VectorFst<A>, OpenFstError>
pub fn to_fst<A: Arc>( &self, label_offset: i64, ) -> Result<VectorFst<A>, OpenFstError>
The chain as an ordinary FST, so it can go through the decoders in this crate or be composed like anything else.
label_offset has to be the one the
DenseFst was built with. It is 1 by default,
because label 0 is epsilon to every FST algorithm and a blank is not one.
Input labels are the columns, offset.
Output labels name what the frame sounded: p + 1 for position p, and
N + 1 for a frame that sounded nothing. Every arc carries one, so a
decoded path’s output labels are one per frame and are the alignment
itself, which Alignment::from_output_labels reads back. That is what
makes lattice_decode and
n_best over this FST produce alternative
alignments, which the exact aligner, returning one answer, does not.
align is what to use to align. This exists to put the chain in front
of the rest of the library, and it is also the oracle the exact aligner
is tested against, since the two share no code.
§Errors
A label that does not fit the arc’s label type, or an offset below 1, which would put a column on epsilon and so on an arc consuming no frame.
Trait Implementations§
Source§impl Clone for AlignChain
impl Clone for AlignChain
Source§fn clone(&self) -> AlignChain
fn clone(&self) -> AlignChain
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more