Ejemplo n.º 1
0
    def test_random_method(self):
        aug = naa.NormalizeAug(method='random', stateless=False)
        augmented_audio = aug.augment(self.audio)

        self.assertTrue(aug.run_method in aug.model.get_support_methods())

        self.assertFalse(np.array_equal(self.audio, augmented_audio))
        self.assertEqual(len(self.audio), len(augmented_audio))
Ejemplo n.º 2
0
    def test_coverage_and_zone(self):
        params = [
            ((0.3, 0.7), 1),
            ((0, 1), 1)
        ]

        for zone, coverage in params:
            augs = [
                naa.LoudnessAug(zone=zone, coverage=coverage, stateless=False),
                naa.MaskAug(zone=zone, coverage=coverage, stateless=False),
                naa.NoiseAug(zone=zone, coverage=coverage, stateless=False),
                naa.PitchAug(zone=zone, coverage=coverage, stateless=False, sampling_rate=self.sampling_rate),
                naa.SpeedAug(zone=zone, coverage=coverage, stateless=False),
                naa.VtlpAug(zone=zone, coverage=coverage, stateless=False, sampling_rate=self.sampling_rate),
                naa.NormalizeAug(zone=zone, coverage=coverage, stateless=False),
                naa.PolarityInverseAug(zone=zone, coverage=coverage, stateless=False)
            ]

            for aug in augs:
                aug_data = aug.augment(self.audio)
                self.assertTrue(len(aug_data[aug.start_pos:aug.end_pos]), int(len(self.audio) * (zone[1] - zone[0]) * coverage))
def normalize(data):
    aug = naa.NormalizeAug(method='minmax')
    return aug.augment(data)
Ejemplo n.º 4
0
    def test_standard(self):
        aug = naa.NormalizeAug(method='standard')
        augmented_audio = aug.augment(self.audio)

        self.assertFalse(np.array_equal(self.audio, augmented_audio))
        self.assertEqual(len(self.audio), len(augmented_audio))
Ejemplo n.º 5
0
 def test_non_exist_method(self):
     with self.assertRaises(ValueError) as error:
         aug = naa.NormalizeAug(method='test1234')
     self.assertTrue(
         'does not support yet. You may pick one' in str(error.exception))
Ejemplo n.º 6
0
    def test_empty_input(self):
        audio = np.array([])
        aug = naa.NormalizeAug()
        augmented_audio = aug.augment(audio)

        self.assertTrue(np.array_equal(audio, augmented_audio))