No Slide Title

Download Report

Transcript No Slide Title

CS 552/652
Speech Recognition with Hidden Markov Models
Winter 2011
Oregon Health & Science University
Center for Spoken Language Understanding
John-Paul Hosom
Lecture 7
January 31
Features of the Speech Signal
1
Features: How to Represent the Speech Signal
Features must (a) provide good representation of phonemes
(b) be robust to non-phonetic changes in signal
Time domain (waveform):
Frequency domain (spectrogram):
“Markov”: male speaker
“Markov”: female speaker
2
Features: Windowing
In many cases, the math assumes that the signal is periodic.
We always assume that the data is zero outside the window.
When we apply a rectangular window, there are usually
discontinuities in the signal at the ends. So we can window the
signal with other shapes, making the signal closer to zero at the
ends. This attenuates discontinuities.
Hamming window:
2 n
h(n)  0.54  0.46 cos(
)
N 1
1.0
0  n  N 1
0.0 0
N-1
Typical window size is 16 msec, which equals 256 samples for
16-kHz (microphone) signal and 128 samples for 8-kHz (telephone)
3
signal. Window size does not have to equal frame size!
Features: Spectrum and Cepstrum
(log power) spectrum:
energy (dB)
amplitude
1. Hamming window
2. Fast Fourier Transform (FFT)
3. Compute 10 log10(r2+i2)
where r is the real component, i is the imaginary component
time
frequency
4
Features: Spectrum and Cepstrum
cepstrum:
treat spectrum as signal subject to frequency analysis…
1. Compute log power spectrum
2. Compute FFT of log power spectrum
3. Use only the lower 13 values (cepstral coefficients)
5
Features: Spectrum and Cepstrum
Why Use Cepstral Features?
• number of features is small (13 vs. 64 or 128 for spectrum)
• models spectral envelope (relevant to phoneme identity),
not (irrelevant) pitch
• coefficients tend to not be correlated with each other
(useful to assume that non-diagonal elements of covariance
matrix are zero… see Lecture 5, slide 29)
• (relatively) easy to compute
Cepstral features are very commonly used. Another type of feature
that is commonly used is called Linear Predictive Coding (LPC).
6
Features: Autocorrelation
Autocorrelation:
measure of periodicity in signal
Rn (k ) 

 x(m) x(m  k )
m  
Rn (k ) 
N 1 k
x (m)w(m)x (m  k )w(m  k )
n
n
m 0
amplitude
n=start sample of analysis, m=sample within analysis window 0…N-1
time
7
Features: Autocorrelation
Autocorrelation: measure of periodicity in signal
Rn (k ) 
N 1 k
x (m)w(m)x (m  k )w(m  k )
n
n
m 0
from previous slide
and if we set yn(m) = xn(m) w(m), so that y is the windowed
signal of x where the window is zero for m<0 and m>N-1, then:
Rn (k ) 
N 1 k
 y (m)  y (m  k )
m 0
n
n
0k  K
where K is the maximum autocorrelation index desired.
Note that Rn(k) = Rn(-k), because when we sum over all
values of m that have a non-zero y value (or just change the limits
in the summation to m=k to N-1 and use negative k), then
yn (m)  yn (m  k )  yn (m  k )  yn (m)  yn (m)  yn (m  k )
the shift is the same in both cases ; limits of summation change m=k…N-1
8
Features: Autocorrelation
Autocorrelation of speech signals: (from Rabiner & Schafer, p. 143)
9
Features: Autocorrelation
Eliminate “fall-off” by including samples in w2 not in w1.
w1 (m)  1
0  m  N 1
w1 (m)  0
otherwise
w2 (m)  1
0  m  N 1  k
w2 (m)  0
otherwise
N 1
Rˆ n (k )   xn (m) w1 (m) xn (m  k ) w2 (m  k )  0  k  K
Rˆ n (k ) 
m 0
N 1
 x (m) x (m  k )
