spectral subtraction noise suppression

10 views (last 30 days)
Deepa
Deepa on 23 Aug 2018
Answered: Deepa on 23 Aug 2018
hi, anyone please check my code for noise suppression using spectral subtraction.
fs =16000; t=0:1/fs:5; signal=2*sin(2*pi*50000*t); noise=5*rand(1,length(signal)); input_speech=noise+signal; removal_sample=input_speech(1,6000:end); NFFT=256; window_length=256; window=hamming(window_length); window = window(:); overlap=floor(0.45*window_length); t_min=0.075; t_max=0.100; [STFT,Freq,Time] =spectrogram(input_speech+1i*eps,window,window_length-overlap,NFFT,fs); %put a short imaginary part to obtain two-sided spectrogram [Nf,Nw]=size(STFT); ind=mod((1:window_length)-1,Nf)+1; output_signal=zeros((Nw-1)*overlap+window_length,1);
%% %Overlapping for indice=1:Nw
left_index=((indice-1)*overlap) ;
index=left_index+[1:window_length];
temp_ifft=real(ifft(STFT(:,indice),NFFT));
output_signal(index)= output_signal(index)+temp_ifft(ind).*window;
end t_index=find(Time>t_min & Time<t_max); subplot(211);plot(t,signal,'g'); hold on; plot(t,noise,'r') hold off; title('Inputspeech'); subplot(212); plot([1:length(output_signal)]/fs,output_signal); xlabel('Time (s)'); ylabel('Amplitude'); title('Sound without noise'); t_epsilon=0.001; figure; S_one_sided=max(STFT(1:length(Freq)/2,:),t_epsilon); pcolor(Time,Freq(1:end/2),10*log10(abs(S_one_sided))); %keep only the positive frequency shading interp; colormap('hot'); title('Spectrogram:final speech'); xlabel('Time (s)'); ylabel('Frequency (Hz)'); audiowrite('finaloutput.wav',output_signal,fs); soundsc(output_signal,fs);
please, tell where I did wrong ?
Thnaks, Chinnydas
  2 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 23 Aug 2018
Edited: KALYAN ACHARJYA on 23 Aug 2018
Format the question properly? Visit Here
Have you got any error? Share the error? Pls attach finaloutput.wav?
Image Analyst
Image Analyst on 23 Aug 2018
Edited: Image Analyst on 23 Aug 2018
and explain why you believe there is something wrong with it. Tell us what you got, and what would be "right".

Sign in to comment.

Answers (1)

Deepa
Deepa on 23 Aug 2018
hi, I have attached my code here. but, couldn't able to attach my wav(finaloutput.wav) file.... and output signal I am receving is combination of both noise and signal. but, I should only get sinewave by suppressing or cancelling the added noise. Am i explain my expected output clearly ?
Thanks, Chinny

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!