How to use the audiomentations.augmentations.transforms.TimeStretch function in audiomentations

To help you get started, we’ve selected a few audiomentations examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iver56 / audiomentations / tests / test_time_stretch.py View on Github external
def test_fixed_length(self):
        samples = np.zeros((20,), dtype=np.float32)
        sample_rate = 16000
        augmenter = Compose(
            [
                TimeStretch(
                    min_rate=0.8, max_rate=0.9, leave_length_unchanged=True, p=1.0
                )
            ]
        )
        samples = augmenter(samples=samples, sample_rate=sample_rate)

        self.assertEqual(samples.dtype, np.float32)
        self.assertEqual(len(samples), 20)
github iver56 / audiomentations / tests / test_time_stretch.py View on Github external
def test_dynamic_length(self):
        samples = np.zeros((20,), dtype=np.float32)
        sample_rate = 16000
        augmenter = Compose(
            [
                TimeStretch(
                    min_rate=0.8, max_rate=0.9, leave_length_unchanged=False, p=1.0
                )
            ]
        )
        samples = augmenter(samples=samples, sample_rate=sample_rate)

        self.assertEqual(samples.dtype, np.float32)
        self.assertGreater(len(samples), 20)