DNN-HMM Hybrid Acoustic Models

A hidden Markov model tracks time. A frame scorer reads each 10 ms of sound. In 2012 a deep network replaced the old Gaussian scorer, and on one Switchboard test the word error rate fell from 27.4% to 18.5%.

Learn how the two parts fit, and the one division that lets a neural network plug into a 1990s decoder.

Pick a frame scorer, then press Decode. The same decoder reads the word “cat” from the same 16 frames. Count the red frames. Then we build each part from zero: the time model, the Gaussian scorer, the division by the prior, Viterbi, alignment and training.

You need what a probability is, what a softmax does and a little Python. We build the rest from zero.

The Switchboard numbers come from Hinton et al., Deep Neural Networks for Acoustic Modeling in Speech Recognition (IEEE Signal Processing Magazine, 2012), Table II. The 16 frames of “cat” are a toy made for this page.

Decode one word three ways

Illustrative toy: hand-made scores for 16 frames, a 5-state chain (sil, k, ae, t, sil), self-loop 0.6, decoded with Viterbi. The green line is the true timing. The real-world result is in Chapter 8.

Chapter 0

A Stream of Frames, and No Words

See why a classifier that reads one frame at a time cannot spell a word

Someone says “cat” into a microphone. The sound card samples the air pressure 16,000 times a second. Nobody reads words off raw samples. So every speech system first cuts the signal into short windows, one every 10 ms, each about 25 ms long.

Each window becomes a short vector of numbers that describe its spectrum. That vector is a frame. Half a second of speech is about 50 frames. The acoustic model is the part that looks at the frames and says which speech sounds made them.

The first idea is a classifier that looks at one frame and names its sound. It fails. The middle of the vowel in “cat” looks almost the same in “bat”. One sound lasts many frames, and its length changes with how fast the person talks. A classifier with no memory of time flips between labels.

Read the same scores two ways

Each column is one frame; each row is a sound. Bright cells are sounds the frame looks like. Switch between a per-frame guess and a decode that knows sounds last.

Illustrative toy: random scores around a true sequence sil, k, ae, t, sil. The time model is an HMM that stays in a sound with probability 0.85 at each frame.

Classical speech recognition splits the problem in two. A hidden Markov model (HMM) handles time: sounds last several frames and come in a fixed order. An emission model handles appearance: given a sound, how likely is this frame? First a Gaussian mixture did that job, then a deep neural network. The pair is the DNN-HMM hybrid.

The failure, as symptom, measurement and fix

The symptom is a transcript like “k a k a t a t” for one short word. To measure it, count label changes per second against a real speaking rate of about 10 to 15 sounds a second. The fix is a time model that makes each change cost something.

The road

  1. The HMM: states, self-loops and how long a sound lasts.
  2. GMM emissions: a frame scored by a mixture of Gaussians.
  3. Divide by the prior: the one step that lets a DNN replace the GMM.
  4. Viterbi: the best path through the frames.
  5. Forced alignment: frame labels from a known transcript.
  6. Training the hybrid: align, train, realign.
  7. The showcase: a full decoder with every knob.
  8. What the swap bought: the 2012 Switchboard numbers.
  9. Why CTC won: one path against all paths.
  10. The field guide: terms, numbers, code and links.
A classifier names the sound of each frame on its own. Why does its transcript of one word come out jittery?

Chapter 1

The HMM: a Machine for Time

Give each sound three states and a self-loop, and see how one number sets how long a sound lasts

The time half of the machine never looks at the audio. It knows three things: which states exist, how the state may change from one frame to the next, and nothing else. The audio enters later, through the emission model.

A phone is one speech sound, like the “k” in “cat”. The standard recipe gives each phone three states: a beginning, a middle and an end. A “k” starts as a silent closure, bursts, then slides into the vowel. One state per part fits each part well.

Speech uses a left-to-right HMM. At each frame a state either stays (a self-loop) or moves to the next state. It never goes back.

Call the self-loop probability a. Then the chance of moving on is 1 − a. How long does a state last? Call that length in frames d.

Say it aloud

P of d equals a to the power d minus one, times one minus a.

P(d)
P of d the chance that the state lasts exactly d frames.
a
a the self-loop probability, between 0 and 1. It is a fixed number, set in training.
d − 1
to the power d minus one the state stays d − 1 times before it leaves.
1 − a
one minus a the chance of moving on, paid once at the last frame.
In plain words

Multiply a by itself once for each extra frame the state stays. Then multiply by 1 − a for the step that leaves. The average length is 1 / (1 − a) frames.

With numbers

With made-up a = 0.7: P(2) = 0.7 × 0.3 = 0.21, and P(4) = 0.7 × 0.7 × 0.7 × 0.3 = 0.103. The average is 1 / 0.3 = 3.3 frames, or 33 ms.

Set the self-loop, watch the length

Bars show P(d) for one state. Raise the self-loop and sounds linger. Press Sample a phone to draw one random walk through the three states.

0.70

Exact P(d) from the equation; one frame is 10 ms. The sampled walk is random.

Look at the bars. A length of one frame is always the most likely, and longer lengths fade away. That shape is a geometric distribution. Real sounds have a typical length, not a peak at one frame. The HMM accepts this error because it is cheap. Three states in a row soften it: their sum has a hump.

The failure, as symptom, measurement and fix

The symptom is phones decoded too short or too long for the speaker. To measure it, compare decoded phone lengths with aligned training lengths. The fix is to train a per state from the data: a = 1 − 1 / (average frames in that state).

A state has self-loop a = 0.8. What is the chance it lasts exactly 3 frames?

Chapter 2

GMM Emissions: Scoring a Frame

Score how well one state explains one frame with a weighted sum of bell curves

The HMM needs one number it cannot make: how likely is this frame if we are in this state? That number is the emission likelihood. For about twenty years a Gaussian mixture model (GMM) supplied it, one GMM per state.

Start with one bell curve, in one dimension so we can draw it. Call the frame value x. Call the centre of the bell μ (mu) and its width σ (sigma).

Say it aloud

N of x, with mu and sigma, equals one over sigma root two pi, times e to the minus x minus mu squared, over two sigma squared.

N(x; μ, σ)
N of x with mu and sigma the height of the bell at the frame value x: a density.
x
x the frame value. A real frame has 13 to 40 numbers; here it has one.
μ
mu the centre of the bell: the typical frame for this state.
σ
sigma the width of the bell. A small sigma makes a tall, narrow bell.
√(2π)
root two pi about 2.507, a fixed number that makes the area under the bell equal 1.
exp
e to the the exponential. The farther x is from mu, the smaller it gets.
In plain words

Take the distance from x to mu. Square it and divide by 2 sigma squared. Raise e to minus that. Multiply by the peak height 1 / (sigma root two pi).

With numbers

With made-up μ = 2, σ = 1, x = 2.5: the distance is 0.5, squared 0.25, over 2 gives 0.125. exp(−0.125) = 0.8825. The peak height is 1 / 2.507 = 0.399. N = 0.399 × 0.8825 = 0.352.

One bell is too rigid. Frames of one state come from many speakers and microphones, so they form several clumps. A GMM adds several bells. Call bell number m's weight wm; the weights add up to 1. Call the state s.

Say it aloud

p of x given s equals the sum over m of w-m times N of x with mu-m and sigma-m.

p(x | s)
p of x given s the emission likelihood: how well state s explains frame x.
Σm
the sum over m add one term per bell. The 2012 Switchboard GMM used 40 bells per state.
wm
w-m the weight of bell m: its share of the state's frames.
N(x; μm, σm)
N of x with mu-m and sigma-m the height of bell m at x, from the first equation.
In plain words

Score the frame x under each bell. Multiply each score by that bell's weight w-m. Add them. The total is p(x | s).

With numbers

With made-up bells A (μ = 2, σ = 1, w = 0.6) and B (μ = 5, σ = 1, w = 0.4) and x = 2.5. A gives 0.352 and B gives 0.0175. p = 0.6 × 0.352 + 0.4 × 0.0175 = 0.211 + 0.007 = 0.218. The near bell does almost all the work.

Drag a frame across one state's GMM

