shithub: opus

ref: 4f3761b0199df7024b6e6b2004fc5eb7a6dbb28b
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