70
1 LSA 352 Summer 2007 LSA 352: Speech Recognition and Synthesis Dan Jurafsky Lecture 5: Intro to ASR+HMMs: Forward, Viterbi, Baum-Welch IP Notice:

Speech Reco & Synthesis Tutorial

Embed Size (px)

Citation preview

Page 1: Speech Reco & Synthesis Tutorial

1 LSA 352 Summer 2007

LSA 352:Speech Recognition and Synthesis

Dan Jurafsky

Lecture 5: Intro to ASR+HMMs:Forward, Viterbi, Baum-Welch

IP Notice:

Page 2: Speech Reco & Synthesis Tutorial

2 LSA 352 Summer 2007

Outline for Today

Speech Recognition Architectural OverviewHidden Markov Models in general

ForwardViterbi DecodingBaum-Wlech

Applying HMMs to speechHow this fits into the ASR component of course

July 6: Language ModelingJuly 19 (today): HMMs, Forward, Viterbi, Start of Baum-Welch (EM) trainingJuly 23: Feature Extraction, MFCCs, and Gaussian Acoustic modelingJuly 26: Evaluation, Decoding, Advanced Topics

Page 3: Speech Reco & Synthesis Tutorial

3 LSA 352 Summer 2007

LVCSR

Large Vocabulary Continuous Speech Recognition~20,000-64,000 wordsSpeaker independent (vs. speaker-dependent)Continuous speech (vs isolated-word)

Page 4: Speech Reco & Synthesis Tutorial

4 LSA 352 Summer 2007

Current error rates

Task Vocabulary Error Rate%Digits 11 0.5WSJ read speech 5K 3WSJ read speech 20K 3Broadcast news 64,000+ 10Conversational Telephone

64,000+ 20

Ballpark numbers; exact numbers depend very much on the specific corpus

Page 5: Speech Reco & Synthesis Tutorial

5 LSA 352 Summer 2007

HSR versus ASR

Conclusions:Machines about 5 times worse than humansGap increases with noisy speechThese numbers are rough, take with grain of salt

Task Vocab

ASR Hum SR

Continuous digits

11 .5 .009

WSJ 1995 clean 5K 3 0.9WSJ 1995 w/noise

5K 9 1.1

SWBD 2004 65K 20 4

Page 6: Speech Reco & Synthesis Tutorial

6 LSA 352 Summer 2007

LVCSR Design Intuition

• Build a statistical model of the speech-to-words process

• Collect lots and lots of speech, and transcribe all the words.

• Train the model on the labeled speech• Paradigm: Supervised Machine Learning +

Search

Page 7: Speech Reco & Synthesis Tutorial

7 LSA 352 Summer 2007

Speech Recognition Architecture

Page 8: Speech Reco & Synthesis Tutorial

8 LSA 352 Summer 2007

The Noisy Channel Model

Search through space of all possible sentences.Pick the one that is most probable given the waveform.

Page 9: Speech Reco & Synthesis Tutorial

9 LSA 352 Summer 2007

The Noisy Channel Model (II)

What is the most likely sentence out of all sentences in the language L given some acoustic input O?Treat acoustic input O as sequence of individual observations

O = o1,o2,o3,…,ot

Define a sentence as a sequence of words:W = w1,w2,w3,…,wn

Page 10: Speech Reco & Synthesis Tutorial

10 LSA 352 Summer 2007

Noisy Channel Model (III)

Probabilistic implication: Pick the highest prob S:

We can use Bayes rule to rewrite this:

Since denominator is the same for each candidate sentence W, we can ignore it for the argmax:

ˆ W = argmaxW ∈L

P(W | O)

ˆ W = argmaxW ∈L

P(O |W )P(W )€

ˆ W = argmaxW ∈L

P(O |W )P(W )P(O)

Page 11: Speech Reco & Synthesis Tutorial

11 LSA 352 Summer 2007