The orange curve is p(x | s) for one state; the dashed curves are its two weighted bells. Drag the frame. Then narrow bell A and watch the peak pass 1.

2.50
1.00

Exact densities from the two equations, with made-up bells.

Two facts matter for the next chapter. A GMM gives a likelihood, p(x | s), which is the number the HMM wants. And each state's GMM works alone: state k's score does not depend on state j's. The states do not compete.

The failure, as symptom, measurement and fix

The symptom is a log score of plus infinity or a crash on one odd frame. A bell with a tiny sigma has collapsed onto a few training frames. To measure it, log the smallest sigma per state. The fix is a floor on each variance.

Why can the HMM use a GMM's output directly, but not a softmax network's output?

Chapter 3

The DNN Swap: Divide by the Prior

Turn a network's posterior into the likelihood the HMM wants with one division

A deep network reads frames better than a GMM. It takes a window of frames, the current one and its neighbours, and ends in a softmax over all states. Its output is a posterior, P(s | x): given this frame, how likely is each state?

The HMM wants the other direction, p(x | s). Bayes' rule links them. Call the share of training frames that belong to state s its prior, P(s). Call the overall chance of the frame p(x).

p(x | s) = P(s | x) · p(x) / P(s)

At one frame, p(x) is the same for every state. Viterbi only compares states at the same frame, so p(x) changes nothing and we drop it. What stays is the scaled likelihood; call it ℓ(s).

Say it aloud

ell of s equals P of s given x, divided by P of s.

ℓ(s)
ell of s the scaled likelihood: p(x | s) divided by p(x). The HMM uses it as the emission.
P(s | x)
P of s given x the network's softmax output for state s at this frame.
P(s)
P of s the prior: frames labelled s in the training alignment, divided by all frames.
In plain words

Count how often each state s appears in the training labels; that is P(s). At each frame, divide the network's output P(s | x) by P(s). Feed ℓ(s) to the HMM in place of the GMM score.

With numbers

With made-up posteriors 0.50, 0.30, 0.15, 0.05 and priors 0.40, 0.20, 0.30, 0.10: ℓ = 1.25, 1.50, 0.50, 0.50. By posterior, state 0 wins. After the division, state 1 wins.

Why does the winner change? The network learned that state 0 fills 40% of all frames. Part of its 0.50 is “state 0 is common”, not “this frame looks like state 0”. The division removes that base rate. In code it is a subtraction in log space: log ℓ(s) = log P(s | x) − log P(s).

Divide and see who wins

Purple is the network's posterior; yellow is the prior; orange is the posterior divided by the prior. Raise state 0's posterior until it wins after the division too.

0.50
0.30
0.15

Made-up numbers. State 3 takes what is left so the posteriors add to 1. Priors are fixed at 0.40, 0.20, 0.30, 0.10.

Bourlard and Morgan's 1993 book on hybrid recognition gave this rule. Hinton et al. (2012) state it plainly: divide the network's outputs by the frequencies of the states in the forced alignment used for training. They add that it changes little on some tasks. It matters when one label dominates, as with many frames of silence.

The failure, as symptom, measurement and fix

The symptom is a decoder that pads every word with silence and drops short sounds. To measure it, compare the decoded share of silence frames with the prior of silence. The fix is the division, done once per frame in log space.

A network gives P(s | x), and the HMM needs p(x | s). Up to a factor that is the same for every state at this frame, how do you convert?

Chapter 4

Viterbi: the Best Path Through the Frames

Fill a grid of frames by states one column at a time, then trace the winning path back

Now we have both halves: transition numbers from Chapter 1 and an emission score for every state at every frame. Which sequence of states explains the frames best? Trying every sequence is hopeless: 3 states over 100 frames give 3100 sequences.

Viterbi decoding keeps only one number per cell of a grid, the best score of any path that ends there. Rows are states, columns are frames. We work in logs, so products become sums. Call the best log score of a path that ends in state s at frame t δt(s).

Say it aloud

delta-t of s equals log ell-t of s, plus the max of: delta t-minus-one of s plus log a, and delta t-minus-one of s-minus-one plus log of one minus a.

