File size: 757 Bytes
936f6fa
 
 
 
 
 
 
 
 
 
 
 
 
 
d67d869
936f6fa
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np
from basis import ScoreBasis


class BSSEval(ScoreBasis):
    def __init__(self):
        super(BSSEval, self).__init__(name='BSSEval')
        self.intrusive = False

    def windowed_scoring(self, audios, score_rate):
        bss_window = np.inf
        bss_hop = np.inf
        from museval.metrics import bss_eval
        if len(audios) != 2:
            return None
        
        result = bss_eval(reference_sources=audios[1][None,...], # shape: [nsrc, nsample, nchannels]
                        estimated_sources=audios[0][None,...],
                        window=bss_window * score_rate,
                        hop=bss_hop * score_rate)
        return {'SDR': result[0][0][0], 'ISR': result[1][0][0], 'SAR': result[3][0][0]}