Skip to main content

Module align

Module align 

Source
Expand description

Exact forced alignment against a known reference.

The reference is a sequence of N phone columns and the acoustic model has scored T frames. Alignment assigns frames to phones by searching a single chain rather than a lattice of possible transcripts.

§Chain topology

States s_0 … s_N, where s_i means “the first i phones are behind us”. s_0 is the start, s_N is the only final state, and four transitions leave each state, every one of them consuming exactly one frame:

transitionreadsgoes tocostsmeans
hold blankblanks_i0silence, or phone i + 1 has not started
hold phonephone is_i0phone i is still sounding (i ≥ 1)
commitphone i + 1s_{i+1}0phone i + 1 starts in this frame
skipblanks_{i+1}skip(i + 1)phone i + 1 never happens

A skip makes a phone optional at a caller-supplied cost. Skipping is disabled by default; see AlignChain::with_skip_costs.

Every transition consumes one frame and advances at most one phone. A path of T frames can therefore occupy position i at frame t only when t - (T - N) <= i <= t. band covers exactly those reachable cells, so align needs no beam or pruning threshold.

The solver reads the original acoustic columns directly. It does not widen the score matrix to distinguish transitions that read the same phone or blank column, and it stores the four transition codes in two bits each.

§Custom topologies

trellis supplies the banded Viterbi and forward-backward solvers independently of this chain. Implement Trellis for constraints such as minimum duration or multi-phone skips. AlignChain::against exposes this module’s trellis when the raw Path or posteriors are needed.

Structs§

AlignChain
A reference to align: the phones in order, and what each one costs to give up.
Alignment
Which phone each frame sounded.
ChainTrellis
AlignChain against a matrix of scores: the trellis align solves.

Functions§

align
Aligns chain to dense: the best path of the chain against the acoustic scores, exactly.