Tutorial

Installation

Not needed if you have followed the setup instructions for our ASR Labs

To use openfst-python, we can simply install it with pip:

$ pip install openfst-python

Lab-specific documentation: an overview

Lab 1: Building HMMs with OpenFst

See the full documentation at Lab 1: Basic FST Manipulation.

Note

Please go to the github repo to view the jupyter notebook file for this lab.

There are three classes used in Lab 1: _MutableFst, the main class for a “mutable” FST (ie. one that can be dynamically modified in the code); Arc, which is the arc object used to connect states in an FST; and SymbolTable, which maps input or output strings to the integer IDs used as arc labels by OpenFst.

openfst_python.pywrapfst.SymbolTable([name])

Mutable SymbolTable class.

openfst_python.pywrapfst._MutableFst

(No constructor.)

openfst_python.pywrapfst.Arc(ilabel, olabel, ...)

This class represents an arc while remaining agnostic about the underlying arc type.

Lab 2: FST with Weights

See the full documentation at Lab 2: Computing HMM probabilities with FST weights.

Note

Please go to the github repo to view the jupyter notebook file for this lab.

The essential class for this lab is Weight, and all weights are instances of this class.

openfst_python.pywrapfst.Weight(weight_type, ...)

FST weight class.

Labs 3 and 4: Viterbi decoding

There is no additional documentation specific to either of these labs.

Labs 5: WFST operations

See the full documentation at Labs 5: WFST operations.

Note

Please go to the github repo to view the jupyter notebook file for this lab.

This lab introduces several WFST operations. You’ll see how these can be used to implement solutions to the problem of matching phoneme sequences to entries in a lexicon, and also incorporating a grammar. We use the following operations:

openfst_python.pywrapfst.determinize

determinize(ifst, delta=1e-6, det_type="functional",

openfst_python.pywrapfst.compose(ifst1, ifst2)

Constructively composes two FSTs.

openfst_python.pywrapfst.shortestpath

shortestpath(ifst, delta=1e-6, nshortest=1, nstate=NO_STATE_ID,

openfst_python.pywrapfst._MutableFst.minimize(self)

Minimizes the FST.

openfst_python.pywrapfst._MutableFst.project(self)

Converts the FST to an acceptor using input or output labels.

openfst_python.pywrapfst._MutableFst.rmepsilon

rmepsilon(self, queue_type="auto", connect=True, weight=None,

openfst_python.pywrapfst._MutableFst.arcsort(self)

Sorts arcs leaving each state of the FST.