n
n
0k  K
m 0
= modified autocorrelation function
= cross-correlation function
Note: requires k ·N multiplications; can be slow
10
Features: LPC
Linear Predictive Coding (LPC) provides
• low-dimension representation of speech signal at one frame
• representation of spectral envelope, not harmonics
• “analytically tractable” method
• some ability to identify formants
LPC models the speech signal at time point n as an approximate
linear combination of previous p samples:
s(n)  a1s(n 1)  a2 s(n  2)   a p s(n  p)
where a1, a2, … ap are constant for each frame of speech.
We can make the approximation exact by including a
“difference” or “residual” term:
(1)
p
s(n)   ak s(n  k )  Gu(n)
(2)
k 1
where G is a scalar gain factor, and u(n) is the (normalized)
error signal (residual).
11
Features: LPC
LPC can be used to generate speech from either the error signal
(residual) or a sequence of impulses as input:
sˆ(m)  e(m)  a1s(m 1)  a2 s(m  2)   a p s(m  p)
where ŝ is the generated speech, and e(m) is the error signal or a
sequence of impulses. However, we use LPC here as a
representation of the signal.
The values a1…ap (where p is typically 10 to 15) describe the
signal over the range of one window of data (typically 128 to 256
samples).
While it’s true that 10-15 values are needed to predict (model)
only one data point (estimating the value at time m from the
previous p points), the same 10-15 values are used to represent
all data points in the analysis window. When one frame of
speech has more than p values, there is data reduction. For
speech, the amount of data reduction is about 10:1. In addition,
LPC values model the spectral envelope, not pitch information.12
Features: LPC
If the error over a segment of speech is defined as
En

M2
 e (m)
m  M1
(3)
2
n


   sn (m)   ak sn (m  k ) 
m  M1 
k 1

M2
p
2
(4)
then we can find ak by setting En/ak = 0 for k = 1,2,…p,
obtaining p equations and p unknowns:
M2
p
M2
 aˆ  s (m  i)s (m  k )   s (m  i)s (m)
k 1
k
m  M1
n
n
m  M1
n
n
1 i  p
(5)
(as shown on next slide…)
Error is minimum (not maximum) when derivative is zero, because
as any ak changes away from optimum value, error will increase.
13
Features: LPC
p


  
s
(
m
)

ak s ( m  k ) 



m M1 
k 1

M2
En
En 
M2

m M1
En 
En
M2

m M1
a1
2
(5-1)
p
 2
 p
 p


a
s
(
m

k
)
 s ( m)  2 s ( m)  a k s ( m  k )  
 k

  ak s ( m  r ) 

k 1
 k 1
 r 1


p
 2

 s ( m)  2 s ( m) a1s ( m  1)  a1s ( m  1) ar s ( m  r )  
r 1


p

 2 s ( m) a2 s ( m  2)  a2 s ( m  2) ar s ( m  r )  


r 1
p


 2 s ( m) a p s ( m  p )  a p s ( m  p ) ar s ( m  r ) 

r 1


M2

m  M1
0
(5-2)
M2
s
m M1
2
(5-3)
(m)  2 s (m)a1s (m  1)  2a1s (m  1)a1s (m  1)  ...  a1s (m  1)a p s (m  p ) 
(5-4)
 2 s (m)a2 s (m  2)  a2 s (m  2)a1s (m  1)  ...  a2 s (m  2)a p s (m  p ) 
 2s(m) s(m  1)  2a1s(m  1) s (m  1)  s (m  1)a2 s(m  2)  ...  s(m  1)a p s(m  p) 
(5-5)
a2 s(m  2) s(m  1)  a3 s(m  3) s(m  1)  ...  a p s(m  p) s (m  1)  0
M2
  2s(m)s(m  1)  2a s(m  1)s(m  1)  2a
1
m  M1
2
s(m  1) s(m  2)  ...  2a p s(m  1) s(m  p)  0
(5-6)
repeat (5-4) to (5-6) for a2, a3, … ap
2


 s(m)s(m  i)  2   ak s(m  i)s(m  k )  0
M2
M2
m M1
m M1
p
 k 1

p



 2s(m) s(m  i )  2 ak s(m  i ) s (m  k )  0
m  M1 
k 1

M2
p
 ak
k 1
M2
 s (m  i ) s (m  k ) 
m  M1
M2
 s(m  i)s(m)
