How to use the nlpaug.util.AudioLoader.load_audio function in nlpaug

To help you get started, we’ve selected a few nlpaug 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 makcedward / nlpaug / test / augmenter / audio / test_noise.py View on Github external
def setUpClass(cls):
        env_config_path = os.path.abspath(os.path.join(
            os.path.dirname(__file__), '..', '..', '..', '.env'))
        load_dotenv(env_config_path)
        # https://freewavesamples.com/yamaha-v50-rock-beat-120-bpm
        cls.sample_wav_file = os.path.join(
            os.environ.get("TEST_DIR"), 'res', 'audio', 'Yamaha-V50-Rock-Beat-120bpm.wav'
        )
        # https://en.wikipedia.org/wiki/Colors_of_noise
        cls.noise_wav_file = os.path.join(
            os.environ.get("TEST_DIR"), 'res', 'audio', 'Pink_noise.ogg'
        )
        cls.audio, cls.sampling_rate = AudioLoader.load_audio(cls.sample_wav_file)
        cls.noise, cls.noise_sampling_rate = AudioLoader.load_audio(cls.noise_wav_file)
github makcedward / nlpaug / test / augmenter / audio / test_audio.py View on Github external
def test_multi_thread(self):
        audio, sampling_rate = AudioLoader.load_audio(self.sample_wav_file)
        n = 3
        augs = [
            naa.CropAug(sampling_rate=sampling_rate),
            naa.PitchAug(sampling_rate=sampling_rate)
        ]

        for num_thread in [1, 3]:
            for aug in augs:
                augmented_data = aug.augment(audio, n=n, num_thread=num_thread)
                self.assertEqual(len(augmented_data), n)
github makcedward / nlpaug / test / augmenter / audio / test_vtlp.py View on Github external
def setUpClass(cls):
        env_config_path = os.path.abspath(os.path.join(
            os.path.dirname(__file__), '..', '..', '..', '.env'))
        load_dotenv(env_config_path)
        # https://freewavesamples.com/yamaha-v50-rock-beat-120-bpm
        cls.sample_wav_file = os.path.join(
            os.environ.get("TEST_DIR"), 'res', 'audio', 'Yamaha-V50-Rock-Beat-120bpm.wav'
        )
        cls.audio, cls.sampling_rate = AudioLoader.load_audio(cls.sample_wav_file)