Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
wangmiao authored and wangmiao committed May 11, 2021
1 parent 6e38968 commit 77e9c80
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,32 @@ $ pip install https://github.com/ludlows/python-pesq/archive/master.zip
$ pip3 install https://github.com/ludlows/python-pesq/archive/master.zip
```

# Example for narrow band and wide band
# Usage for narrow-band and wide-band Modes

when using it, please note that the sampling rate (frequency) should be 16000 or 8000.
Please note that the sampling rate (frequency) should be 16000 or 8000 (Hz).

And using 8000 is supported for narrow band only.
And using 8000Hz is supported for narrow band only.

The code supports error-handling behaviors now.

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

```python
from scipy.io import wavfile
Expand Down Expand Up @@ -71,29 +92,6 @@ The original C soure code is modified.
# Who is using `python-pesq`
Please click [here](https://github.com/ludlows/python-pesq/network/dependents) to see these repositories, whose owners include `Facebook Research`, `SpeechBrain`, `NVIDIA` .etc.

# Expressing your opinions on the error-handling behaviors
The code on `dev` branch supports error-handling behaviors now.

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

Thanks to the contribution from [@Rafgd](https://github.com/Rafagd).

# Buy me a Coffee
[Buy](https://www.paypal.me/wangmiao521) me a Coffee if my work helps you in some ways.

0 comments on commit 77e9c80

Please sign in to comment.