forked from aliutkus/speechmetrics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
105 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from .. import Metric | ||
import numpy as np | ||
from numpy.linalg import norm | ||
|
||
|
||
class SISDR(Metric): | ||
def __init__(self, window, hop=None): | ||
super(SISDR, self).__init__(name='SISDR', window=window, hop=hop) | ||
self.mono = True | ||
|
||
def test_window(self, audios, rate): | ||
# as provided by @Jonathan-LeRoux and slightly adapted for the case of just one reference | ||
# and one estimate. | ||
# see original code here: https://github.com/sigsep/bsseval/issues/3#issuecomment-494995846 | ||
eps = np.finfo(audios[0].dtype).eps | ||
reference = audios[1].reshape(audios[1].shape[0], -1) | ||
estimate = audios[0].reshape(audios[0].shape[0], -1) | ||
Rss = np.dot(reference.T, reference) | ||
|
||
# get the scaling factor for clean sources | ||
a = (eps + np.dot(reference.T, estimate)) / (Rss + eps) | ||
|
||
e_true = a * reference | ||
e_res = estimate - e_true | ||
|
||
Sss = (e_true**2).sum() | ||
Snn = (e_res**2).sum() | ||
|
||
return {'sisdr': 10 * np.log10((eps+ Sss)/(eps + Snn))} | ||
|
||
def load(window, hop=None): | ||
return SISDR(window, hop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters