Skip to main content

Module ctc

Module ctc 

Source
Expand description

The decoding graph for a CTC model.

A CTC model emits one symbol per frame from an alphabet that includes a blank, and the transcript is recovered by collapsing runs of the same symbol and then deleting the blanks, so _ a a _ a b reads as a a b. Note where the blank matters: it is what separates the two as. Without it the run would collapse to one.

As an FST that rule is a graph of V + 1 states, one per symbol the model could have emitted last, plus the state meaning “the last thing was a blank”. ctc_topo builds it. Composing it with the acoustic matrix and taking the best path is CTC decoding; composing the two of them with a lexicon and a language model instead is the rest of a recogniser, and this is the piece it starts from.

This is k2’s k2.ctc_topo(max_token, modified=False). The modified topology, which lets a frame be skipped, is not here.

Functions§

collapse
The CTC collapsing rule applied to a sequence of columns: runs of the same symbol become one, then the blanks go.
ctc_topo
Builds the CTC topology for a model with num_symbols columns, blank first.