Noisy channel model

ˆ W = argmaxW ∈L

P(O |W )P(W )

likelihood prior

Page 12: Speech Reco & Synthesis Tutorial

12 LSA 352 Summer 2007

The noisy channel model

Ignoring the denominator leaves us with two factors: P(Source) and P(Signal|Source)

Page 13: Speech Reco & Synthesis Tutorial

13 LSA 352 Summer 2007

Speech Architecture meets Noisy Channel

Page 14: Speech Reco & Synthesis Tutorial

14 LSA 352 Summer 2007

Architecture: Five easy pieces (only 2 for today)

Feature extractionAcoustic ModelingHMMs, Lexicons, and PronunciationDecodingLanguage Modeling

Page 15: Speech Reco & Synthesis Tutorial

15 LSA 352 Summer 2007

HMMs for speech

Page 16: Speech Reco & Synthesis Tutorial

16 LSA 352 Summer 2007

Phones are not homogeneous!

Time (s)0.48152 0.937203

0

5000

ay k

Page 17: Speech Reco & Synthesis Tutorial

17 LSA 352 Summer 2007

Each phone has 3 subphones

Page 18: Speech Reco & Synthesis Tutorial

18 LSA 352 Summer 2007

Resulting HMM word model for “six”

Page 19: Speech Reco & Synthesis Tutorial

19 LSA 352 Summer 2007

HMMs more formally

Markov chainsA kind of weighted finite-state automaton

Page 20: Speech Reco & Synthesis Tutorial

20 LSA 352 Summer 2007

HMMs more formally

Markov chainsA kind of weighted finite-state automaton

Page 21: Speech Reco & Synthesis Tutorial

21 LSA 352 Summer 2007

Another Markov chain

Page 22: Speech Reco & Synthesis Tutorial

22 LSA 352 Summer 2007

Another view of Markov chains

Page 23: Speech Reco & Synthesis Tutorial

23 LSA 352 Summer 2007

An example with numbers:

What is probability of:Hot hot hot hotCold hot cold hot

Page 24: Speech Reco & Synthesis Tutorial

24 LSA 352 Summer 2007

Hidden Markov Models

Page 25: Speech Reco & Synthesis Tutorial

25 LSA 352 Summer 2007

Hidden Markov Models

Page 26: Speech Reco & Synthesis Tutorial

26 LSA 352 Summer 2007

Hidden Markov Models

Bakis network Ergodic (fully-connected) network

Left-to-right network

Page 27: Speech Reco & Synthesis Tutorial

27 LSA 352 Summer 2007

The Jason Eisner task

You are a climatologist in 2799 studying the history of global warmingYOU can’t find records of the weather in Baltimore for summer 2006But you do find Jason Eisner’s diaryWhich records how many ice creams he ate each day.Can we use this to figure out the weather?

Given a sequence of observations O, – each observation an integer = number of ice creams eaten– Figure out correct hidden sequence Q of weather states (H

or C) which caused Jason to eat the ice cream

Page 28: Speech Reco & Synthesis Tutorial

28 LSA 352 Summer 2007

Page 29: Speech Reco & Synthesis Tutorial

29 LSA 352 Summer 2007

HMMs more formally

Three fundamental problemsJack Ferguson at IDA in the 1960s Given a specific HMM, determine likelihood of observation sequence. Given an observation sequence and an HMM, discover the best (most probable) hidden state sequence Given only an observation sequence, learn the HMM parameters (A, B matrix)

Page 30: Speech Reco & Synthesis Tutorial

30 LSA 352 Summer 2007

The Three Basic Problems for HMMs

Problem 1 (Evaluation): Given the observation sequence O=(o1o2…oT), and an HMM model = (A,B), how do we efficiently compute P(O| ), the probability of the observation sequence, given the modelProblem 2 (Decoding): Given the observation sequence O=(o1o2…oT), and an HMM model = (A,B), how do we choose a corresponding state sequence Q=(q1q2…qT) that is optimal in some sense (i.e., best explains the observations)Problem 3 (Learning): How do we adjust the model parameters = (A,B) to maximize P(O| )?

Page 31: Speech Reco & Synthesis Tutorial

31 LSA 352 Summer 2007

Problem 1: computing the observation likelihood

Given the following HMM:

How likely is the sequence 3 1 3?

Page 32: Speech Reco & Synthesis Tutorial

32 LSA 352 Summer 2007

How to compute likelihood

For a Markov chain, we just follow the states 3 1 3 and multiply the probabilitiesBut for an HMM, we don’t know what the states are!So let’s start with a simpler situation.Computing the observation likelihood for a given hidden state sequence

Suppose we knew the weather and wanted to predict how much ice cream Jason would eat.I.e. P( 3 1 3 | H H C)

Page 33: Speech Reco & Synthesis Tutorial

33 LSA 352 Summer 2007

Computing likelihood for 1 given hidden state sequence

Page 34: Speech Reco & Synthesis Tutorial

34 LSA 352 Summer 2007

Computing total likelihood of 3 1 3

We would need to sum overHot hot coldHot hot hotHot cold hot….

How many possible hidden state sequences are there for this sequence?How about in general for an HMM with N hidden states and a sequence of T observations?

NT

So we can’t just do separate computation for each hidden state sequence.

Page 35: Speech Reco & Synthesis Tutorial

35 LSA 352 Summer 2007

Instead: the Forward algorithm

A kind of dynamic programming algorithm

Uses a table to store intermediate valuesIdea:

Compute the likelihood of the observation sequenceBy summing over all possible hidden state sequencesBut doing this efficiently

– By folding all the sequences into a single trellis

Page 36: Speech Reco & Synthesis Tutorial

36 LSA 352 Summer 2007

The Forward Trellis

Page 37: Speech Reco & Synthesis Tutorial

37 LSA 352 Summer 2007

The forward algorithm

Each cell of the forward algorithm trellis alphat(j)

Represents the probability of being in state jAfter seeing the first t observationsGiven the automaton

Each cell thus expresses the following probabilty

Page 38: Speech Reco & Synthesis Tutorial

38 LSA 352 Summer 2007

We update each cell

Page 39: Speech Reco & Synthesis Tutorial

39 LSA 352 Summer 2007

The Forward Recursion

Page 40: Speech Reco & Synthesis Tutorial

40 LSA 352 Summer 2007

The Forward Algorithm

Page 41: Speech Reco & Synthesis Tutorial

41 LSA 352 Summer 2007

Decoding

Given an observation sequence3 1 3

And an HMMThe task of the decoder

To find the best hidden state sequenceGiven the observation sequence O=(o1o2…oT), and an HMM model = (A,B), how do we choose a corresponding state sequence Q=(q1q2…qT) that is optimal in some sense (i.e., best explains the observations)

Page 42: Speech Reco & Synthesis Tutorial

42 LSA 352 Summer 2007

Decoding

One possibility:For each hidden state sequence

– HHH, HHC, HCH, Run the forward algorithm to compute P( |O)

Why not?NT

Instead:The Viterbi algorithmIs again a dynamic programming algorithmUses a similar trellis to the Forward algorithm

Page 43: Speech Reco & Synthesis Tutorial

43 LSA 352 Summer 2007

The Viterbi trellis

Page 44: Speech Reco & Synthesis Tutorial

44 LSA 352 Summer 2007

Viterbi intuition

Process observation sequence left to rightFilling out the trellisEach cell:

Page 45: Speech Reco & Synthesis Tutorial

45 LSA 352 Summer 2007

Viterbi Algorithm

Page 46: Speech Reco & Synthesis Tutorial

46 LSA 352 Summer 2007

Viterbi backtrace

Page 47: Speech Reco & Synthesis Tutorial

