# Residual Echo Suppression Considering Harmonic Distortion and Temporal Correlation
## 4 Residual Echo Suppression Considering Harmonic Distortion and Temporal Correlation
The weights \(W_{Hs}(i,j,k)\), \(W_{T1s}(p,f)\), \(W_{T2s}(p,f)\), and \(W_{T3s}(p,f)\) used for the single-talk periods are adapted as follows:  
\[W_{Hs}(i,j,k)\gets W_{Hs}(i,j,k)+\frac{\mu}{\bar{P}_{X}(m,i)}|X^{\prime}( m,i)|\xi_{ST}(m,i\times j+k), \tag{12}\]  
\[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]  
\[W_{T52}(p,f)\gets W_{T52}(p,f)+\frac{\mu}{\bar{P}_{D}(m-p,f)}|\bar{D}_{r}( m-p,f)|\xi_{ST}(m,f), \tag{14}\]  
\[W_{T53}(p,f)\gets W_{T53}(p,f)+\frac{\mu}{\bar{P}_{Y}(m-p,f)}|Y(m-p,f)|\xi_{ ST}(m,f), \tag{15}\]  
\[\xi_{ST}(m,f)=|E(m,f)|-|\bar{D}_{ST}(m,f)|, \tag{16}\]  
where \(\xi_{ST}(m,f)\) is the error, \(\mu\) is the step size, and \(\bar{P}_{X}\), \(\bar{P}_{D}\), and \(\bar{P}_{Y}\) are smoothed powers given by:  
\[\bar{P}_{X}(m,f)=(1-\rho)\bar{P}_{X}(m-1,f)+\rho|X^{\prime}(m,f)|^{2}, \tag{17}\]  
\[\bar{P}_{D}(m,f)=(1-\rho)\bar{P}_{D}(m-1,f)+\rho|\hat{D}_{r}(m,f)|^{2}, \tag{18}\]  
\[\bar{P}_{Y}(m,f)=(1-\rho)\bar{P}_{Y}(m-1,f)+\rho|Y(m,f)|^{2}, \tag{19}\]  
in which \(\rho\) is the smoothing parameter. As for the parameters used to estimate the residual noise during the double-talk period, \(W_{Hd}(i,j,k)\), \(W_{T1d}(p,f)\), and \(W_{T2d}(p,f)\), are updated as follows:  
\[W_{Hd}(i,j,k)\gets W_{Hd}(i,j,k)+\frac{\mu}{\bar{P}_{X}(m,i)}|X^{\prime}( m,i)|\xi_{DT}(m,i\times j+k), \tag{20}\]  
\[W_{Td1}(p,f)\gets W_{Td1}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}( m-p,f)|\xi_{DT}(m,f), \tag{21}\]  
\[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]0  
\[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]1  
It is noted that the weights used to estimate the residual echo magnitude in the double-talk periods are updated with Equations (20)-(22) in the far-end single-talk period, not in the double-talk period. This is because the weights \(W_{Hd}\), \(W_{Td1}\), and \(W_{Td2}\) try to estimate the effect of the linear echo in the harmonically related frequencies, the linear echo in the previous frames, and the residual echo in the previous frames to the residual echo in the current frame, but the \(|X^{\prime}|\) and \(|\hat{D}_{r}|\) in the double talk period contain a significant amount of near-end speech which disrupts the estimation of \(W_{Hd}\), \(W_{Td1}\), and \(W_{Td2}\). With the estimated magnitude of the residual echo in the Equation (11), \(|\hat{D}_{r}(m,f)|\), the output of the linear echo canceller, \(|E(m,f)|\), and the estimate of the magnitude of the noise spectrum obtained by the minimum statistics approach [29], \(|\hat{N}(m,f)|\), the real-valued gain function of the residual echo suppressor, \(G(m,f)\), is constructed as a spectral subtraction with a noise floor as in [27; 28]. \[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]2where \(\beta\) is a parameter that controls the aggressiveness of the RES, \(\max(\cdot,\cdot)\) function returns the largest value between two variables, and \(\bar{D}_{r}\), \(\bar{E}\), and \(\bar{N}\) are smoothed versions of \(|\hat{D}_{r}\), \(|E|\), and \(|\hat{N}|\) obtained by:  
\[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]3 \[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]4 (26) \[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]5  
in which \(\alpha\) is a smoothing factor. The final output of the RES is obtained by:  
\[W_{T51}(p,f)\gets W_{T51}(p,f)+\frac{\mu}{\bar{P}_{X}(m-p,f)}|X^{\prime}(m-p,f)|\xi_{ST}(m,f), \tag{13}\]6  
where \(\exp(\cdot)\) is the exponential function, and the time domain signal \(\hat{s}(t)\) is computed by an inverse short-time Fourier transform of \(\hat{S}(m,f)\).