⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 huishengxiaochu.m

📁 一个用matlab做的电话声学回声消除程序
💻 M
字号:
clear;
clc;
%% read the far speech signal
[y, fs, bits]   = wavread('farspeech.wav');
fspeech = y;
clear y;

%% read the near speech signal
[y, fs, bits]   = wavread('nearspeech.wav');
nspeech = y;
clear y;

%% the impulse response of room
M       = 4001;
[B, A]  = cheby2(4, 20, [0.1 0.7]);
H       = filter(B, A, log(0.99*rand(1,M)+0.01).*sign(randn(1,M)).*exp(-0.002*(1:M)));
H       = H/norm(H) * 4;
%% draw room impulse response figure
% plot(0:1/fs:0.5, H);
% xlabel('Time [sec]');
% ylabel('Amplitude');
% title('Room Impulse Response');

%% the signal of far speech through room impulse response
Afspeech= filter(H, 1, fspeech);        %Afspeech is the signal of far speech through room impulse response

n       = 1:length(fspeech);            %data length
t       = n / fs;                       %sound signal length
% plot(t, nspeech, 'g');
% axis([0 33.5 -1 1]);
% xlabel('Time (s)');
% ylabel('Amplitude');
% title('Near-End Speech Signal');

%% microphone composite signal 
csignal = Afspeech + nspeech + 0.001*randn(length(nspeech), 1);
% plot(t, csignal, 'r');
% axis([0 33.5 -1 1]);
% xlabel('Time (s)');
% ylabel('Amplitude');
% title('Microphone Composite Signal');

%% calculate Power Spectral Density of far speech 
% Hs      = spectrum.welch;
% hpsd    = psd(Hs, fspeech, 'Fs', fs);

%% AF based on LMS
miu     = 0.1;                          %step size of lms filter
norder  = 1500;                         %order of lms filter
hdLMS   = adaptfilt.lms(norder, miu);
mumax   = maxstep(hdLMS, csignal);
hdLMS   = adaptfilt.lms(norder, mumax);
[y, zf] = filter(hdLMS, fspeech, csignal);
subplot(3,1,1);
plot(t, nspeech, 'g');
axis([0 33.5 -1 1]);
xlabel('Time (s)');
ylabel('Amplitude');
title('Near-End Speech Signal');
subplot(3,1,2);
plot(t, csignal, 'r');
axis([0 33.5 -1 1]);
xlabel('Time (s)');
ylabel('Amplitude');
title('Microphone Composite Signal');
subplot(3,1,3);
plot(t, zf);
axis([0 33.5 -1 1]);
xlabel('Time (s)');
ylabel('Amplitude');
title('Output of Acoustic Echo Canceller');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -