Speech Noise cancellation - scilab code

Senthilkumar December 28, 20116 comments Coded in Scilab

This program is used to perform speech noise cancellation using LMS adaptive filter in scilab

//Caption: Speech Noise Cancellation using LMS Adaptive Filter

clc;
//Reading a speech signal
[x,Fs,bits]=wavread("E:\4.wav");
order = 40;  // Adaptive filter order
x = x';
N = length(x);
t = 1:N;
//Plot the speech signal
figure(1)
subplot(2,1,1)
plot(t,x)
title('Noise free Speech Signal')
//Generation of noise signal
noise = 0.1*rand(1,length(x));
//Adding noise with speech signal
for i = 1:length(noise)
    primary(i)= x(i)+noise(i);
end
//Plot the noisy speech signal
subplot(2,1,2)
plot(t,primary)
title('primary = speech+noise (input 1)')
//Reference noise generation
for i = 1:length(noise)
    ref(i)= noise(i)+0.025*rand(10);
end
//Plot the reference noise
figure(2)
subplot(2,1,1)
plot(t,ref)
title('reference noise (input 2)')
//Adaptive filter coefficients initialized to zeros
w = zeros(order,1);
Average_Power = pow_1(x,N)
mu = 1/(10*order*Average_Power); //Adaptive filter step size
//Speech noise cancellation
for k = 1:110
    for i =1:N-order-1
        buffer = ref(i:i+order-1); //current order points of reference
        desired(i) = primary(i)-buffer'*w; // dot product the reference & filter
        w = w+(buffer.*mu*desired(i)); //update filter coefficients
    end
end
//Plot the Adaptive Filter output
subplot(2,1,2)
plot([1:length(desired)],desired)
title('Denoised Speech Signal at Adaptive Filter Output')
//Calculation of Mean Squarred Error between the original speech signal and
//Adaptive filter output
for i =1:N-order-1
    err(i) = x(i)-desired(i);
    square_error(i)= err(i)*err(i);
end
MSE = (sum(square_error))/(N-order-1);
MSE_dB = 20*log10(MSE);
//Playing the original speech signal
sound(x,Fs,16)
//Delay between playing sound signals
for i = 1:1000
    j = 1;
end
/////////////////////////////////
//Playing Noisy Speech Signal
sound(primary,Fs,16)
//Delay between playing sound signals
for i = 1:1000
    j = 1;
end
/////////////////////////////////
//Playing denoised speech signal (Adaptive Filter Output)
sound(desired,Fs,16)

Comments:

Swavanthi
Said:
Can you please give us the codes to generate square waves using TMS320C6713 in cc studio. This is for our final year project. If possible please mail it to swavanthi.cec@gmail.com
6 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
raghuramg
Said:
sir im getting errors in this coding...can u pls correct the errors and post it as soon as possible... for k = 1:110 for i =1:N-(order-1) buffer = ref(i:i+(order-1)); %current order points of reference*/ desired(i) = primary(i)-buffer*w; % dot product the reference & filter*/ w =(buffer*mu*desired(i)); %update filter coefficients*/ end end .......and error is....??? Error using ==> mtimes Inner matrix dimensions must agree.
6 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
Padma naik
Said:
Sir can u give me interfacing c source code for acoustic echo cancellation using tms320c5505 ezdsp usb stick and 1k hz audio tone generation
4 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
abhi5491
Said:
I am trying to implement rls code.I have implemented it on tmsc6713dsk but i am not able to achieve snr of 30 dB.The algorithm works as i can hear the noise getting cancelled
Any one please help.
2 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
zaka125
Said:
Sir I am doing Master degree , I need a topic for my semester subject based research paper topic...
2 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
Sorry, you need javascript enabled to post any comments.