File size: 604 Bytes
091b1e0
 
 
 
bd0a813
091b1e0
 
 
 
 
 
bd0a813
091b1e0
bd0a813
 
 
091b1e0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from torchmetrics.audio.pesq import PerceptualEvaluationSpeechQuality
from torchmetrics.audio.stoi import ShortTimeObjectiveIntelligibility
import torch
import torchaudio
from torchmetrics import SignalNoiseRatio


class Metrics:
    def __init__(self, rate=16000):
        self.nb_pesq = PerceptualEvaluationSpeechQuality(rate, 'wb')
        self.stoi = ShortTimeObjectiveIntelligibility(rate, False)
        self.snr = SignalNoiseRatio()
        
    def calculate(self, denoised, clean):
        return {'PESQ': self.nb_pesq(denoised, clean),
                'STOI': self.stoi(denoised, clean)}