m  M1
1 i  p
(5-7)
1 i  p
(5-8)
1 i  p
14 (5-9)
Features: LPC Autocorrelation Method
Then, defining n (i, k ) 
M2
 sn (m  i)sn (m  k )
(6)
m  M1
we can re-write equation (5) as:
p
 aˆ  (i, k )   (i,0)
k 1
k n
n
1 i  p
(7)
We can solve for ak using several methods. The most common
method in speech processing is the “autocorrelation” method:
Force the signal to be zero outside of interval 0  m  N-1:
(8)
sˆn (m)  sn (m)w(m)
where w(m) is a finite-length window (e.g. Hamming) of length N
that is zero when less than 0 and greater than N-1. ŝ is the
windowed signal. As a result,
En

N  p 1
2
e
 n (m)
m 0
(9)
15
Features: LPC Autocorrelation Method
How did we get from En 
to En 
M2
2
e
 n (m)
(equation (3))
m M1
N  p 1
2
e
 n (m)
(equation (9))
m 0
N 1
with window from 0 to N-1? Why not En   en2 (m) ??
m 0
Because value for en(m) may not be zero when m > N-1…
for example, when m = N+p-1, then
p
en ( N  p  1)  sˆn ( N  p  1)   ak sˆn ( N  p  1  k )

k 1

en ( N  p 1)  sˆn ( N  p 1)  a1sˆn ( N  p 11)  ... a p sˆn ( N  p 1 p)
0
0
ŝn(N-1) is not zero!
16
Features: LPC Autocorrelation Method
because of setting the signal to zero outside the window, eqn (6):
N  p 1
1 i  p
(10)
n (i, k )   sˆn (m  i)sˆn (m  k )
0k  p
m 0
and this can be expressed as
N 1( i  k )
1 i  p
n (i, k )   sˆn (m)sˆn (m  (i  k ))
(11)
0k  p
m 0
and this is identical to the autocorrelation function for |ik| because
the autocorrelation function is symmetric, Rn(x) = Rn(x) :
n (i, k )  Rn (| i  k | )
Rn ( x) 
where
(12)
N 1 x
 sˆ (m)sˆ (m  x)
n
n
m 0
(13)
so the set of equations for ak (eqn (7)) can be combo of (7) and (12):
p
 aˆ R (| i  k |)  R (i)
k 1
k
n
n
1 i  p
(14)
17
Features: LPC Autocorrelation Method
Why can equation (10):
n (i, k ) 
N  p 1

m 0
sˆn (m  i)sˆn (m  k )
be expressed as (11): ???
n (i, k ) 
n (i, k ) 
n (i, k ) 
n (i, k ) 
N 1( i  k )

m 0
N  p 1
 sˆ (m  i)sˆ (m  k )
m 0
N  p 1i

m 0
N  k 1i

m 0
n
n
sˆn (m) sˆn (m  i  k )
1 i  p
0k  p
1 i  p
0k  p
1 i  p
0k  p
original equation
sˆn (m)sˆn (m  k  i)
add i to sn() offset and subtract i
from summation limits. If m < 0,
0k  p
sn(m) is zero so still start sum at 0.
sˆn (m)sˆn (m  k  i)
1  i  p replace p in sum limit by k, because
0  k  p when m > N+k-1-i, s(m+i-k)=0
1 i  p
and k is always  p
18
Features: LPC Autocorrelation Method
In matrix form, equation (14) looks like this:
 Rn (0)
 Rn (1)
 R ( 2)
 n
 
 
 Rn ( p  1)
Rn (1)
Rn (2)
Rn (0)
Rn (1)
Rn (1)
Rn (0)




Rn ( p  2) Rn ( p  3)






Rn ( p  1)   aˆ1   Rn (1) 
Rn ( p  2)  aˆ 2   Rn (2) 
Rn ( p  3)   aˆ3   Rn (3) 


      


      
Rn (0)  aˆ p   Rn ( p )
There is a recursive algorithm to solve this: Durbin’s solution
19
Features: LPC Durbin’s Solution
Solve a Toeplitz (symmetric, diagonal elements equal) matrix
for values of  :
p

k 1
k
Rn (| i  k |)  Rn (i )
1 i  p
E ( 0 )  R ( 0)
i 1


