diff --git a/test/torchaudio_unittest/sox_effect/dataset_test.py b/test/torchaudio_unittest/sox_effect/dataset_test.py index 647e4d2a81e..67dd0b87045 100644 --- a/test/torchaudio_unittest/sox_effect/dataset_test.py +++ b/test/torchaudio_unittest/sox_effect/dataset_test.py @@ -2,6 +2,7 @@ import platform from unittest import skipIf from typing import List, Tuple +from concurrent.futures import ProcessPoolExecutor import numpy as np import torch @@ -122,3 +123,23 @@ def test_apply_effects_tensor(self): ) for batch in loader: assert batch.shape == (32, 2, 2 * sample_rate) + + +@skipIfNoExtension +class TestProcessPoolExecutor(PytorchTestCase): + @staticmethod + def _speed(): + sample_rate = 16000 + wav = get_whitenoise(n_channels=1, sample_rate=sample_rate, duration=1, dtype='float') + effects = [ + ['speed', '1.03756523535464655'], + ['rate', f'{sample_rate}'], + ] + return torchaudio.sox_effects.apply_effects_tensor(wav, sample_rate, effects)[0] + + def test_executor(self): + """Test that apply_effects_tensor with speed + rate does not crush + + https://github.com/pytorch/audio/issues/1021 + """ + ProcessPoolExecutor(1).submit(TestProcessPoolExecutor._speed).result()