δt(s)
delta-t of s the best log score of any path that is in state s at frame t.
log ℓt(s)
log ell-t of s the log emission of state s at frame t: a GMM score or a scaled network score.
max
the max of keep the larger of the two ways in. Remember which one won: the backpointer.
δt−1(s) + log a
delta t-minus-one of s plus log a the path stayed in s. log 0.7 = −0.36.
δt−1(s−1) + log(1 − a)
delta t-minus-one of s-minus-one plus log of one minus a the path moved in from the state before. log 0.3 = −1.20.
In plain words

For each cell, look left at the two cells that can reach it. Add each one's delta to its transition cost and keep the larger. Add the cell's own emission. At the last frame, start at the best cell and follow the backpointers left.

With numbers

With made-up emissions, frame 1: A = −0.2; frame 2: A = −1.5, B = −0.3. Start in A, so δ1(A) = −0.2. Then δ2(A) = −0.2 − 0.36 − 1.5 = −2.06, and δ2(B) = −0.2 − 1.20 − 0.3 = −1.70. B wins: the sound moved on.

Step Viterbi one frame at a time

Each cell shows its emission (small) and its delta once filled (large). Press Step to fill the next column; the arrows are backpointers. The last step traces the path.

Made-up log emissions; self-loop 0.7. Frames 1 and 2 are the worked example above.

The cost is one comparison per cell: states times frames. Swap the max for a sum of probabilities and you get the forward algorithm, the total chance of the frames over all paths. In the example, the two frame-2 cells give 0.128 + 0.182 = 0.310. Training with EM uses the forward sum; decoding uses the max.

The failure, as symptom, measurement and fix

The symptom is a score of minus infinity, or a path that is all one state, on long utterances. Products of many small probabilities underflow to zero. To measure it, print the raw product after 500 frames. The fix is logs, as above.

At frame t, state B can be reached from A (score −3.0, move cost −1.2) or from B (score −3.5, stay cost −0.36). B's emission is −0.5. What is δt(B)?

Chapter 5

Forced Alignment: Frame Labels from a Transcript

Lock the order of states to the known words and let Viterbi find only the boundaries

To train a network you need a target for every frame: frame 17 is the middle of “k”, frame 18 is its end. The data has audio and a transcript, “cat”, but no frame labels. Nobody labels millions of frames by hand.

Forced alignment makes the labels. Join the phone HMMs of the transcript into one chain: k, then ae, then t. Run Viterbi on that chain only. The chain fixes which states come and in what order. Viterbi decides only when each state starts.

A hand example. Three frames must go to state A, then state B, each at least one frame. Only two alignments are legal: A A B and A B B. The made-up log scores are A = −1, −3, −5 and B = −4, −1, −1. Then A A B scores −1 − 3 − 1 = −5 and A B B scores −1 − 1 − 1 = −3. A B B wins: frame 2 looks like B, so the boundary moves left.

Place the boundaries on the timeline

Bright cells are frames that look like the state. The order A, B, C is fixed. Drag the two boundaries and watch the score, then press Viterbi align.

4
8

Made-up log emissions. Every legal alignment has two moves and nine stays. With one shared self-loop, transitions add the same amount to each, so only emissions decide.

Free decoding and forced alignment run the same program. Decoding searches the states of every possible word to answer “what was said?”. Alignment searches one known chain to answer “when was each part said?”.

There is a loop hidden here. Alignment needs an emission model. Training the emission model needs alignments. Chapter 6 breaks the loop.

The failure, as symptom, measurement and fix

The symptom is a label set where whole words sit in silence or one phone eats a second. A wrong transcript or a bad model forces sounds onto the wrong frames. To measure it, check the alignment score per frame and listen to the worst utterances. The fix is to drop or correct those utterances.

What does forced alignment take in, and what does it give back?

Chapter 6

Training the Hybrid: Align, Train, Realign

Break the loop between labels and model by fixing one and improving the other

The recipe has four steps. Toolkits such as Kaldi follow the same order.

  1. Bootstrap a GMM-HMM. Split each utterance evenly among its states and fit GMMs with EM. This system is a scaffold.
  2. Align. Force-align the whole training set with it. Every frame gets a state label.
  3. Train the network on those labels with frame cross-entropy.
  4. Realign with the network's scaled likelihoods, then train again.

