Loading scripts/pyaudio3dtools/audioarray.py +5 −7 Original line number Diff line number Diff line Loading @@ -545,19 +545,17 @@ def ssnr( test_sig_norm = test_sig / -np.iinfo(np.int16).min # check if diff of signal is zero already, then SNR is infinite, since no noise diff_norm = ref_sig_norm - test_sig_norm if np.all(diff_norm == 0): diff_sig_norm = ref_sig_norm - test_sig_norm if np.all(diff_sig_norm == 0): return np.asarray([np.inf] * ref_sig_norm.shape[1]) denom_add = 10**-13 * len_seg segment_counter = np.zeros(ref_sig.shape[1]) for ref_seg, test_seg in zip( for ref_seg, diff_seg in zip( get_framewise(ref_sig_norm, len_seg, zero_pad=True), get_framewise(test_sig_norm, len_seg, zero_pad=True), get_framewise(diff_sig_norm, len_seg, zero_pad=True), ): nrg_ref = np.sum(ref_seg**2, axis=0) diff_seg = ref_seg - test_seg nrg_diff = np.sum(diff_seg**2, axis=0) ss_seg = np.log10(1 + nrg_ref / (denom_add + nrg_diff)) Loading @@ -581,7 +579,7 @@ def ssnr( ssnr[segment_counter == 0] = -np.inf # set to zero for channels with no diff (this handles e.g. the corner-case of an all-zero channel in both ref and dut) zero_diff_mask = np.asarray([np.all(diff_norm[:, c] == 0) for c in range(ref_sig.shape[1])]) zero_diff_mask = np.asarray([np.all(diff_sig_norm[:, c] == 0) for c in range(ref_sig.shape[1])]) ssnr[zero_diff_mask] = 0 return ssnr Loading
scripts/pyaudio3dtools/audioarray.py +5 −7 Original line number Diff line number Diff line Loading @@ -545,19 +545,17 @@ def ssnr( test_sig_norm = test_sig / -np.iinfo(np.int16).min # check if diff of signal is zero already, then SNR is infinite, since no noise diff_norm = ref_sig_norm - test_sig_norm if np.all(diff_norm == 0): diff_sig_norm = ref_sig_norm - test_sig_norm if np.all(diff_sig_norm == 0): return np.asarray([np.inf] * ref_sig_norm.shape[1]) denom_add = 10**-13 * len_seg segment_counter = np.zeros(ref_sig.shape[1]) for ref_seg, test_seg in zip( for ref_seg, diff_seg in zip( get_framewise(ref_sig_norm, len_seg, zero_pad=True), get_framewise(test_sig_norm, len_seg, zero_pad=True), get_framewise(diff_sig_norm, len_seg, zero_pad=True), ): nrg_ref = np.sum(ref_seg**2, axis=0) diff_seg = ref_seg - test_seg nrg_diff = np.sum(diff_seg**2, axis=0) ss_seg = np.log10(1 + nrg_ref / (denom_add + nrg_diff)) Loading @@ -581,7 +579,7 @@ def ssnr( ssnr[segment_counter == 0] = -np.inf # set to zero for channels with no diff (this handles e.g. the corner-case of an all-zero channel in both ref and dut) zero_diff_mask = np.asarray([np.all(diff_norm[:, c] == 0) for c in range(ref_sig.shape[1])]) zero_diff_mask = np.asarray([np.all(diff_sig_norm[:, c] == 0) for c in range(ref_sig.shape[1])]) ssnr[zero_diff_mask] = 0 return ssnr