Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

エコー キャンセル

音声の録音には壁面からの反射によるエコーが含まれることがあります。自己相関を使用したフィルター処理によりこれを除外します。

この録音では、話者は MATLAB® という言葉を話しています。データとサンプル レート Fs=7418Hz を読み込みます。

load mtlb

% To hear, type soundsc(mtlb,Fs)

Δ サンプル遅延させ、既知の係数 α: y(n)=x(n)+αx(n-Δ) により減衰させた信号のコピーを録音に追加して、エコーをモデル化します。タイム ラグを 0.23 秒に、減衰係数を 0.5 に指定します。

timelag = 0.23;
delta = round(Fs*timelag);
alpha = 0.5;

orig = [mtlb;zeros(delta,1)];
echo = [zeros(delta,1);mtlb]*alpha;

mtEcho = orig + echo;

% To hear, type soundsc(mtEcho,Fs)

元の信号、エコー、結果の信号をプロットします。

t = (0:length(mtEcho)-1)/Fs;

subplot(2,1,1)
plot(t,[orig echo])
legend("Original","Echo")

subplot(2,1,2)
plot(t,mtEcho)
legend("Total")
xlabel("Time (s)")

Figure contains 2 axes objects. Axes object 1 contains 2 objects of type line. These objects represent Original, Echo. Axes object 2 with xlabel Time (s) contains an object of type line. This object represents Total.

信号の自己相関の不偏推定を計算します。ゼロより大きいラグに対応するセクションを選択してプロットします。

[Rmm,lags] = xcorr(mtEcho,"unbiased");

Rmm = Rmm(lags>0);
lags = lags(lags>0);

figure
plot(lags/Fs,Rmm)
xlabel("Lag (s)")

Figure contains an axes object. The axes object with xlabel Lag (s) contains an object of type line.

自己相関は、エコーが到着した時点のラグで鋭いピークになります。出力 ww(n)+αw(n-Δ)=y(n) に従う IIR システムを通して信号をフィルター処理することにより、エコーをキャンセルします。

[~,dl] = findpeaks(Rmm,lags,MinPeakHeight=0.22);

mtNew = filter(1,[1 zeros(1,dl-1) alpha],mtEcho);

% To hear, type soundsc(mtNew,Fs)

フィルター処理した信号をプロットして、元の信号と比較します。

subplot(2,1,1)
plot(t,orig)
legend("Original")

subplot(2,1,2)
plot(t,mtNew)
legend("Filtered")
xlabel("Time (s)")

Figure contains 2 axes objects. Axes object 1 contains an object of type line. This object represents Original. Axes object 2 with xlabel Time (s) contains an object of type line. This object represents Filtered.

参考

関数