Step 3 is ordinary classification. Call the label of frame t from the alignment s*t. Call the network's softmax output for state s at frame t yt(s). The loss is L.

Say it aloud

L equals minus the sum over t of log y-t of s-star-t.

L
L the frame cross-entropy loss, in nats. Lower is better; 0 means full confidence in every label.
Σt
the sum over t one term per training frame, millions of them.
log
log the natural log. log 1 = 0, and it falls fast as the probability falls.
yt(s*t)
y-t of s-star-t the probability the network gives to the aligned state of frame t.
In plain words

For each frame t, find the probability the network gives to its label s*-t. Take minus its log. Add over all frames. Gradient descent lowers L.

With numbers

With made-up outputs: the label is state 1 and the network gives it 0.50, so the frame costs −log 0.50 = 0.693. After training it gives 0.90, and the cost falls to 0.105.

Run the align and train loop

Dots are frame values; green ticks mark the true boundaries. Orange lines are the model's state centres. Alternate Align and Train until nothing moves.

Illustrative toy: the model is one Gaussian centre per state (σ = 1), a stand-in for the network. It starts from an even split. Align runs exact forced alignment; Train moves each centre to the mean of its frames.

Realignment pays off in the real system too. In Hinton et al. (2012), Table II, the Switchboard network trained on GMM alignments scored 19.6% word error on one test set. Retrained on its own alignments, it scored 18.6%.

The failure, as symptom, measurement and fix

The symptom is a network that stops improving at a mediocre frame accuracy. Its labels come from the weak GMM and hold its mistakes. To measure it, compare frame accuracy on GMM labels with accuracy on labels from the network's own realignment. The fix is one or two realignment rounds.

A frame's label is state 2 and the network gives it 0.6. What is the frame's loss, and what if the network improves to 0.95?

Chapter 7

Showcase: a Whole Decoder You Can Break

Turn the self-loop, the prior and the noise, and watch the best path change

Here is every part at once. A simulated network gives posteriors for 30 frames of “cat” with silence around it. The decoder divides by the priors, adds the transitions and runs Viterbi.

Real systems add one knob. Hinton et al. (2012) report that for Google Voice Input they had to smooth the priors. They multiplied the log priors by a number chosen by grid search. Call that number κ (kappa).

Say it aloud

log ell-t of s equals log P of s given x-t, minus kappa times log P of s.

log ℓt(s)
log ell-t of s the emission score Viterbi uses for state s at frame t.
log P(s | xt)
log P of s given x-t the log of the network's posterior at frame t.
κ
kappa the prior scale. 0 means no division; 1 means the full Bayes division.
log P(s)
log P of s the log prior of state s. It is negative, so subtracting it raises rare states most.
In plain words

Take the log posterior. Subtract kappa times the log prior. With kappa 1 this is Chapter 3's division; with kappa 0 the prior stays in.

With numbers

With made-up numbers: posterior 0.40 for “k”, prior 0.15. log 0.40 = −0.92 and log 0.15 = −1.90. With κ = 1: −0.92 + 1.90 = 0.98. With κ = 0.5: −0.92 + 0.95 = 0.03.

Decode, then break it

Heat is the emission score per state. Teal is the decoded path, green the truth, red marks wrong frames. Set kappa to 0, then raise the noise.

0.70
1.00
0.60

Illustrative toy. The fake network's posterior is a softmax of a match score plus the log prior, so it carries the base rate like a real one. Priors: sil 0.40, k 0.15, ae 0.30, t 0.15.

What to try. Set kappa to 0: silence starts to eat the edges of “k” and “t”. Drop the self-loop to 0.3: moves are cheap, so noisy frames pull the path off course sooner. Raise the noise past 1.5: the frame scores stop agreeing with the truth and no setting saves the decode.

The failure, as symptom, measurement and fix

The symptom is good frame accuracy on the test labels but too many deletions in the words. The prior scale or the self-loop is off for this data. To measure it, sweep kappa on held-out audio and plot word error. The fix is the grid search Hinton et al. describe.

