MCPcopy
hub / github.com/Audio-AGI/AudioSep / calculate_sdr

Function calculate_sdr

utils.py:148–169  ·  view source on GitHub ↗

r"""Calculate SDR between reference and estimation. Args: ref (np.ndarray), reference signal est (np.ndarray), estimated signal

(
    ref: np.ndarray,
    est: np.ndarray,
    eps=1e-10
)

Source from the content-addressed store, hash-verified

146
147
148def calculate_sdr(
149 ref: np.ndarray,
150 est: np.ndarray,
151 eps=1e-10
152) -> float:
153 r"""Calculate SDR between reference and estimation.
154
155 Args:
156 ref (np.ndarray), reference signal
157 est (np.ndarray), estimated signal
158 """
159 reference = ref
160 noise = est - reference
161
162
163 numerator = np.clip(a=np.mean(reference ** 2), a_min=eps, a_max=None)
164
165 denominator = np.clip(a=np.mean(noise ** 2), a_min=eps, a_max=None)
166
167 sdr = 10. * np.log10(numerator / denominator)
168
169 return sdr
170
171
172def calculate_sisdr(ref, est):

Callers 7

__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected