Skip to content

Commit

Permalink
update readme and default value of n_processor
Browse files Browse the repository at this point in the history
  • Loading branch information
ludlows committed May 9, 2022
1 parent f76d43f commit e0414ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ print(pesq(rate, ref, deg, 'nb'))
```python
def pesq_batch(fs, ref, deg, mode='wb', n_processor=None, on_error=PesqError.RAISE_EXCEPTION):
"""
Running `pesq` using multiple processors
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: None (without multiprocessing) or number of processors
on_error:
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)
"""
Expand Down
6 changes: 3 additions & 3 deletions pesq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def pesq_batch(fs, ref, deg, mode, n_processor=cpu_count(), on_error=PesqError.R
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 -1 (without multiprocessing)
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)
Expand All @@ -130,7 +130,7 @@ def pesq_batch(fs, ref, deg, mode, n_processor=cpu_count(), on_error=PesqError.R
if len(deg.shape) == 1 and ref.shape == deg.shape:
return [_pesq_inner(ref, deg, fs, mode, PesqError.RETURN_VALUES)]
elif len(deg.shape) == 2 and ref.shape[-1] == deg.shape[-1]:
if n_processor < 0:
if n_processor <= 0:
pesq_score = [np.nan for i in range(deg.shape[0])]
for i in range(deg.shape[0]):
pesq_score[i] = _pesq_inner(ref, deg[i, :], fs, mode, on_error)
Expand All @@ -143,7 +143,7 @@ def pesq_batch(fs, ref, deg, mode, n_processor=cpu_count(), on_error=PesqError.R
raise ValueError("The shapes of `deg` is invalid!")
elif len(ref.shape) == 2:
if deg.shape == ref.shape:
if n_processor < 0:
if n_processor <= 0:
pesq_score = [np.nan for i in range(deg.shape[0])]
for i in range(deg.shape[0]):
pesq_score[i] = _pesq_inner(ref[i, :], deg[i, :], fs, mode, on_error)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_pesq.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def test_pesq_batch():


# if __name__ == "__main__":
# test()
# test_no_utterances_nb_mode()
# test_no_utterances_wb_mode()
# test_pesq_batch()
# test()
# test_no_utterances_nb_mode()
# test_no_utterances_wb_mode()
# test_pesq_batch()

0 comments on commit e0414ec

Please sign in to comment.