You set kappa to 0 and silence frames spread into the word. Why?

Chapter 8

What the Swap Bought: Switchboard, 2012

Read the real error rates step by step, from the GMM to the deep network

Switchboard is a public set of recorded phone calls. Seide, Li and Yu (Interspeech 2011) trained on its standard 309 hours. Hinton et al. (2012) summarize the result in their Table II.

Both systems shared everything except the frame scorer: the same 9,304 tied states, the same three-state left-to-right phones, the same trigram language model. The baseline GMM had 40 Gaussians per state, trained first for likelihood and then with a discriminative criterion (BMMI). The network had 7 hidden layers of 2,048 units.

Climb the ladder of changes

Each bar is one system, each a change on the one before. Press Next change to add a row. Switch the test set to see that the pattern holds.

Word error rates in % from Hinton et al. (2012), Table II. All rows: 309 hours, speaker independent, one decoding pass. The dashed line is a GMM system with 2,000 hours, speaker adaptation and several passes.

Read the rows in order. A network with one hidden layer is worse than the GMM: 29.4% against 27.4%. A window of 11 frames helps. Depth gives the big drop. Realignment, Chapter 6, takes off one more point. The relative cut from 27.4% to 18.5% is 32%; the paper calls it 33%.

The dashed line is the striking part. The 309-hour network matched a GMM system trained on 2,000 hours with speaker adaptation and several passes (18.6%). Dahl et al. (2012) had built the same context-dependent recipe on 24 hours of Bing voice search; there, sentence error fell from 36.2% to 30.4%.

Task (Hinton et al. 2012, Table III)HoursDNN-HMMGMM-HMM, same data
Switchboard, test set 1 (RT03S-FSH)30918.527.4
Switchboard, test set 2 (Hub5’00-SWB)30916.123.6
English Broadcast News5017.518.8
Bing Voice Search (sentence error)2430.436.2

The failure, as symptom, measurement and fix

The symptom is a claim that “the network beat the GMM” with different language models or data behind each number. To measure it, list what differs between the two rows. The fix is the paper's method: change only the frame scorer.

In Table II, which change gave the largest single drop in word error?

Chapter 9

Why CTC Won, and What Survives

Compare one fixed alignment with a sum over every alignment

The hybrid is heavy: a GMM scaffold, alignment passes, a pronunciation lexicon and hard frame labels. End-to-end models drop most of it. The key step is Connectionist Temporal Classification (CTC), from Graves et al. (2006).

CTC lets the network output, at each frame, a symbol or a special blank. To read the output, merge repeated symbols, then delete blanks. Many frame labelings give the same text. The CTC loss adds the probability of all of them. The network never sees a frame label.

Count them for the text “A B” over 3 frames, with “-” for blank: A A B, A B B, A - B, - A B, A B -. That is 5 labelings. At 4 frames there are 15, and at 10 frames 495. A dynamic program, like the forward algorithm, adds them all without listing them.

One path, or all paths

Rows are positions in “- A - B -”; columns are frames. The hybrid trains on one path. CTC trains on every valid path; brighter cells sit on more paths.

6

Exact path counts by dynamic program. The hybrid path shown is one fixed example.

What survives is large. CTC's blank-and-repeat rule is a small HMM. Decoding CTC with a language model searches the same kind of weighted graph. Forced alignment is still how tools get word timestamps for subtitles. The hybrid still makes sense in some cases:

NeedHybridEnd-to-end
Little training audioLexicon, HMM and language model add structureMust learn all of it from data
Add new wordsEdit the lexicon and language modelOften retrain or add a language model
Exact timestampsRead them off the state pathCTC spikes; attention is fuzzy
Simple pipelineMany stagesOne network, one loss

The failure, as symptom, measurement and fix

The symptom is subtitles that drift by a few hundred milliseconds from an end-to-end model. CTC emits each symbol as a one-frame spike, not as a span. To measure it, compare predicted word starts with a forced alignment. The fix is a separate aligner for timing.

What difference let CTC drop forced alignment?

Chapter 10

The Field Guide

Keep the terms, the numbers, the checklist and the code in one place

