GithubHelp home page GithubHelp logo

peter94013 / python-pesq Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ludlows/pesq

0.0 0.0 0.0 298 KB

PESQ (Perceptual Evaluation of Speech Quality) Wrapper for Python Users (narrow band and wide band)

Home Page: https://github.com/ludlows/python-pesq

License: MIT License

Python 5.63% C 94.37%

python-pesq's Introduction

python-pesq

PESQ (Perceptual Evaluation of Speech Quality) Wrapper for Python Users

This code is designed for numpy array specially.

Requirements

C compiler
numpy
cython

Build and Install

$ git clone https://github.com/ludlows/python-pesq.git
$ cd python-pesq
$ pip install .  # for python 2
$ pip3 install . # for python 3 
$ cd ..
$ rm -rf python-pesq # remove the code folder since it exists in the python package folder

Install with pip

# PyPi Repository
$ pip install pesq


# The Latest Version
$ pip install https://github.com/ludlows/python-pesq/archive/master.zip

# or

$ pip3 install https://github.com/ludlows/python-pesq/archive/master.zip

Usage for narrow-band and wide-band Modes

Please note that the sampling rate (frequency) should be 16000 or 8000 (Hz).

And using 8000Hz is supported for narrow band only.

The code supports error-handling behaviors now.

def pesq(fs, ref, deg, mode, on_error=PesqError.RAISE_EXCEPTION):
    """
    Args:
        ref: numpy 1D array, reference audio signal 
        deg: numpy 1D array, degraded audio signal
        fs:  integer, sampling rate
        mode: 'wb' (wide-band) or 'nb' (narrow-band)
        on_error: error-handling behavior, it could be PesqError.RETURN_VALUES or PesqError.RAISE_EXCEPTION by default
    Returns:
        pesq_score: float, P.862.2 Prediction (MOS-LQO)
    """

Once you select PesqError.RETURN_VALUES, the pesq function will return -1 when an error occurs.

Once you select PesqError.RAISE_EXCEPTION, the pesq function will raise an exception when an error occurs.

It supports the following errors now: InvalidSampleRateError, OutOfMemoryError,BufferTooShortError,NoUtterancesError,PesqError(other unknown errors).

from scipy.io import wavfile
from pesq import pesq

rate, ref = wavfile.read("./audio/speech.wav")
rate, deg = wavfile.read("./audio/speech_bab_0dB.wav")

print(pesq(rate, ref, deg, 'wb'))
print(pesq(rate, ref, deg, 'nb'))

Correctness

The correctness is verified by running samples in audio folder.

PESQ computed by this code in wide band mode is 1.0832337141036987

PESQ computed by this code in narrow band mode is 1.6072081327438354

Note

Sampling rate (fs|rate) - No default. Must select either 8000Hz or 16000Hz.

Note there is narrow band (nb) mode only when sampling rate is 8000Hz.

The original C soure code is modified.

Who is using python-pesq

Please click here to see these repositories, whose owners include Facebook Research, SpeechBrain, NVIDIA .etc.

Buy me a Coffee

Buy me a Coffee if my work helps you in some ways.

python-pesq's People

Contributors

boeddeker avatar ludlows avatar rafagd avatar scarecrow1123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.