( i 1)
ki   R (i )    j R (i  j ) E ( i 1)
j 1


 i(i )  ki
 (ji )   (ji 1)  ki i(i j1)
1 i  p
1  j  i 1
E (i )  (1  ki2 ) E ( i 1)
aˆ j   (j p )
20
Features: LPC Example
For 2nd-order LPC, with waveform samples
{462
16
-294
-374
-178
98
40
-82}
If we apply a Hamming window (because we assume signal is zero
outside of window; if rectangular window, large prediction error
at edges of window), which is
{0.080 0.253
0.642
0.954
0.954
0.642
0.253
0.080}
-188.85 -356.96 -169.89 62.95
10.13
-6.56}
then we get
{36.96 4.05
and so
R(0) = 197442
R(1)=117319
E ( 0)  R(0)
k1  R(1)  0 E ( 0) 
1(1)  k1
R(2)=-946
 197442
R(1)
R(0)
 0.59420
 0.59420
21
Features: LPC Example
E (1)  (1  k12 ) E ( 0)

R 2 (0)  R 2 (1)

R(0)

k 2  R(2)  1(1) R(1) E (1)
R(2) R(0)  R 2 (1)

R 2 (0)  R 2 (1)
 2( 2)  k 2

( 2)
1

(1)
1
 127731
 0.55317
 0.55317
 k 2
aˆ1  0.92289
(1)
1
R(1) R(0)  R(1) R(2)

R 2 (0)  R 2 (1)
 0.92289
aˆ 2  0.55317
Note: if divide all R(·) values by R(0), solution is unchanged,
but error E(i) is now “normalized error”.
Also: -1  kr 1 for r = 1,2,…,p
22
Features: LPC Example
We can go back and check our results by using these
coefficients to “predict” the windowed waveform:
{36.96 4.05
-188.85 -356.96 -169.89 62.95
10.13
-6.56}
and compute the error from time 0 to N+p-1 (Eqn (9))
0
×0.92542 + 0 × -0.5554 = 0
36.96 ×0.92542 + 0 × -0.5554 = 34.1
4.05 ×0.92542 + 36.96 × -0.5554 = -16.7
-188.9×0.92542 + 4.05 × -0.5554 = -176.5
-357.0×0.92542 + -188.9×-0.5554 = -225.0
-169.9×0.92542 + -357.0×-0.5554 = 40.7
62.95×0.92542 + -169.89×-0.5554 = 152.1
10.13×0.92542 + 62.95×-0.5554 = -25.5
-6.56×0.92542 + 10.13×-0.5554 = -11.6vs. 0,
0×0.92542 + -6.56×-0.5554 = 3.63
vs. 36.96,
diff = 36.96
vs. 4.05,
diff = -30.05
vs. –188.85,
diff = -172.15
vs. –356.96,
diff = -180.43
vs. –169.89,
diff = 55.07
vs. 62.95,
diff = 22.28
vs. 10.13,
diff = -141.95
vs. –6.56,
diff = 18.92
diff = 11.65
8
vs. 0,
diff = -3.63
time
0
1
2
3
4
5
6
7
A total squared error of 88,645, or error normalized by R(0) of
0.449
(If p=0, then predict nothing, and total error equals R(0), so we can
normalize all error values by dividing by R(0).)
23
9
Normalized Prediction Error
(total squared error / R(0))
Features: LPC Example
If we look at a longer speech sample of the vowel /iy/, do
pre-emphasis of 0.97 (see following slides), and perform LPC
of various orders, we get:
0.20
0.16
0.12
0.08
0.04
0.00
0
1
2
3
4
5
6
7
8
9
10
LPC Order
which implies that order 4 captures most of the important
information in the signal (probably corresponding to 2 formants)
24
Features: LPC and Linear Regression
• LPC models the speech at time n as a linear combination of the
previous p samples. The term “linear” does not imply that the
result involves a straight line, e.g. s = ax + b.
• Speech is then modeled as a linear but time-varying system
(piecewise linear).
• LPC is a form of linear regression, called multiple linear
regression, in which there is more than one parameter. In other
words, instead of an equation with one parameter of the form s
= a1x + a2x2, an equation of the form s = a1x + a2y + …
• Because the function is linear in its parameters, the solution
reduces to a system of linear equations, and other techniques
for linear regression (e.g. gradient descent) are not necessary.
25
Features: LPC Spectrum
We can compute spectral envelope magnitude from LPC parameters
by evaluating the transfer function S(z) for z=ej:
G
G
S (e j ) 

p
A(e j )
1   ak e  jk
k 1
because e j  cos( )  j sin( ) the log power spectrum  is:
p
p
2n
2n
Re{A}  1    ak cos(k 
) Im{A}    ak sin(k 
) 0n N
N
N
k 1
k 1
2




G
G2



(n)  10 log
 10 log
1 
2
2 
 Re{A}2  Im{A}2 2 
 Re{A}  Im{A} 


Each resonance (complex pole) in spectrum requires two
LPC coefficients; each spectral slope factor (frequency=0 or
Nyquist frequency) requires one LPC coefficient.



For 8 kHz speech, 4 formants  LPC order of 9 or 10

26
Features: LPC Representations
27
Features: LPC Cepstral Features
The LPC values are more correlated than cepstral coefficients.
But, for GMM with diagonal covariance matrix, we want values
to be uncorrelated.
So, we can convert the LPC coefficients into cepstral values:
1 n1
cn  an   (n  j )a j cn j
n j 1
28
Features: LPC History
Wikipedia has an interesting article on the history of LPC:
… The first ideas leading to LPC started in 1966 when S. Saito and F. Itakura
of NTT described an approach to automatic phoneme discrimination that
involved the first maximum likelihood approach to speech coding. In 1967,
John Burg outlined the maximum entropy approach. In 1969 Itakura and Saito
introduced partial correlation, May Glen Culler proposed real-time speech
encoding, and B. S. Atal presented an LPC speech coder at the Annual Meeting
of the Acoustical Society of America.
In 1972 Bob Kahn of ARPA, with Jim Forgie (Lincoln Laboratory) and Dave
Walden (BBN Technologies), started the first developments in packetized
speech, which would eventually lead to Voice over IP. In 1976 the first LPC
conference took place over the ARPANET using the Network Voice Protocol.
It is [currently] used as a form of voice compression by phone companies, for
example in the GSM standard. It is also used for secure wireless, where voice
must be digitized, encrypted and sent over a narrow voice channel.
[from http://en.wikipedia.org/wiki/Linear_predictive_coding]
29
Features: Pre-emphasis
energy (dB)
The source signal for voiced sounds has slope of -6 dB/octave:
0
1k
frequency
2k
3k
4k
We want to model only the resonant energies, not the source.
But LPC will model both source and resonances.
If we pre-emphasize the signal for voiced sounds, we flatten it
in the spectral domain, and source of speech more closely
approximates impulses. LPC can then model only resonances
(important information) rather than resonances + source.
Pre-emphasis: s'n (m)  sn (m)  k  sn (m 1)
k  0.97
30
Features: Pre-emphasis
Adaptive pre-emphasis:
a better way to flatten the speech signal
1. LPC of order 1
= value of spectral slope in dB/octave
= R(1)/R(0)
= first value of normalized autocorrelation
2. Result = pre-emphasis factor
s ' n ( m )  s n ( m) 
R(1)
 sn (m  1)
R(0)
31
Features: Frequency Scales
The human ear has different responses at different frequencies.
Two scales are common:
Mel scale:
Bark( f ) 
26.81 f
 0.53
1960 f
energy (dB)
f
Mel( f )  2595 log10 (1 
)
700
Bark scale (from Traunmüller 1990):
frequency
frequency
32
Features: Perceptual Linear Prediction (PLP)
Perceptual Linear Prediction (PLP) is composed of the
following steps:
1. Hamming window
2 n
h(n)  0.54  0.46 cos(
)
N 1
2. power spectrum (not dB scale) (frequency analysis)
S=(Xr2+Xi2)
3. Bark scale filter banks (trapezoidal filters) (freq. resolution)
26.81 f
Bark( f ) 
 0.53
1960 f
4. equal-loudness weighting (frequency sensitivity)
2

 f 2  1.44e6
f2
  2
E ( f )   2
f

1
.
6
e
5

 f  9.61e6
33
Features: PLP
PLP is composed of the following steps:
5. cubic compression (relationship between intensity and loudness)
( f )  ( f )0.33
6. LPC analysis (compute autocorrelation from freq. domain)
p
s(n)   ak s(n  k )  Gu(n) ( p  12)
k 1
7. compute cepstral coefficients
1 n1
cn  an   (n  i)ai cni
n i 1
8. weight cepstral coefficients
c'n  exp(n  k )cn
k  0.6
34
Features: Mel-Frequency Cepstral Coefficients (MFCC)
Mel-Frequency Cepstral Coefficients (MFCC) is composed of
the following steps:
1. pre-emphasis
s'n (m)  sn (m)  0.97 sn (m 1)
2. Hamming window
h(n)  0.54  0.46 cos(
2 n
)
N 1
3. power spectrum (not dB scale)
S=(Xr2+Xi2)
4. Mel scale filter banks (triangular filters)
Mel( f )  2595 log10 (1 
f
)
700
35
Features: MFCC
MFCC is composed of the following steps:
5. compute log spectrum from filter banks
10 log10(S)
6. convert log energies from filter banks to cepstral coefficients
N
m j  log energy values
i
ci   m j cos( ( j  0.5))
N  number of filterbanks
N
j 1
7. weight cepstral coefficients
c'n  exp(n  k )cn
k  0.6
36
Features: Delta Values
The PLP and MFCC features, as presented, analyze the speech
signal at one time frame. However, speech changes over time.
To capture dynamics of speech, use “delta” features.
Using this formula for delta of nth cepstral coefficient c, at time t:
dn,t  cn,t  cn,t 1
too noisy!
Use this regression formula (Furui, 1986, IEEE Trans ASSP, 34, pp 52-59):

d n ,t 
  c


1
n ,t 

 cn ,t  
2  2
 = window size = 2 frames
(50 msec window)
 1
The “acceleration” or “delta-delta” coefficients may also be used,
and computed by applying the same formula to the delta features.
37
Features: Delta Values
Derivation of delta formula:
m
n ( xy)   x  y
n x   x 
2
2

d n ,t 
linear regression formula
for slope of n points (xi,yi)
n  (  cn ,t  ) 
 


 c





2
  
n     
 
   

2
n ,t 
xi = frame index from – to 
yi = cn,t+i

d n ,t 
(  c



n ,t 
)
remove factors that cancel out




2


d n ,t 
 (c


1
n ,t 

 cn ,t  )
2  2
 1
change limits on sum from
(– … ) to (1 … ) 38
Removing Noise: CMS
Convolutional noise (from type of channel) is
• convolutional in the time domain
• multiplicative in the spectral domain
• additive in the log-spectral domain
So, we can remove constant convolutional effects by removing
constant values from the log spectrum, which is called spectral
mean subtraction
Cepstral Mean Subtraction (CMS)
removes mean value from cepstral parameters to reduce
convolutional noise, in the cepstral domain
CMS assumes that there is enough of a signal that the mean is
not significantly influenced by the speech component of the signal.
39
Removing Noise: RASTA
2 types of noise:
• additive:
noise values added to time-domain signal
• convolutional: noise values added to log-domain spectrum
In RASTA, the time trajectory of the log power spectrum (or
cepstral coefficients) is filtered with a band-pass filter:
The high-pass portion of the filter alleviates channel characteristics,
the low-pass portion smooths small frame-to-frame changes.
If, instead of log compression, a linear-log compression is
done (linear for small spectral values), both additive and
convolutional noise can be suppressed.
40
Features: Summary
Typical features represent the speech signal using a small
analysis window (e.g. 16 msec) with a medium-size frame
rate (e.g. 10 msec).
Dynamics of speech, removing channel noise are addressed,
but current solutions may not be optimal solutions.
PLP and MFCC features are advantageous because they mimic
some of the human processing of the signal, emphasizing
the perceptually-important aspects.
The use of a small number of cepstral coefficients approximates
the spectral envelope, removing (unwanted) information about
pitch.
Usually one set of generic features is used; features not “targeted”
to any specific phonemes.
41