pesq


Namepesq JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/ludlows/python-pesq
SummaryPython Wrapper for PESQ Score (narrow band and wide band)
upload_time2022-05-17 14:15:26
maintainer
docs_urlNone
authorludlows
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # pesq
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6549559.svg)](https://doi.org/10.5281/zenodo.6549559)
[![Downloads](https://pepy.tech/badge/pesq)](https://pepy.tech/project/pesq)
[![Downloads](https://pepy.tech/badge/pesq/month)](https://pepy.tech/project/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
```bash
$ 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

```bash
# 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 narrowband and wideband Modes

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

And using 8000Hz is supported for narrowband only.

The code supports error-handling behaviors now.

```python
def pesq(fs, ref, deg, mode='wb', 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).

```python
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'))
```

# Usage for `multiprocessing` feature

```python
def pesq_batch(fs, ref, deg, mode='wb', n_processor=None, on_error=PesqError.RAISE_EXCEPTION):
    """
   Running `pesq` using multiple processors
    Args:
        on_error:
        ref: numpy 1D (n_sample,) or 2D array (n_file, n_sample), reference audio signal
        deg: numpy 1D (n_sample,) or 2D array (n_file, n_sample), degraded audio signal
        fs:  integer, sampling rate
        mode: 'wb' (wide-band) or 'nb' (narrow-band)
        n_processor: cpu_count() (default) or number of processors (chosen by the user) or 0 (without multiprocessing)
        on_error: PesqError.RAISE_EXCEPTION (default) or PesqError.RETURN_VALUES
    Returns:
        pesq_score: list of pesq scores, P.862.2 Prediction (MOS-LQO)
    """
```
this function uses `multiprocessing` features to boost time efficiency.

When the `ref` is an 1-D numpy array and `deg` is a 2-D numpy array, the result of `pesq_batch` is identical to the value of `[pesq(fs, ref, deg[i,:],**kwargs) for i in range(deg.shape[0])]`.

When the `ref` is a 2-D numpy array and `deg` is a 2-D numpy array, the result of `pesq_batch` is identical to the value of `[pesq(fs, ref[i,:], deg[i,:],**kwargs) for i in range(deg.shape[0])]`.


# Correctness

The correctness is verified by running samples in audio folder.

PESQ computed by this code in wideband mode is    1.0832337141036987

PESQ computed by this code in narrowband mode is  1.6072081327438354

# Note

Sampling rate (fs|rate) - No default. Must select either 8000Hz or 16000Hz.
 
Note there is narrowband (nb) mode only when sampling rate is 8000Hz.

The original C source code is modified. 

# Who is using `pesq`

Please click [here](https://github.com/ludlows/python-pesq/network/dependents) to see these repositories, whose owners include `Facebook Research`, `SpeechBrain`, `NVIDIA` .etc.

# Cite this code

```
   @software{miao_wang_2022_6549559,
   author       = {Miao Wang and
                  Christoph Boeddeker and
                  Rafael G. Dantas and
                  ananda seelan},
   title        = {{ludlows/python-pesq: supporting for 
                   multiprocessing features}},
   month        = may,
   year         = 2022,
   publisher    = {Zenodo},
   version      = {v0.0.4},
   doi          = {10.5281/zenodo.6549559},
   url          = {https://doi.org/10.5281/zenodo.6549559}}
```

# Acknowledgement

This work was funded by the Natural Sciences and Engineering Research Council of Canada.

This work was also funded by the Concordia University, Montreal, Canada.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ludlows/python-pesq",
    "name": "pesq",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "ludlows",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/22/e6/f8bdcef3238ac10fb3ce37d150e9b03a152d971febd681f088c6e5e17d8e/pesq-0.0.4.tar.gz",
    "platform": null,
    "description": "# pesq\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6549559.svg)](https://doi.org/10.5281/zenodo.6549559)\n[![Downloads](https://pepy.tech/badge/pesq)](https://pepy.tech/project/pesq)\n[![Downloads](https://pepy.tech/badge/pesq/month)](https://pepy.tech/project/pesq)\n\nPESQ (Perceptual Evaluation of Speech Quality) Wrapper for Python Users\n\nThis code is designed for numpy array specially.\n\n# Requirements\n\n    C compiler\n    numpy\n    cython\n\n# Build and Install\n```bash\n$ git clone https://github.com/ludlows/python-pesq.git\n$ cd python-pesq\n$ pip install .  # for python 2\n$ pip3 install . # for python 3 \n$ cd ..\n$ rm -rf python-pesq # remove the code folder since it exists in the python package folder\n```\n\n# Install with pip\n\n```bash\n# PyPi Repository\n$ pip install pesq\n\n\n# The Latest Version\n$ pip install https://github.com/ludlows/python-pesq/archive/master.zip\n\n# or\n\n$ pip3 install https://github.com/ludlows/python-pesq/archive/master.zip\n```\n\n# Usage for narrowband and wideband Modes\n\nPlease note that the sampling rate (frequency) should be 16000 or 8000 (Hz). \n\nAnd using 8000Hz is supported for narrowband only.\n\nThe code supports error-handling behaviors now.\n\n```python\ndef pesq(fs, ref, deg, mode='wb', on_error=PesqError.RAISE_EXCEPTION):\n    \"\"\"\n    Args:\n        ref: numpy 1D array, reference audio signal \n        deg: numpy 1D array, degraded audio signal\n        fs:  integer, sampling rate\n        mode: 'wb' (wide-band) or 'nb' (narrow-band)\n        on_error: error-handling behavior, it could be PesqError.RETURN_VALUES or PesqError.RAISE_EXCEPTION by default\n    Returns:\n        pesq_score: float, P.862.2 Prediction (MOS-LQO)\n    \"\"\"\n```\nOnce you select `PesqError.RETURN_VALUES`, the `pesq` function will return -1 when an error occurs.\n\nOnce you select `PesqError.RAISE_EXCEPTION`, the `pesq` function will raise an exception when an error occurs.\n\nIt supports the following errors now: `InvalidSampleRateError`, `OutOfMemoryError`,`BufferTooShortError`,`NoUtterancesError`,`PesqError`(other unknown errors).\n\n```python\nfrom scipy.io import wavfile\nfrom pesq import pesq\n\nrate, ref = wavfile.read(\"./audio/speech.wav\")\nrate, deg = wavfile.read(\"./audio/speech_bab_0dB.wav\")\n\nprint(pesq(rate, ref, deg, 'wb'))\nprint(pesq(rate, ref, deg, 'nb'))\n```\n\n# Usage for `multiprocessing` feature\n\n```python\ndef pesq_batch(fs, ref, deg, mode='wb', n_processor=None, on_error=PesqError.RAISE_EXCEPTION):\n    \"\"\"\n   Running `pesq` using multiple processors\n    Args:\n        on_error:\n        ref: numpy 1D (n_sample,) or 2D array (n_file, n_sample), reference audio signal\n        deg: numpy 1D (n_sample,) or 2D array (n_file, n_sample), degraded audio signal\n        fs:  integer, sampling rate\n        mode: 'wb' (wide-band) or 'nb' (narrow-band)\n        n_processor: cpu_count() (default) or number of processors (chosen by the user) or 0 (without multiprocessing)\n        on_error: PesqError.RAISE_EXCEPTION (default) or PesqError.RETURN_VALUES\n    Returns:\n        pesq_score: list of pesq scores, P.862.2 Prediction (MOS-LQO)\n    \"\"\"\n```\nthis function uses `multiprocessing` features to boost time efficiency.\n\nWhen the `ref` is an 1-D numpy array and `deg` is a 2-D numpy array, the result of `pesq_batch` is identical to the value of `[pesq(fs, ref, deg[i,:],**kwargs) for i in range(deg.shape[0])]`.\n\nWhen the `ref` is a 2-D numpy array and `deg` is a 2-D numpy array, the result of `pesq_batch` is identical to the value of `[pesq(fs, ref[i,:], deg[i,:],**kwargs) for i in range(deg.shape[0])]`.\n\n\n# Correctness\n\nThe correctness is verified by running samples in audio folder.\n\nPESQ computed by this code in wideband mode is    1.0832337141036987\n\nPESQ computed by this code in narrowband mode is  1.6072081327438354\n\n# Note\n\nSampling rate (fs|rate) - No default. Must select either 8000Hz or 16000Hz.\n \nNote there is narrowband (nb) mode only when sampling rate is 8000Hz.\n\nThe original C source code is modified. \n\n# Who is using `pesq`\n\nPlease click [here](https://github.com/ludlows/python-pesq/network/dependents) to see these repositories, whose owners include `Facebook Research`, `SpeechBrain`, `NVIDIA` .etc.\n\n# Cite this code\n\n```\n   @software{miao_wang_2022_6549559,\n   author       = {Miao Wang and\n                  Christoph Boeddeker and\n                  Rafael G. Dantas and\n                  ananda seelan},\n   title        = {{ludlows/python-pesq: supporting for \n                   multiprocessing features}},\n   month        = may,\n   year         = 2022,\n   publisher    = {Zenodo},\n   version      = {v0.0.4},\n   doi          = {10.5281/zenodo.6549559},\n   url          = {https://doi.org/10.5281/zenodo.6549559}}\n```\n\n# Acknowledgement\n\nThis work was funded by the Natural Sciences and Engineering Research Council of Canada.\n\nThis work was also funded by the Concordia University, Montreal, Canada.",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python Wrapper for PESQ Score (narrow band and wide band)",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/ludlows/python-pesq"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22e6f8bdcef3238ac10fb3ce37d150e9b03a152d971febd681f088c6e5e17d8e",
                "md5": "8423a956e73c727d98f5bfc27e99c10c",
                "sha256": "b724b28f73fb638522982bd68e8c3c0957e2f45210639a460233b17aa7fc890b"
            },
            "downloads": -1,
            "filename": "pesq-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "8423a956e73c727d98f5bfc27e99c10c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 38702,
            "upload_time": "2022-05-17T14:15:26",
            "upload_time_iso_8601": "2022-05-17T14:15:26.301390Z",
            "url": "https://files.pythonhosted.org/packages/22/e6/f8bdcef3238ac10fb3ce37d150e9b03a152d971febd681f088c6e5e17d8e/pesq-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-05-17 14:15:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ludlows",
    "github_project": "python-pesq",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pesq"
}
        
Elapsed time: 0.27490s