Kalman filter was introduced in front, but its specific application was not introduced due to space reasons. Here we introduce the process of using Kalman filter to do echo cancellation. We know that Speex and WebRTC echo cancellation are based on NLMS algorithm, but some companies use Kalman filter for echo cancellation. True echo cancellation also includes the nonlinear part behind the filter, and today only the linear echo cancellation part will be discussed.

Echo cancellation

We’ve talked about echo cancellation before, but just to recap, let’s say that the frame length is L and the remote signal is

Then the signal collected by the microphone can be expressed as

Among themv(n) is the proximal signal,h(n) is the impulse response of the sound system from speaker to microphone

What echo cancellation does is to approximate the impulse response of the above system with an adaptive filter, and then we can subtract the near-end signal from the estimated echo

Equation of state

We write the remote signal of the nearest P frame as a matrix of size (L, P)

At this point, echo signal can be expressed as

Similarly, the microphone acquisition signal can be written as

Equation (6) is called the equation of state. We assume thath(n) is a random vector with zero mean and conforms to the first order Markov model, i.e

Among themw(n) is a zero-mean Gaussian white noise signal vector and is equal tohAnd (n – 1)v(n) is irrelevant.wThe correlation matrix for phi n can be written as

wVariance of is used to measurehIt determines the tracking ability and convergence of kalman filter to echo path. According to Formula (6), we can define echo-to-noise ratio (ENR).

Kalman filter

According to the Bayesian method, we can obtain the optimal echo path estimation, that is, the state vector can be written as

Among themKIt’s kalman’s gain matrix;eIs the prior error between the estimates of the microphone signal and the echo signal

The corresponding posterior error is defined as:

Among them

Call this state estimation error or posterior disorder. Transcendental dissonance is defined as:

The relationship between the prior dissonance correlation matrix at any given moment n and the posterior dissonance correlation matrix at n-1 moment is

The Kalman gain matrix is obtained by minimizing the following loss function

Easy to draw

Then the prior and posterior error correlation matrices are calculated

Finally, the posterior error correlation matrix is updated

Finally, we summarize the whole process of Kalman filtering:

Echo cancellation effect

Finally, we compare the effects of LMS and Kalman filter, using the same audio data as parsing adaptive filter echo cancellation:

The first is the effect of LMS filter:

Then the effect of kalman filter:

It is obvious that the echo suppression effect of Kalman filter is better than that of LMS. In practice, this method is generally transformed to the frequency domain and divided into several subbands for processing.

The relevant codes and data in this paper can be obtained by clicking Code on the menu bar of the voice algorithm group of the public account.

References:

[1]. Study of the general kalman lter for echo cancellation