47 LSA 352 Summer 2007

Viterbi Recursion

Page 48: Speech Reco & Synthesis Tutorial

48 LSA 352 Summer 2007

Why “Dynamic Programming”

“I spent the Fall quarter (of 1950) at RAND. My first task was to find a name for multistage decision processes. An interesting question is, Where did the name, dynamic programming, come from? The 1950s were not good years for mathematical research. We had a very interesting gentleman in Washington named Wilson. He was Secretary of Defense, and he actually had a pathological fear and hatred of the word, research. I’m not using the term lightly; I’m using it precisely. His face would suffuse, he would turn red, and he would get violent if people used the term, research, in his presence. You can imagine how he felt, then, about the term, mathematical. The RAND Corporation was employed by the Air Force, and the Air Force had Wilson as its boss, essentially. Hence, I felt I had to do something to shield Wilson and the Air Force from the fact that I was really doing mathematics inside the RAND Corporation. What title, what name, could I choose? In the first place I was interested in planning, in decision making, in thinking. But planning, is not a good word for various reasons. I decided therefore to use the word, “programming” I wanted to get across the idea that this was dynamic, this was multistage, this was time-varying I thought, lets kill two birds with one stone. Lets take a word that has an absolutely precise meaning, namely dynamic, in the classical physical sense. It also has a very interesting property as an adjective, and that is its impossible to use the word, dynamic, in a pejorative sense. Try thinking of some combination that will possibly give it a pejorative meaning. Its impossible. Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it as an umbrella for my activities.” Richard Bellman, “Eye of the Hurrican: an autobiography” 1984.

Thanks to Chen, Picheny, Eide, Nock

Page 49: Speech Reco & Synthesis Tutorial

49 LSA 352 Summer 2007

HMMs for Speech

We haven’t yet shown how to learn the A and B matrices for HMMs; we’ll do that later today or possibly on MondayBut let’s return to think about speech

Page 50: Speech Reco & Synthesis Tutorial

50 LSA 352 Summer 2007

Reminder: a word looks like this:

Page 51: Speech Reco & Synthesis Tutorial

51 LSA 352 Summer 2007

HMM for digit recognition task

Page 52: Speech Reco & Synthesis Tutorial

52 LSA 352 Summer 2007

The Evaluation (forward) problem for speech

The observation sequence O is a series of MFCC vectorsThe hidden states W are the phones and wordsFor a given phone/word string W, our job is to evaluate P(O|W)Intuition: how likely is the input to have been generated by just that word string W

Page 53: Speech Reco & Synthesis Tutorial

53 LSA 352 Summer 2007

Evaluation for speech: Summing over all different paths!

f ay ay ay ay v v v v f f ay ay ay ay v v v f f f f ay ay ay ay vf f ay ay ay ay ay ay vf f ay ay ay ay ay ay ay ay vf f ay v v v v v v v

Page 54: Speech Reco & Synthesis Tutorial

54 LSA 352 Summer 2007

The forward lattice for “five”

Page 55: Speech Reco & Synthesis Tutorial

55 LSA 352 Summer 2007

The forward trellis for “five”

Page 56: Speech Reco & Synthesis Tutorial

56 LSA 352 Summer 2007

Viterbi trellis for “five”

Page 57: Speech Reco & Synthesis Tutorial

57 LSA 352 Summer 2007

Viterbi trellis for “five”

Page 58: Speech Reco & Synthesis Tutorial

58 LSA 352 Summer 2007

Search space with bigrams

Page 59: Speech Reco & Synthesis Tutorial

59 LSA 352 Summer 2007

Viterbi trellis with 2 words and uniform LM

Page 60: Speech Reco & Synthesis Tutorial

60 LSA 352 Summer 2007

Viterbi backtrace

Page 61: Speech Reco & Synthesis Tutorial

61 LSA 352 Summer 2007

Page 62: Speech Reco & Synthesis Tutorial

