def NMREval(self, xn, xnhat):
""" Method to perform NMR perceptual evaluation of audio quality between two signals.
Args :
xn : (ndarray) 1D Array containing the true time domain signal.
xnhat : (ndarray) 1D Array containing the estimated time domain signal.
Returns :
NMR : (float) A float measurement in dB providing a perceptually weighted
evaluation. Below -9 dB can be considered as in-audible difference/error.
As appears in :
- K. Brandenburg and T. Sporer, “NMR and Masking Flag: Evaluation of Quality Using Perceptual Criteria,” in
Proceedings of the AES 11th International Conference on Test and Measurement, Portland, USA, May 1992, pp. 169–179
- J. Nikunen and T. Virtanen, "Noise-to-mask ratio minimization by weighted non-negative matrix factorization," in
Acoustics Speech and Signal Processing (ICASSP), 2010 IEEE International Conference on, Dallas, TX, 2010, pp. 25-28.
"""
mX, _ = TimeFrequencyDecomposition.STFT(xn, hanning(self.nfft/2 + 1), self.nfft, self.nfft/4)
mXhat, _ = TimeFrequencyDecomposition.STFT(xnhat, hanning(self.nfft/2 + 1), self.nfft, self.nfft/4)
# Compute Error
Err = np.abs(mX - mXhat) ** 2.
# Acquire Masking Threshold
mT = self.maskingThreshold(mX)
# Inverse the filter of masking threshold
imT = 1./(mT + eps)
# Outer/Middle Ear transfer function on the diagonal
LTq = 10 ** (self.MOEar()/20.)
# NMR computation
NMR = 10. * np.log10((1./mX.shape[0]) * self._maxb * np.sum((imT * (Err*LTq))))
print(NMR)
return NMR
评论列表
文章目录