shithub: opus

ref: ba44bac43517ceb777f8638c5804aa7d5e22119f
dir: /dnn/torch/testsuite/utils/pesq.py/

View raw version
import pesq
import librosa

def compute_PESQ(ref, test, fs=16000):

    if not ref.endswith('.wav') or not test.endswith('.wav'):
        raise ValueError('error: expecting .wav as file extension')

    ref_item, _ = librosa.load(ref, sr=fs)
    test_item, _ = librosa.load(test, sr=fs)

    score = pesq.pesq(fs, ref_item, test_item)

    return score