Skip to content

Commit

Permalink
Add test for pytorch#1021
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed Nov 13, 2020
1 parent 8d0c08d commit 9982596
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/torchaudio_unittest/sox_effect/dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(TempDirMixin, 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()

0 comments on commit 9982596

Please sign in to comment.