An adaptive filter is a computational device that iteratively models the connection between the input and output signals of the filter. An adaptive filter self-adjusts the filter coefficients consistent with an adaptive algorithmic program. The subsequent figure shows the diagram of a typical adaptive filter…

Installing Python

First, install some dependencies:

Then download using the following command:

Extract and go to the dirctory:

Now, install using the command:

To install from PyPI using pip simply run:

Acoustic echo cancellation in white background noise with NLMS.

Consider a scenario where two individuals, John and Emily, are talking over the Internet. John is using his loudspeakers, which means Emily can hear herself through John’s microphone. The speech signal that Emily hears, is a distorted version of her own. This is caused by the acoustic path from John’s loudspeakers to his microphone. This path includes attenuated echoes, etc.

Now for the problem!

Emily wishes to cancel the echo she hears from John’s microphone. Emily only knows the speech signal she sends to him, call that u(n), and the speech signal she receives from  him, call that d(n). To successfully remove her own echo from d(n), she must approximate the acoustic path from John’s loudspeakers to his microphone. This path can be approximated by a FIR filter, which means an adaptive NLMS FIR filter can be used to identify it. The model which Emily uses to design this filter looks like this:

Capture

As seen, the signal that is sent to John is also used as input to the adaptive NLMS filter. The output of the filter, y(n), is subtracted from the signal received from John, which results in an error signal e(n) = d(n)-y(n). By feeding the error signal back to the adaptive filter, it can minimize the error by approximating the impulse response (that is the FIR filter coefficients) of John’s room. Note that so far John’s speech signal v(n) has not been taken into account. If John speaks, the error should equal his speech, that is, e(n) should equal v(n). For this simple example, however, we assume John is quiet and v(n) is equal to white Gaussian background noise with zero-mean. In the following example we keep the impulse response of John’s room constant.

This is not required, however, since the advantage of adaptive filters, is that they can be used to track changes in the impulse response.

It Will the graphs like the following