Implementation of Linear Predictive Coding (LPC) of Speech: Outline
Implementation of Linear Predictive Coding (LPC) of Speech: Outline
=
=
p
i
i i
a a
G
z H
1
*
) 1 )( 1 (
) (
Implementation of LPC
Speech Modeling Transfer Function
Example: a 10
th
order transfer function
model:
6
Speech Modeling Radiation
Implementation of LPC
Models how sound is radiated by the lips
Usually approximated by a digital
differentiator:
Radiation is not important for classification
of a sound
Thus, we will omit it from our
implementation
1
1 ) (
= z z R
Implementation of LPC
Architecture Overview
Voice
Voice
Segmentation
Segmentation
Pitch
Detection
Pitch
Detection
LPC
LPC
Parameters:
Silence
LPC Coeff.
Gain
Voiced/Unvoiced
Pitch Frequency
Parameters:
Silence
LPC Coeff.
Gain
Voiced/Unvoiced
Pitch Frequency
Channel
Channel
LPC
Synthesizer
LPC
Synthesizer
7
Implementation of LPC
Voice Segmentation
20 ms
30 ms
Overlap
8000 samples/sec
20 ms step size (160 samples)
30 ms window (240 samples)
Process 240 samples in 20 ms
Implementation of LPC
Voice Segmentation - Filtering and Windowing
z
-1
-0.98
Segment
Samples
Hamming
Window
Coefficients
To Silence Detection,
LPC and Pitch
Detection
0 50 100 150 200 250
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1 0
)
1
2
cos( 46 . 0 54 . 0 ) (
=
=
N n
N
n
n w
8
Implementation of LPC
Voice Segmentation - Silence Detection
Compute R(0)
Compute R(0)
Is R(0) > R(0)
for Background
Noise
Is R(0) > R(0)
for Background
Noise
Yes
Yes
No
No
Compute LPC
and Pitch
Detection
Compute LPC
and Pitch
Detection
Silence
Period: Stop
Algorithm
and set G
2
=0
Silence
Period: Stop
Algorithm
and set G
2
=0
Implementation of LPC
LPC - Motivation
Speech Difference Equation for a p
th
order filter:
=
+ =
p
k
k
n Gu k n s a n s
1
) ( ) ( ) (
Want to minimize the mean-squared prediction error:
=
=
p
k
k
k n s n s n e
1
) ( ) ( ) (
For a single input impulse or stationary white noise,
the obtained coefficients are identical to the a
k
s
9
Implementation of LPC
LPC - Autocorrelation (1)
If we assume that s(n) is zero outside the interval 0 n N-1,
we then need to solve the following set of linear equations:
( ) p i i R k i R
p
k
k
=
=
1 ) (
1
Where:
=
+ =
k N
m
k m s m s k R
1
0
) ( ) ( ) (
Implementation of LPC
LPC - Autocorrelation (2)
In matrix form the set of linear equation can be expressed as:
) (
) 3 (
) 2 (
) 1 (
) 0 ( ) 3 ( ) 2 ( ) 1 (
) 3 ( ) 0 ( ) 1 ( ) 2 (
) 2 ( ) 1 ( ) 0 ( ) 1 (
) 1 ( ) 2 ( ) 1 ( ) 0 (
3
2
1
p R
R
R
R
R p R p R p R
p R R R R
p R R R R
p R R R R
p
10
Implementation of LPC
LPC - Levinson-Durbin Algorithm (1)
By exploiting
Toeplitz structure of the matrix;
Particular structure of the right-hand side of the linear system
of equation
We can use the efficient Levinson-Durbin recursive procedure
to solve this particular system of equations.
Implementation of LPC
LPC - Levinson-Durbin Algorithm (2)
The Levinson-Durbin recursive procedure is given by:
( )
) 1 ( 2 ) (
) 1 ( ) 1 ( ) (
) (
) 1 (
1
1
) 1 (
(0)
1
1 1 for
) ( ) (
1 for
) 0 ( E
=
=
=
=
=
i
i
i
i
j i i
i
j
i
j
i
i
i
i
i
j
i
j
i
E k E
k
i j
k
E
j i R i R
k
p i
R
=
= =
p
k
n k
E k R R G
1
2
) ( ) 0 (
Where E
n
is the minimum mean squared error
prediction and is given by E
(p)
from Levinson-
Durbins Algorithm.
We will transmit G
2
.
Implementation of LPC
LPC Algorithm
From Segmentation:
s(n) and R(0)
From Segmentation:
s(n) and R(0)
Compute R(i) 1 i p
Compute R(i) 1 i p
Levinson-Durbins Algorithm:
Find
i
1 i p
and G
2
Levinson-Durbins Algorithm:
Find
i
1 i p
and G
2
Transmit
to decoder
Transmit
to decoder
12
Pitch Detection - Motivation
Implementation of LPC
Recall that source can be either a periodic
impulse train spaced by F
0
or random noise
Autocorrelation function of a speech frame:
If x(n) is periodic in N, then R(k) is also
periodic in N
Thus, we can compute R(k) and check if its
periodic
=
+ =
1
0
) ( ) ( ) (
k N
m
k m x m x k R
Implementation of LPC
Pitch Detection Motivation
First we clip the frame using 3-level center
clipping function:
That is:
C
L
-C
L
+1
-1
otherwise
C n x if
C n x if
n x C
L
L
<
>
+
= ) (
) (
0
1
1
)] ( [
x(n)
C[x(n)]
13
Implementation of LPC
Pitch Detection Motivation
Next we compute the modified
autocorrelation function:
where can have only 3
different values:
=
+ =
1
0
) ( ) ( ) (
k N
m
n
k m x m x k R
) ( ) ( k m x m x +
0 ) ( 0 ) (
) ( ) (
) ( ) (
0
1
1
) ( ) (
= + =
+
+ =
+
= +
k m x or m x if
k m x m x if
k m x m x if
k m x m x
Implementation of LPC
Pitch Detection Motivation
We dont need to compute for all
values of k (i.e. 0 k N)
Thus we only need to look in the range:
80 Hz F
0
350 Hz
) (k R
n
200 80 men
350 150 women
F
0
(Hz) max F
0
(Hz) min
14
Pitch Detection Algorithm
Speech
Frame
x(n)
Speech
Frame
x(n)
LPF
F
c
= 900 Hz
LPF
F
c
= 900 Hz
C
L
= 30% of
max{x(n)}
C
L
= 30% of
max{x(n)} Clip x(n)
Clip x(n)
Compute AC
R
n
(k) for
F
s
/350 k F
s
/80
Compute AC
R
n
(k) for
F
s
/350 k F
s
/80
Compute
R = max{R
n
(k)}
Compute
R = max{R
n
(k)}
Compute
R
n
(0)
Compute
R
n
(0)
if R 30% of R
n
(0) then frame is voiced,
output pitch period = k + F
s
/350
else frame is unvoiced,
output 0
if R 30% of R
n
(0) then frame is voiced,
output pitch period = k + F
s
/350
else frame is unvoiced,
output 0
Implementation of LPC
Implementation of LPC
LPC Synthesizer
Impulse
Train
Generator
Pitch
Period
Random
Noise
Generator
Voice/
Unvoiced
Switch
2
G
Time-Varying
IIR Filter
s '
i
15
References
Implementation of LPC
L. R. Rabiner and R. W. Schafer. Digital
Processing of Speech Signals. Prentice Hall,
Englewood Cliffs, New Jersey, 1978.
Douglas OShaugnessy. Speech
Communication Human and Machine.
Addison Wesley Books, 1978.
M. M. Sondhi. New Methods of Pitch
Extraction. IEEE Trans. Audio and
Electroacoustics, Vol. AU-16, No. 2, pp.
262-266, June 1968.