62 LSA 352 Summer 2007

Evaluation

How to evaluate the word string output by a speech recognizer?

Page 63: Speech Reco & Synthesis Tutorial

63 LSA 352 Summer 2007

Word Error Rate

Word Error Rate = 100 (Insertions+Substitutions + Deletions) ------------------------------ Total Word in Correct TranscriptAligment example:REF: portable **** PHONE UPSTAIRS last night soHYP: portable FORM OF STORES last night soEval I S S WER = 100 (1+2+0)/6 = 50%

Page 64: Speech Reco & Synthesis Tutorial

64 LSA 352 Summer 2007

NIST sctk-1.3 scoring softare:Computing WER with sclite

http://www.nist.gov/speech/tools/Sclite aligns a hypothesized text (HYP) (from the recognizer) with a correct or reference text (REF) (human transcribed)

id: (2347-b-013)Scores: (#C #S #D #I) 9 3 1 2REF: was an engineer SO I i was always with **** **** MEN UM and theyHYP: was an engineer ** AND i was always with THEM THEY ALL THAT and theyEval: D S I I S S

Page 65: Speech Reco & Synthesis Tutorial

65 LSA 352 Summer 2007

Sclite output for error analysisCONFUSION PAIRS Total (972) With >= 1 occurances (972)

1: 6 -> (%hesitation) ==> on 2: 6 -> the ==> that 3: 5 -> but ==> that 4: 4 -> a ==> the 5: 4 -> four ==> for 6: 4 -> in ==> and 7: 4 -> there ==> that 8: 3 -> (%hesitation) ==> and 9: 3 -> (%hesitation) ==> the 10: 3 -> (a-) ==> i 11: 3 -> and ==> i 12: 3 -> and ==> in 13: 3 -> are ==> there 14: 3 -> as ==> is 15: 3 -> have ==> that 16: 3 -> is ==> this

Page 66: Speech Reco & Synthesis Tutorial

66 LSA 352 Summer 2007

Sclite output for error analysis17: 3 -> it ==> that

18: 3 -> mouse ==> most 19: 3 -> was ==> is 20: 3 -> was ==> this 21: 3 -> you ==> we 22: 2 -> (%hesitation) ==> it 23: 2 -> (%hesitation) ==> that 24: 2 -> (%hesitation) ==> to 25: 2 -> (%hesitation) ==> yeah 26: 2 -> a ==> all 27: 2 -> a ==> know 28: 2 -> a ==> you 29: 2 -> along ==> well 30: 2 -> and ==> it 31: 2 -> and ==> we 32: 2 -> and ==> you 33: 2 -> are ==> i 34: 2 -> are ==> were

Page 67: Speech Reco & Synthesis Tutorial

67 LSA 352 Summer 2007

Better metrics than WER?

WER has been usefulBut should we be more concerned with meaning (“semantic error rate”)?

Good idea, but hard to agree onHas been applied in dialogue systems, where desired semantic output is more clear

Page 68: Speech Reco & Synthesis Tutorial

68 LSA 352 Summer 2007

Summary: ASR ArchitectureFive easy pieces: ASR Noisy Channel architecture1) Feature Extraction:

39 “MFCC” features2) Acoustic Model:

Gaussians for computing p(o|q)3) Lexicon/Pronunciation Model

• HMM: what phones can follow each other4) Language Model

• N-grams for computing p(wi|wi-1)5) Decoder

• Viterbi algorithm: dynamic programming for combining all these to get word sequence from speech!

Page 69: Speech Reco & Synthesis Tutorial

69 LSA 352 Summer 2007

ASR Lexicon: Markov Models for pronunciation

Page 70: Speech Reco & Synthesis Tutorial

70 LSA 352 Summer 2007

Summary

Speech Recognition Architectural OverviewHidden Markov Models in general

ForwardViterbi Decoding

Hidden Markov models for SpeechEvaluation