Main Content

エコー キャンセル

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

この録音では、話者は MATLAB® という言葉を話しています。データとサンプルレート F s = 7 4 1 8 H z を読み込みます。

loadmtlb% 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;

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

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 contains an object of type line. This object represents Total.

% To hear, type soundsc(mtEcho,Fs)

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

[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 contains an object of type line.

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

[~,dl] = findpeaks(Rmm,lags,'MinPeakHeight',0.22); mtNew = filter(1,[1 zeros(1,dl-1) alpha],mtEcho);

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

次要情节(2,1,1)情节(t,源自)传说('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 contains an object of type line. This object represents Filtered.

% To hear, type soundsc(mtNew,Fs)

参考

関数