Skip to content

Commit

Permalink
enable multiple processors
Browse files Browse the repository at this point in the history
performance test
  • Loading branch information
ludlows committed May 7, 2022
1 parent 5e86029 commit 956e99b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
5 changes: 3 additions & 2 deletions pesq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import numpy as np
from multiprocessing import Pool, Queue, Process
from functools import partial
from .cypesq import cypesq, cypesq_retvals
from .cypesq import PesqError
from .cypesq import cypesq, cypesq_retvals, cypesq_error_message as pesq_error_message
from .cypesq import PesqError, InvalidSampleRateError, OutOfMemoryError
from .cypesq import BufferTooShortError, NoUtterancesError

USAGE = """
Run model on reference(ref) and degraded(deg)
Expand Down
32 changes: 27 additions & 5 deletions tests/test_pesq.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,30 @@ def test_pesq_batch():
assert np.allclose(np.array(scores), ideally), scores


if __name__ == "__main__":
test()
test_no_utterances_nb_mode()
test_no_utterances_wb_mode()
test_pesq_batch()
# def test_time_efficiency():
# data_dir = Path(__file__).parent.parent / 'audio'
# ref_path = data_dir / 'speech.wav'
# deg_path = data_dir / 'speech_bab_0dB.wav'
#
# sample_rate, ref = scipy.io.wavfile.read(ref_path)
# sample_rate, deg = scipy.io.wavfile.read(deg_path)
# import time
# nums = [100, 1000, 10000]
# durations = []
# n_processors = 8
# degs = [np.repeat(deg[np.newaxis, :], n, axis=0) for n in nums]
# for d, n in zip(degs, nums):
# start = time.time()
# pesq_batch(ref=ref, deg=d, fs=sample_rate, mode='wb', n_processor=n_processors)
# end = time.time()
# durations.append(end - start)
# print(durations)
# # [5.192636251449585, 30.032038688659668, 294.47159910202026]


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

0 comments on commit 956e99b

Please sign in to comment.