How to use the audiomentations.augmentations.transforms.Normalize 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_normalize.py View on Github external
def test_normalize_negative_peak(self):
        samples = np.array([0.5, 0.6, -0.8, 0.0], dtype=np.float32)
        sample_rate = 16000
        augmenter = Compose([Normalize(p=1.0)])
        samples = augmenter(samples=samples, sample_rate=sample_rate)

        self.assertEqual(np.amin(samples), -1.0)
        self.assertEqual(samples[-1], 0.0)
        self.assertEqual(samples.dtype, np.float32)
        self.assertEqual(len(samples), 4)
github iver56 / audiomentations / tests / test_normalize.py View on Github external
def test_normalize_positive_peak(self):
        samples = np.array([0.5, 0.6, -0.2, 0.0], dtype=np.float32)
        sample_rate = 16000
        augmenter = Compose([Normalize(p=1.0)])
        samples = augmenter(samples=samples, sample_rate=sample_rate)

        self.assertEqual(np.amax(samples), 1.0)
        self.assertEqual(samples.dtype, np.float32)
        self.assertEqual(len(samples), 4)