[speech denoising] Wiener filtering algorithm based on a priori SNR speech denoising matlab source code

1, Introduction

This chapter proposes a speech enhancement algorithm, which is based on Wiener filtering method based on a priori SNR estimation. The initial noise power spectrum is obtained by calculating the statistical average of the silent segment, and the initial noise power spectrum and the noisy speech power spectrum are smoothed to update the noise power spectrum; Finally, considering the sharp increase of noise at a certain frequency point, the correlation verification is done. The algorithm can effectively suppress the noise with small or stable variation range, but the effect on the noise with wide variation range in practice is not very good.
1. Speech enhancement overview
1.1 related concepts of speech enhancement
Embedded in the speech system, the speech signal will inevitably be disturbed by the surrounding noise, which will affect the quality and intelligibility of speech.
Speech enhancement: in fact, it is to extract as pure speech as possible from noisy speech, improve speech quality and intelligibility, and improve the performance of speech communication system in noisy environment.
Noise is generated randomly and cannot be completely eliminated. The goal of speech enhancement is to reduce noise, eliminate background noise, improve speech quality, make listening willing to accept and improve speech intelligibility.
1.2 related algorithms of speech enhancement
Due to many sources of noise, the characteristics are different. The applications of speech enhancement processing system vary greatly.
Therefore, there is no speech enhancement algorithm that can be used in various noise environments. Different speech enhancement algorithms are adopted for different environments.
According to the processing methods, speech enhancement algorithms can be divided into: enhancement algorithm based on speech periodicity, enhancement algorithm based on all pole model, enhancement algorithm based on short-time spectrum estimation, enhancement algorithm based on signal subspace and
HMM based enhancement algorithm.
From the current development, the method based on short-time spectrum estimation is the most effective method. Specifically, it includes spectral subtraction, Wiener filtering, minimum mean square error short-time spectral amplitude estimation (MMSE-STSA) and minimum mean square error logarithmic spectral amplitude estimation (MMSE-LSA). This paper mainly discusses the implementation of speech enhancement using Wiener filter.
2 Wiener filter speech enhancement theory based on a priori SNR estimation
A priori signal-to-noise ratio is a very important parameter in speech enhancement algorithm. The method of calculating a priori signal-to-noise ratio by "direct decision" estimation proposed by Ephraim and Malah is the most effective and easy to calculate.

2, Source code

clear all; clc; close all;

[xx, fs] = wavread('C5_3_y.wav');           % Read in data file
xx=xx-mean(xx);                         % Eliminate DC component
x=xx/max(abs(xx));                      % Amplitude normalization
IS=0.25;                                % Set the length of leading non session
wlen=200;                               % Set the frame length to 25 ms
inc=80;                                 % Set frame shift to 10 ms
SNR=5;                                  % Set SNR SNR
NIS=fix((IS*fs-wlen)/inc +1);           % Find the number of leading no segment frames
alpha=0.95;

signal=awgn(x,SNR,'measured','db');               % Superimposed noise
output=Weina_Im(x,wlen,inc,NIS,alpha) ;
output=output/max(abs(output));
len=min(length(output),length(x));
x=x(1:len);
signal=signal(1:len);
output=output(1:len);

snr1=SNR_Calc(x,signal);            % Calculate the initial signal-to-noise ratio
snr2=SNR_Calc(x,output);            % Calculate the signal-to-noise ratio after noise reduction
snr=snr2-snr1;
fprintf('snr1=%5.4f   snr2=%5.4f   snr=%5.4f\n',snr1,snr2,snr);

% Mapping
time=(0:len-1)/fs;                        % Set time
subplot 311; plot(time,x,'k'); grid; axis tight;
title('Pure speech waveform'); ylabel('amplitude')
subplot 312; plot(time,signal,'k'); grid; axis tight;
title(['Noisy speech signal to noise ratio=' num2str(SNR) 'dB']); ylabel('amplitude')
function frameout=enframe(x,win,inc)

nx=length(x(:));            % Fetch data length
nwin=length(win);           % Window length
if (nwin == 1)              % Judge whether the window length is 1. If it is 1, it means that there is no window function
   len = win;               % Yes, frame length=win
else
   len = nwin;              % No, frame length=Window length
end
if (nargin < 3)             % If there are only two parameters, set the frame inc=Frame length
   inc = len;
end
nf = fix((nx-len+inc)/inc); % Calculate the number of frames
frameout=zeros(nf,len);            % initialization
indf= inc*(0:(nf-1)).';     % Set each frame at x Displacement position in
inds = (1:len);             % Each frame of data corresponds to 1:len
frameout(:) = x(indf(:,ones(1,len))+inds(ones(nf,1),:));   % Framing data
if (nwin > 1)               % If the parameter includes a window function, multiply each frame by the window function
    w = win(:)';            % hold win Convert to row data
    function frameout=filpframe(x,win,inc)

[nf,len]=size(x);
nx=(nf-1) *inc+len;                 %Original signal length
frameout=zeros(nx,1);
nwin=length(win);                   % Window length
if (nwin ~= 1)                           % Judge whether the window length is 1. If it is 1, it means that there is no window function
    winx=repmat(win',nf,1);
    x=x./winx;                          % Remove the effect of windowing
    x(find(isinf(x)))=0;                %Obtained by removing 0 Inf
end

 
for i=1:nf
    start=(i-1)*inc+1;    
    xn=x(i,:)';
    sig(start:start+len-1)=sig(start:start+len-1)+xn;
end

3, Operation results

4, Remarks

Complete code or write on behalf of QQ1575304183

Review of previous periods > > > > >

[signal processing] matlab source code of signal denoising based on LMS algorithm

[speech denoising] Wiener filtering algorithm based on a priori SNR speech denoising matlab source code

[signal denoising] matlab source code for denoising based on spectral subtraction

[speech denoising] speech denoising matlab source code based on basic Wiener filtering algorithm

[speech denoising] matlab source code of speech denoising based on improved spectral subtraction

Keywords: MATLAB

Added by tobimichigan on Sat, 05 Mar 2022 02:34:26 +0200