A DNN-HMM hybrid is an HMM for time plus a network for frames, joined by a division by the prior. Labels come from forced alignment, and training alternates aligning and learning. Viterbi decodes.

TermWhat to remember
FrameOne window of sound, every 10 ms, about 25 ms long
StateThree per phone; tied into thousands of shared states (9,304 on Switchboard)
Self-loop aP(d) = ad−1(1 − a); average length 1 / (1 − a) frames
GMM emissionp(x | s) = Σ wm N(x; μm, σm), one GMM per state
Scaled likelihoodP(s | x) / P(s); in logs, subtract the log prior (times κ)
ViterbiBest path by max over stay or move, then trace back
Forward algorithmThe same grid with a sum in place of the max
Forced alignmentViterbi on the transcript's chain; gives frame labels
Frame cross-entropy−log of the probability on the aligned state, summed over frames
Switchboard, 309 h27.4% GMM to 18.5% DNN on RT03S-FSH; 23.6% to 16.1% on Hub5’00-SWB
CTCSums over all alignments with a blank; no frame labels

Checklist for a working hybrid

  1. Count the priors from the same alignment that trained the network.
  2. Subtract the log prior from the log posterior; tune its scale on held-out audio.
  3. Work in logs from the first frame.
  4. Floor GMM variances during the bootstrap.
  5. Realign with the network once or twice.
  6. Check alignments by ear on the worst-scoring utterances.

The core, as code

pythonimport numpy as np

def scaled_loglik(post, prior, kappa=1.0):      # post: (T, S) softmax, prior: (S,)
    return np.log(post) - kappa * np.log(prior)       # (T, S) log emissions

def viterbi_chain(E, a):                           # E: (T, S) log emissions, left-to-right chain
    T, S = E.shape; stay, move = np.log(a), np.log(1 - a)
    d = np.full((T, S), -np.inf); bp = np.zeros((T, S), int)
    d[0, 0] = E[0, 0]                                 # start in the first state
    for t in range(1, T):
        for s in range(S):
            best, arg = d[t-1, s] + stay, s
            if s > 0 and d[t-1, s-1] + move > best:
                best, arg = d[t-1, s-1] + move, s - 1
            d[t, s], bp[t, s] = E[t, s] + best, arg
    path = [S - 1]                                       # end in the last state
    for t in range(T - 1, 0, -1): path.append(bp[t, path[-1]])
    return path[::-1], d[T - 1, S - 1]

def priors_from_alignment(labels, S):                # labels: (N,) aligned state per frame
    return np.bincount(labels, minlength=S) / len(labels)

Keep going

The takeaway. Keep the HMM for time. Swap the GMM for a network. Divide its posteriors by the state priors. Train on forced alignments and realign once. Decode with Viterbi.
You count the priors from a different data set than the one used for the training alignment. What should you expect?

Now press Present or Teach and explain from memory: why the self-loop sets a geometric length, why you divide the posterior by the prior, and how alignment and training feed each other. Then go back to the hero and decode “cat” again. Say why the raw posteriors lose the “k”.

Sources

G. Hinton, L. Deng, D. Yu, G. Dahl, A. Mohamed, N. Jaitly, A. Senior, V. Vanhoucke, P. Nguyen, T. Sainath and B. Kingsbury, “Deep Neural Networks for Acoustic Modeling in Speech Recognition”, IEEE Signal Processing Magazine, 2012 (Tables II and III, Section II.E). G. Dahl, D. Yu, L. Deng and A. Acero, “Context-Dependent Pre-Trained Deep Neural Networks for Large-Vocabulary Speech Recognition”, IEEE Transactions on Audio, Speech, and Language Processing, 2012. F. Seide, G. Li and D. Yu, “Conversational Speech Transcription Using Context-Dependent Deep Neural Networks”, Interspeech 2011. H. Bourlard and N. Morgan, Connectionist Speech Recognition: A Hybrid Approach, Kluwer, 1993. A. Graves et al., “Connectionist Temporal Classification”, ICML 2006. Toy numbers on this page are our own.

DNN-HMM Hybrid Acoustic Models
Hinton et al. 2012 · Hidden Markov Models · Back to Gleams