AudioAugmentor


NameAudioAugmentor JSON
Version 0.0.5 PyPI version JSON
download
home_page
SummaryPython package for simple application of wide range of audio augmentations.
upload_time2024-03-11 17:27:22
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) [2024] [Ladislav Vašina] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords audio augmentation pytorch machine learning deep learning data augmentation audio processing audio augmentation audio data augmentation audio data processing torchaudio ffmpeg ffmpeg-python audiomentations torch-audiomentations rir room impulse response room simulation pyroomacoustics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AudioAugmentor
### Python library for augmenting audio data
[![EXAMPLE 1](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1IMVLl6LCUU5gaYAz0IMSAcHh7Iq7NZr7?usp=sharing)


This library is designed to augment audio data for machine learning purposes. 
It combines several tools and libraries for audio data augmentation and provides a unified interface that can be used to apply a large set of audio augmentations in one place.

The library is designed to be used with the [PyTorch](https://pytorch.org) machine learning framework.
It can also work solely on just simple audio waveforms and augment those.

This library specifically combines these libraries and tools:

- [torchaudio](https://pytorch.org/audio/stable/index.html)
- [audiomentations](https://github.com/iver56/audiomentations)
- [torch-audiomentations](https://github.com/asteroid-team/torch-audiomentations)
- [pyroomacoustics](https://pyroomacoustics.readthedocs.io/en/pypi-release/index.html)
- [ffmpeg-python](https://github.com/kkroening/ffmpeg-python)


### Available augmentations
Table below shows which library was used to apply specific audio augmentation/codec.

|                                                                      | [audiomentations](https://iver56.github.io/audiomentations/) | [torch-audiomentations](https://github.com/asteroid-team/torch-audiomentations) | [torchaudio](https://pytorch.org/audio/stable/index.html) | [pyroomacoustics](https://pyroomacoustics.readthedocs.io/en/pypi-release/index.html) | [ffmpeg-python](https://github.com/kkroening/ffmpeg-python) |
|----------------------------------------------------------------------|:---------------:|:---------------------:|:----------:|:---------------:|:------:|
| [AddBackgroundNoise](#addbackgroundnoise)                            |                 |           ✅          |            |                 |        |
| [AddColoredNoise](#addcolorednoise) |                 |           ✅          |            |                 |        |
| [AddGaussianNoise](#addgaussiannoise)                                |        ✅       |                       |            |                 |        |
| [AddShortNoises](#addshortnoises)                                    |        ✅       |                       |            |                 |        |
| [AdjustDuration](#adjustduration)                                    |        ✅       |                       |            |                 |        |
| [AirAbsorption](#airabsorption)                                      |        ✅       |                       |            |                 |        |
| [ApplyImpulseResponse](#applyimpulseresponse)                        |                 |           ✅          |            |                 |        |
| [BandPassFilter](#bandpassfilter)                                    |                 |           ✅          |            |                 |        |
| [BandStopFilter](#bandstopfilter)                                    |                 |           ✅          |            |                 |        |
| [ClippingDistortion](#clippingdistortion)                            |        ✅       |                       |            |                 |        |
| [FrequencyMasking](#frequencymasking)                                |                 |                       |     ✅     |                 |        |
| [Volume / Gain](#volume--gain)                                       |                 |                       |     ✅     |                 |        |
| [GainTransition](#gaintransition)                                    |        ✅       |                       |            |                 |        |
| [HighPassFilter](#highpassfilter)                                    |                 |           ✅          |            |                 |        |
| [HighShelfFilter](#highshelffilter)                                  |        ✅       |                       |            |                 |        |
| [Limiter](#limiter)                                                  |        ✅       |                       |            |                 |        |
| [LoudnessNormalization](#loudnessnormalization)                      |        ✅       |                       |            |                 |        |
| [LowPassFilter](#lowpassfilter)                                      |                 |           ✅          |            |                 |        |
| [LowShelfFilter](#lowshelffilter)                                    |        ✅       |                       |            |                 |        |
| [Mp3Compression](#mp3compression)                                    |        ✅       |                       |            |                 |        |
| [MelSpectrogram](#melspectrogram)                                    |                 |                       |     ✅     |                 |        |
| [Normalize](#normalize)                                              |        ✅       |                       |            |                 |        |
| [Padding](#padding)                                                  |        ✅       |                       |            |                 |        |
| [PeakNormalization](#peaknormalization)                              |                 |           ✅          |            |                 |        |
| [PeakingFilter](#peakingfilter)                                      |        ✅       |                       |            |                 |        |
| [PitchShift](#pitchshift)                                            |                 |                       |     ✅     |                 |        |
| [PolarityInversion](#polarityinversion)                              |                 |           ✅          |            |                 |        |
| [Time inversion](#time-inversion)                                    |                 |           ✅          |            |                 |        |
| [ApplyRIR (RoomSimulator)](#applyrir)                                |                 |                       |            |        ✅       |        |
| [SevenBandParametricEQ](#sevenbandparametriceq)                      |       ✅        |                       |            |                 |        |
| [Shift](#shift)                                                      |                 |           ✅          |            |                 |        |
| [Speed](#speed)                                                      |                 |                       |     ✅     |                 |        |
| [Spectrogram](#spectrogram)                                          |                 |                       |     ✅     |                 |        |
| [TanhDistortion](#tanhdistortion)                                    |       ✅        |                       |            |                 |        |
| [TimeMasking](#timemasking)                                             |                 |                       |     ✅     |                 |        |
| [TimeStretch](#timestretch)                                          |       ✅        |                       |            |                 |        |
| [ac3](#codecs-using-torchaudio)                                      |                 |                       |     ✅     |                 |        |
| [adpcm_ima_wav](#codecs-using-torchaudio)                            |                 |                       |     ✅     |                 |        |
| [adpcm_ms](#codecs-using-torchaudio)                                 |                 |                       |     ✅     |                 |        |
| [adpcm_yamaha](#codecs-using-torchaudio)                             |                 |                       |     ✅     |                 |        |
| [eac3](#codecs-using-torchaudio)                                     |                 |                       |     ✅     |                 |        |
| [flac](#codecs-using-torchaudio)                                     |                 |                       |     ✅     |                 |        |
| [libmp3lame](#codecs-using-torchaudio)                               |                 |                       |     ✅     |                 |        |
| [mp2](#codecs-using-torchaudio)                                      |                 |                       |     ✅     |                 |        |
| [pcm_alaw](#codecs-using-torchaudio)                                 |                 |                       |     ✅     |                 |        |
| [pcm_f32le](#codecs-using-torchaudio)                                |                 |                       |     ✅     |                 |        |
| [pcm_mulaw](#codecs-using-torchaudio)                                |                 |                       |     ✅     |                 |        |
| [pcm_s16le](#codecs-using-torchaudio)                                |                 |                       |     ✅     |                 |        |
| [pcm_s24le](#codecs-using-torchaudio)                                |                 |                       |     ✅     |                 |        |
| [pcm_s32le](#codecs-using-torchaudio)                                |                 |                       |     ✅     |                 |        |
| [pcm_u8](#codecs-using-torchaudio)                                   |                 |                       |     ✅     |                 |        |
| [wmav1](#codecs-using-torchaudio)                                    |                 |                       |     ✅     |                 |        |
| [wmav2](#codecs-using-torchaudio)                                    |                 |                       |     ✅     |                 |        |
| [g726](#g726)                                                        |                 |                       |            |                 |   ✅   |
| [gsm](#gsm)                                                          |                 |                       |            |                 |   ✅   |
| [amr](#amr)                                                          |                 |                       |            |                 |   ✅   |


## Usage
For a more complex example see [example colab notebook above](#python-library-for-augmenting-audio-data).

`Note: AudioAugmentor was mainly tested using Python 3.11.8 and Fedora 38 (Google Colab uses Python 3.10 and Ubuntu)`


**0. You need to install the library and necessary packages first**
```bash
pip install -U pip
pip install AudioAugmentor
dnf install -y sox                # FEDORA
dnf install -y sox-devel          # FEDORA
dnf install -y ffmpeg             # FEDORA
# apt-get install -y sox          # UBUNTU
# apt-get install -y libsox-dev   # UBUNTU
# apt-get install -y ffmpeg       # UBUNTU
```

**1. Import necessary libraries**
```python
import torch
import torchaudio
import numpy as np
import audiomentations as AA
from IPython.display import Audio, display

from AudioAugmentor import transf_gen
from AudioAugmentor import sox_parser
from AudioAugmentor import core
from AudioAugmentor import rir_setup
from AudioAugmentor import torchaudio_transf_wrapper as TTW
```
**2. Define the augmentations you want to apply to your audio data.**

You have **3** options of how to define the augmentations:

**a)** Use `transf_gen.transf_gen` function to generate list of transformations.

See [supported transformation table](#available-augmentations) and examples of every augmentation, so you know what parameters are needed for each augmentation method.

You can enter augmentation parameters as a string or as a dictionary.

`PitchShift='sample_rate=16000, n_steps=[1, 1.5, 0.1], p=1.0'`

`PitchShift={'sample_rate': 16000, 'n_steps': [1, 1.5, 0.1], 'p': 1.0}`
```php
transformations = transf_gen.transf_gen(verbose=True,
                                        PitchShift='sample_rate=16000, n_steps=[1, 1.5, 0.1], p=1.0',
                                        Speed={'orig_freq': 16000, 'factor': [0.9, 1.5, 0.1], 'p': 1},
                                        LowPassFilter={'min_cutoff_freq': 700, 'max_cutoff_freq': 800, 'sample_rate': sampling_rate, 'p': 1},
)
```
**b)** Use pseudo SoX command.
SoX command **must** be in this format:

`--sox="norm gain 0 highpass 1000 phaser 0.5 0.6 1 0.45 0.6 -s"`

(When you don't want to apply some codec after applying SoX effects)

OR

`--sox="norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s" amr audio_bitrate 4.75k`

(In this case, you want to apply codec after applying SoX effects -> Codec is entered in the form `codec_name` `codec_parameter_name` `codec_parameter_value` directly after the SoX effects command)
```python
example_sox = '--sox="norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s" amr audio_bitrate 4.75k'
```

**c)** Use a file with multiple pseudo SoX commands. Random SoX command from this file will be chosen and applied to your data.

File **must** to be loaded using `sox_parser.load_sox_file` function. 
```php
sox_file_content_to_write = '''--sox="norm gain 0 highpass 1000 phaser 0.5 0.6 1 0.45 0.6 -s"
#--sox="norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s"
--sox="norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s" gsm
--sox="norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s" amr audio_bitrate 4.75k
'''
with open('sox_file_example.txt', 'w') as f:
    f.write(sox_file_content_to_write)

sox_file_content = sox_parser.load_sox_file('sox_file_example.txt')
print('SOX FILE LOADED:', sox_file_content, type(sox_file_content))
```



**3. Apply augmentations**

**a)** Use generated the `transformations` list, `single SoX command` or `loaded SoX file content` while initializing `CollateFunction` class. 

Use this initiated class as an argument for the `collate_fn` parameter of PyTorch's dataloader.
```php
collate_fn = core.CollateFunction(
    transformations=transformations, device='cpu', sox_effects=None, sample_rate=sampling_rate, verbose=True,
    #transformations=None, device='cpu', sox_effects='--sox="norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s" amr audio_bitrate 4.75k', sample_rate=sampling_rate, verbose=False,
    #transformations=None, device='cpu', sox_effects=sox_file_content, sample_rate=sampling_rate, verbose=False,
)

dataset = torchaudio.datasets.LIBRISPEECH("../data", url="train-clean-100", download=True)
aug_dataloader = torch.utils.data.DataLoader(
    dataset,
    batch_size=1,
    num_workers=0,
    collate_fn=collate_fn,
)
augmented_record_from_dataset = next(iter(aug_dataloader))
display(Audio(augmented_record_from_dataset[0].squeeze(0).squeeze(0).squeeze(0).cpu(), rate=sampling_rate))
```
`OR`

**b)** Use generated the `transformations` list, `single SoX command` or `loaded SoX file content` while initializing `AugmentWaveform` class and apply the augmentations to the audio signal.
```php
augment = core.AugmentWaveform(
    transformations=transformations, device='cpu', sox_effects=None, sample_rate=16000, verbose=False,
    #transformations=None, device='cpu', sox_effects='--sox="norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s" amr audio_bitrate 4.75k', sample_rate=16000, verbose=False,
    #transformations=None, device='cpu', sox_effects=sox_file_content, sample_rate=16000, verbose=False,
)
# Load test wav file
signal, fs = torchaudio.load('../data/test.wav')
# Apply transformations
waveform = augment(signal.numpy()[0])
display(Audio(waveform, rate=fs))
```


# EXAMPLES OF AVAILABLE AUGMENTATIONS
## !!!Put following examples as an argument for `transf_gen.transf_gen` function to generate a list of transformations!!!

Like this:
```php
transformations = transf_gen.transf_gen(verbose=True,
                                        AddBackgroundNoise=f'background_paths="../data/musan/noise/free-sound", min_snr_in_db=10, max_snr_in_db=20, p=1, sample_rate={sampling_rate}',
                                        AddColoredNoise=f'min_snr_in_db=9, max_snr_in_db=10, p=1, sample_rate={sampling_rate}',
                                        )
```
You can enter augmentation parameters as a string or as a dictionary.

`PitchShift='sample_rate=16000, n_steps=[1, 1.5, 0.1], p=1.0'`

`PitchShift={'sample_rate': 16000, 'n_steps': [1, 1.5, 0.1], 'p': 1.0}`

<a id="addbackgroundnoise"></a>
### [⬆️](#available-augmentations) AddBackgroundNoise [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/background_noise.py#L32-L51)
```python
AddBackgroundNoise=f'''background_paths="../data/musan/noise/free-sound",
                       min_snr_in_db=10, 
                       max_snr_in_db=20, 
                       p=1, 
                       sample_rate={sampling_rate}''',
```
<a id="addcolorednoise"></a>
### [⬆️](#available-augmentations) AddColoredNoise [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/colored_noise.py#L49-L74)
```python
AddColoredNoise=f'''min_snr_in_db=9,
                    max_snr_in_db=10, 
                    p=1, 
                    sample_rate={sampling_rate}''',
```
<a id="addgaussiannoise"></a>
### [⬆️](#available-augmentations) AddGaussianNoise [docs](https://iver56.github.io/audiomentations/waveform_transforms/add_gaussian_noise/)
```python
AddGaussianNoise={'min_amplitude': 0.001, 
                  'max_amplitude': 0.015, 
                  'p': 1},
```
<a id="addshortnoises"></a>
### [⬆️](#available-augmentations) AddShortNoises [docs](https://iver56.github.io/audiomentations/waveform_transforms/add_short_noises/)
```python
AddShortNoises={'sounds_path': "../data/musan/noise/free-sound",
                'min_snr_in_db': 3.0,
                'max_snr_in_db': 30.0,
                'noise_rms': "relative_to_whole_input",
                'min_time_between_sounds': 2.0,
                'max_time_between_sounds': 8.0,
                'noise_transform': AA.PolarityInversion(),
                'p': 1.0},
```
<a id="adjustduration"></a>
### [⬆️](#available-augmentations) AdjustDuration [docs](https://iver56.github.io/audiomentations/waveform_transforms/adjust_duration/)
```python
AdjustDuration={'duration_seconds': 3.5, 
                'padding_mode': 'silence', 
                'p': 1},
```
<a id="airabsorption"></a>
### [⬆️](#available-augmentations) AirAbsorption [docs](https://iver56.github.io/audiomentations/waveform_transforms/air_absorption/)
```python
AirAbsorption={'min_distance': 10.0, 
               'max_distance': 50.0, 
               'min_humidity': 80.0, 
               'max_humidity': 90.0, 
               'min_temperature': 10.0, 
               'max_temperature': 20.0, 
               'p': 1.0},
```
<a id="applyimpulseresponse"></a>
### [⬆️](#available-augmentations) ApplyImpulseResponse [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/impulse_response.py#L33-L55)
```python
ApplyImpulseResponse=f'''ir_paths="../data/Rir.wav", 
                         p=1, 
                         sample_rate={sampling_rate}''',
```
<a id="bandpassfilter"></a>
### [⬆️](#available-augmentations) BandPassFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/band_pass_filter.py#L25-L46)
```python
BandPassFilter=f'''min_center_frequency=200, 
                   max_center_frequency=4000, 
                   min_bandwidth_fraction=0.5, 
                   max_bandwidth_fraction=1.99, 
                   sample_rate={sampling_rate}, 
                   p=1''',
```
<a id="bandstopfilter"></a>
### [⬆️](#available-augmentations) BandStopFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/band_stop_filter.py#L16-L38)
```python
BandStopFilter=f'''min_center_frequency=200, 
                   max_center_frequency=4000, 
                   min_bandwidth_fraction=0.5, 
                   max_bandwidth_fraction=1.99, 
                   sample_rate={sampling_rate}, 
                   p=1''',
```
<a id="clippingdistortion"></a>
### [⬆️](#available-augmentations) ClippingDistortion [docs](https://iver56.github.io/audiomentations/waveform_transforms/clipping_distortion/)
```python
ClippingDistortion={'min_percentile_threshold': 10, 
                    'max_percentile_threshold': 30, 
                    'p': 1},
```
<a id="frequencymasking"></a>
### [⬆️](#available-augmentations) FrequencyMasking [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.FrequencyMasking.html)
```python
FrequencyMasking={'freq_mask_param': 80},
```
<a id="volume--gain"></a>
### [⬆️](#available-augmentations) Volume / Gain [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.Vol.html)
```python
Vol={'gain': [2.5, 3, 0.1], 
     'p': 1.0},
```
<a id="gaintransition"></a>
### [⬆️](#available-augmentations) GainTransition [docs](https://iver56.github.io/audiomentations/waveform_transforms/gain_transition/)
```python
GainTransition={'min_gain_db': 30, 
                'max_gain_db': 40, 
                'min_duration': 5, 
                'max_duration': 16, 
                'duration_unit': 'seconds', 
                'p': 1},
```
<a id="highpassfilter"></a>
### [⬆️](#available-augmentations) HighPassFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/high_pass_filter.py#L15-L31)
```python
HighPassFilter=f'''min_cutoff_freq=700,
                   max_cutoff_freq=800,
                   sample_rate={sampling_rate},
                   p=1''',
```
<a id="highshelffilter"></a>
### [⬆️](#available-augmentations) HighShelfFilter [docs](https://iver56.github.io/audiomentations/waveform_transforms/high_shelf_filter/)
```python
HighShelfFilter={'min_center_freq': 2000, 
                 'max_center_freq': 5000, 
                 'min_gain_db': 10.0, 
                 'max_gain_db': 16.0, 
                 'min_q': 0.5, 
                 'max_q': 1.0, 
                 'p': 1},
```
<a id="limiter"></a>
### [⬆️](#available-augmentations) Limiter [docs](https://iver56.github.io/audiomentations/waveform_transforms/limiter/)
```python
Limiter='''min_threshold_db=-24, 
           max_threshold_db=-2,
           min_attack=0.0005, 
           max_attack=0.025, 
           min_release=0.05, 
           max_release=0.7, 
           threshold_mode="relative_to_signal_peak", 
           p=1''',
```
<a id="loudnessnormalization"></a>
### [⬆️](#available-augmentations) LoudnessNormalization [docs](https://iver56.github.io/audiomentations/waveform_transforms/loudness_normalization/)
```python
LoudnessNormalization={'min_lufs': -31, 
                       'max_lufs': -13, 
                       'p': 1},
```
<a id="lowpassfilter"></a>
### [⬆️](#available-augmentations) LowPassFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/low_pass_filter.py#L27-L42)
```python
LowPassFilter={'min_cutoff_freq': 700, 
               'max_cutoff_freq': 800, 
               'sample_rate': sampling_rate, 
               'p': 1},
```
<a id="lowshelffilter"></a>
### [⬆️](#available-augmentations) LowShelfFilter [docs](https://iver56.github.io/audiomentations/waveform_transforms/low_shelf_filter/)
```python
LowShelfFilter={'min_center_freq': 20, 
                'max_center_freq': 600, 
                'min_gain_db': -16.0, 
                'max_gain_db': 16.0, 
                'min_q': 0.5, 
                'max_q': 1.0, 
                'p': 1},
```
<a id="mp3compression"></a>
### [⬆️](#available-augmentations) Mp3Compression [docs](https://iver56.github.io/audiomentations/waveform_transforms/mp3_compression/)
```python
Mp3Compression={'min_bitrate': 8, 
                'max_bitrate': 8, 
                'backend': 'pydub', 
                'p': 1},
```
<a id="melspectrogram"></a>
### [⬆️](#available-augmentations) MelSpectrogram [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.MelSpectrogram.html)
```python
MelSpectrogram={'sample_rate': 16000},
```
<a id="normalize"></a>
### [⬆️](#available-augmentations) Normalize [docs](https://iver56.github.io/audiomentations/waveform_transforms/normalize/)
```python
Normalize={'p': 1},
```
<a id="padding"></a>
### [⬆️](#available-augmentations) Padding [docs](https://iver56.github.io/audiomentations/waveform_transforms/padding/)
```python
Padding={'mode': 'silence', 
         'min_fraction': 0.02, 
         'max_fraction': 0.8, 
         'pad_section': 'start', 
         'p': 1},
```
<a id="peaknormalization"></a>
### [⬆️](#available-augmentations) PeakNormalization [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/peak_normalization.py#L34-L36)
```python
PeakNormalization={'p': 1, 
                   'sample_rate': sampling_rate},
```
<a id="peakingfilter"></a>
### [⬆️](#available-augmentations) PeakingFilter [docs](https://iver56.github.io/audiomentations/waveform_transforms/peaking_filter/)
```python
PeakingFilter={'min_center_freq': 51, 
               'max_center_freq': 7400, 
               'min_gain_db': -22, 
               'max_gain_db': 22, 
               'min_q': 0.5, 
               'max_q': 1.0, 
               'p': 1},
```
<a id="pitchshift"></a>
### [⬆️](#available-augmentations) PitchShift [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.PitchShift.html)
```python
PitchShift={'sample_rate': 16000, 
            'n_steps': [1, 1.5, 0.1],
            'bins_per_octave': 12, 
            'n_fft': 512, 
            'win_length':512, 
            'hop_length': 512//4, 
            'p': 1.0},
```
<a id="polarityinversion"></a>
### [⬆️](#available-augmentations) PolarityInversion [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/polarity_inversion.py#L30-L32)
```python
PolarityInversion={'p': 1, 
                   'sample_rate': sampling_rate},
```
<a id="time-inversion"></a>
### [⬆️](#available-augmentations) Time inversion [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/time_inversion.py#L28-L39)
```python
TimeInversion={'p': 1, 
               'sample_rate': sampling_rate},
```
<a id="applyrir"></a>
### [⬆️](#available-augmentations) ApplyRIR
```php
# Use this to see available materials you can use as walls_mat, floor_mat and ceiling_mat argument
# from AudioAugmentor import rir_setup
# rir_setup.get_all_materials_info()

rir_kwargs = {
    'audio_sample_rate': 16000,
    'x_range': (0, 100), 
    'y_range': (0, 100), 
    'num_vertices_range': (3, 6),
    'mic_height': 1.5,
    'source_height': 1.5,
    'walls_mat': 'curtains_cotton_0.5',
    'room_height': 2.0,
    'max_order': 3,
    'floor_mat': 'carpet_cotton',
    'ceiling_mat': 'hard_surface',
    'ray_tracing': True,
    'air_absorption': True,
}
transformations = transf_gen.transf_gen(verbose=True,
                                        ApplyRIR=rir_kwargs,
                                        )
```
<a id="sevenbandparametriceq"></a>
### [⬆️](#available-augmentations) SevenBandParametricEQ [docs](https://iver56.github.io/audiomentations/waveform_transforms/seven_band_parametric_eq/)
```python
SevenBandParametricEQ={'min_gain_db': -10, 
                       'max_gain_db': 10, 
                       'p': 1},
```
<a id="shift"></a>
### [⬆️](#available-augmentations) Shift [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/shift.py#L66-L93)
```python
Shift={'min_shift': 1, 
       'max_shift': 2, 
       'p': 1, 
       'sample_rate': sampling_rate},
```
<a id="speed"></a>
### [⬆️](#available-augmentations) Speed [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.Speed.html)
```python
Speed={'orig_freq': 16000, 
       'factor': [0.9, 1.5, 0.1], 
       'p': 1},
```
<a id="spectrogram"></a>
### [⬆️](#available-augmentations) Spectrogram [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.Spectrogram.html)
```python
Spectrogram={'sample_rate': 16000},
```
<a id="tanhdistortion"></a>
### [⬆️](#available-augmentations) TanhDistortion [docs](https://iver56.github.io/audiomentations/waveform_transforms/tanh_distortion/)
```python
TanhDistortion={'min_distortion': 0.1, 
                'max_distortion': 0.8, 
                'p': 1},
```
<a id="timemasking"></a>
### [⬆️](#available-augmentations) TimeMasking [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.TimeMasking.html)
```python
TimeMasking={'time_mask_param': 80},
```
<a id="timestretch"></a>
### [⬆️](#available-augmentations) TimeStretch [docs](https://iver56.github.io/audiomentations/waveform_transforms/time_stretch/)
```python
TimeStretch='''min_rate=0.9, 
               max_rate=1.1, 
               p=0.2, 
               leave_length_unchanged=False''',
```
<a id="codecs-using-torchaudio"></a>
### [⬆️](#available-augmentations) Codecs using torchaudio
You can select just one. No need to use them all. :)
```php
transformations = transf_gen.transf_gen(verbose=True,
                                        ac3=True,
                                        adpcm_ima_wav=True,
                                        adpcm_ms=True,
                                        adpcm_yamaha=True,
                                        eac3=True,
                                        flac=True,
                                        libmp3lame=True,
                                        mp2=True,
                                        pcm_alaw=True,
                                        pcm_f32le=True,
                                        pcm_mulaw=True,
                                        pcm_s16le=True,
                                        pcm_s24le=True,
                                        pcm_s32le=True,
                                        pcm_u8=True,
                                        wmav1=True,
                                        wmav2=True,
                                        )
```
<a id="g726"></a>
### [⬆️](#available-augmentations) g726
```python
g726={'audio_bitrate': '40k'},
```
<a id="gsm"></a>
### [⬆️](#available-augmentations) gsm
```python
gsm=True,
```
<a id="amr"></a>
### [⬆️](#available-augmentations) amr
```python
amr={'audio_bitrate': '4.75k'},
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "AudioAugmentor",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "audio,augmentation,pytorch,machine learning,deep learning,data augmentation,audio processing,audio augmentation,audio data augmentation,audio data processing,torchaudio,ffmpeg,ffmpeg-python,audiomentations,torch-audiomentations,RIR,room impulse response,room simulation,pyroomacoustics",
    "author": "",
    "author_email": "Ladislav Va\u0161ina <ladislavvasina@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/41/2c/fdc3bb01adb794a208744747d63ef647c074a44ee675591f01b495dd2071/AudioAugmentor-0.0.5.tar.gz",
    "platform": null,
    "description": "# AudioAugmentor\n### Python library for augmenting audio data\n[![EXAMPLE 1](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1IMVLl6LCUU5gaYAz0IMSAcHh7Iq7NZr7?usp=sharing)\n\n\nThis library is designed to augment audio data for machine learning purposes. \nIt combines several tools and libraries for audio data augmentation and provides a unified interface that can be used to apply a large set of audio augmentations in one place.\n\nThe library is designed to be used with the [PyTorch](https://pytorch.org) machine learning framework.\nIt can also work solely on just simple audio waveforms and augment those.\n\nThis library specifically combines these libraries and tools:\n\n- [torchaudio](https://pytorch.org/audio/stable/index.html)\n- [audiomentations](https://github.com/iver56/audiomentations)\n- [torch-audiomentations](https://github.com/asteroid-team/torch-audiomentations)\n- [pyroomacoustics](https://pyroomacoustics.readthedocs.io/en/pypi-release/index.html)\n- [ffmpeg-python](https://github.com/kkroening/ffmpeg-python)\n\n\n### Available augmentations\nTable below shows which library was used to apply specific audio augmentation/codec.\n\n|                                                                      | [audiomentations](https://iver56.github.io/audiomentations/) | [torch-audiomentations](https://github.com/asteroid-team/torch-audiomentations) | [torchaudio](https://pytorch.org/audio/stable/index.html) | [pyroomacoustics](https://pyroomacoustics.readthedocs.io/en/pypi-release/index.html) | [ffmpeg-python](https://github.com/kkroening/ffmpeg-python) |\n|----------------------------------------------------------------------|:---------------:|:---------------------:|:----------:|:---------------:|:------:|\n| [AddBackgroundNoise](#addbackgroundnoise)                            |                 |           \u2705          |            |                 |        |\n| [AddColoredNoise](#addcolorednoise) |                 |           \u2705          |            |                 |        |\n| [AddGaussianNoise](#addgaussiannoise)                                |        \u2705       |                       |            |                 |        |\n| [AddShortNoises](#addshortnoises)                                    |        \u2705       |                       |            |                 |        |\n| [AdjustDuration](#adjustduration)                                    |        \u2705       |                       |            |                 |        |\n| [AirAbsorption](#airabsorption)                                      |        \u2705       |                       |            |                 |        |\n| [ApplyImpulseResponse](#applyimpulseresponse)                        |                 |           \u2705          |            |                 |        |\n| [BandPassFilter](#bandpassfilter)                                    |                 |           \u2705          |            |                 |        |\n| [BandStopFilter](#bandstopfilter)                                    |                 |           \u2705          |            |                 |        |\n| [ClippingDistortion](#clippingdistortion)                            |        \u2705       |                       |            |                 |        |\n| [FrequencyMasking](#frequencymasking)                                |                 |                       |     \u2705     |                 |        |\n| [Volume / Gain](#volume--gain)                                       |                 |                       |     \u2705     |                 |        |\n| [GainTransition](#gaintransition)                                    |        \u2705       |                       |            |                 |        |\n| [HighPassFilter](#highpassfilter)                                    |                 |           \u2705          |            |                 |        |\n| [HighShelfFilter](#highshelffilter)                                  |        \u2705       |                       |            |                 |        |\n| [Limiter](#limiter)                                                  |        \u2705       |                       |            |                 |        |\n| [LoudnessNormalization](#loudnessnormalization)                      |        \u2705       |                       |            |                 |        |\n| [LowPassFilter](#lowpassfilter)                                      |                 |           \u2705          |            |                 |        |\n| [LowShelfFilter](#lowshelffilter)                                    |        \u2705       |                       |            |                 |        |\n| [Mp3Compression](#mp3compression)                                    |        \u2705       |                       |            |                 |        |\n| [MelSpectrogram](#melspectrogram)                                    |                 |                       |     \u2705     |                 |        |\n| [Normalize](#normalize)                                              |        \u2705       |                       |            |                 |        |\n| [Padding](#padding)                                                  |        \u2705       |                       |            |                 |        |\n| [PeakNormalization](#peaknormalization)                              |                 |           \u2705          |            |                 |        |\n| [PeakingFilter](#peakingfilter)                                      |        \u2705       |                       |            |                 |        |\n| [PitchShift](#pitchshift)                                            |                 |                       |     \u2705     |                 |        |\n| [PolarityInversion](#polarityinversion)                              |                 |           \u2705          |            |                 |        |\n| [Time inversion](#time-inversion)                                    |                 |           \u2705          |            |                 |        |\n| [ApplyRIR (RoomSimulator)](#applyrir)                                |                 |                       |            |        \u2705       |        |\n| [SevenBandParametricEQ](#sevenbandparametriceq)                      |       \u2705        |                       |            |                 |        |\n| [Shift](#shift)                                                      |                 |           \u2705          |            |                 |        |\n| [Speed](#speed)                                                      |                 |                       |     \u2705     |                 |        |\n| [Spectrogram](#spectrogram)                                          |                 |                       |     \u2705     |                 |        |\n| [TanhDistortion](#tanhdistortion)                                    |       \u2705        |                       |            |                 |        |\n| [TimeMasking](#timemasking)                                             |                 |                       |     \u2705     |                 |        |\n| [TimeStretch](#timestretch)                                          |       \u2705        |                       |            |                 |        |\n| [ac3](#codecs-using-torchaudio)                                      |                 |                       |     \u2705     |                 |        |\n| [adpcm_ima_wav](#codecs-using-torchaudio)                            |                 |                       |     \u2705     |                 |        |\n| [adpcm_ms](#codecs-using-torchaudio)                                 |                 |                       |     \u2705     |                 |        |\n| [adpcm_yamaha](#codecs-using-torchaudio)                             |                 |                       |     \u2705     |                 |        |\n| [eac3](#codecs-using-torchaudio)                                     |                 |                       |     \u2705     |                 |        |\n| [flac](#codecs-using-torchaudio)                                     |                 |                       |     \u2705     |                 |        |\n| [libmp3lame](#codecs-using-torchaudio)                               |                 |                       |     \u2705     |                 |        |\n| [mp2](#codecs-using-torchaudio)                                      |                 |                       |     \u2705     |                 |        |\n| [pcm_alaw](#codecs-using-torchaudio)                                 |                 |                       |     \u2705     |                 |        |\n| [pcm_f32le](#codecs-using-torchaudio)                                |                 |                       |     \u2705     |                 |        |\n| [pcm_mulaw](#codecs-using-torchaudio)                                |                 |                       |     \u2705     |                 |        |\n| [pcm_s16le](#codecs-using-torchaudio)                                |                 |                       |     \u2705     |                 |        |\n| [pcm_s24le](#codecs-using-torchaudio)                                |                 |                       |     \u2705     |                 |        |\n| [pcm_s32le](#codecs-using-torchaudio)                                |                 |                       |     \u2705     |                 |        |\n| [pcm_u8](#codecs-using-torchaudio)                                   |                 |                       |     \u2705     |                 |        |\n| [wmav1](#codecs-using-torchaudio)                                    |                 |                       |     \u2705     |                 |        |\n| [wmav2](#codecs-using-torchaudio)                                    |                 |                       |     \u2705     |                 |        |\n| [g726](#g726)                                                        |                 |                       |            |                 |   \u2705   |\n| [gsm](#gsm)                                                          |                 |                       |            |                 |   \u2705   |\n| [amr](#amr)                                                          |                 |                       |            |                 |   \u2705   |\n\n\n## Usage\nFor a more complex example see [example colab notebook above](#python-library-for-augmenting-audio-data).\n\n`Note: AudioAugmentor was mainly tested using Python 3.11.8 and Fedora 38 (Google Colab uses Python 3.10 and Ubuntu)`\n\n\n**0. You need to install the library and necessary packages first**\n```bash\npip install -U pip\npip install AudioAugmentor\ndnf install -y sox                # FEDORA\ndnf install -y sox-devel          # FEDORA\ndnf install -y ffmpeg             # FEDORA\n# apt-get install -y sox          # UBUNTU\n# apt-get install -y libsox-dev   # UBUNTU\n# apt-get install -y ffmpeg       # UBUNTU\n```\n\n**1. Import necessary libraries**\n```python\nimport torch\nimport torchaudio\nimport numpy as np\nimport audiomentations as AA\nfrom IPython.display import Audio, display\n\nfrom AudioAugmentor import transf_gen\nfrom AudioAugmentor import sox_parser\nfrom AudioAugmentor import core\nfrom AudioAugmentor import rir_setup\nfrom AudioAugmentor import torchaudio_transf_wrapper as TTW\n```\n**2. Define the augmentations you want to apply to your audio data.**\n\nYou have **3** options of how to define the augmentations:\n\n**a)** Use `transf_gen.transf_gen` function to generate list of transformations.\n\nSee [supported transformation table](#available-augmentations) and examples of every augmentation, so you know what parameters are needed for each augmentation method.\n\nYou can enter augmentation parameters as a string or as a dictionary.\n\n`PitchShift='sample_rate=16000, n_steps=[1, 1.5, 0.1], p=1.0'`\n\n`PitchShift={'sample_rate': 16000, 'n_steps': [1, 1.5, 0.1], 'p': 1.0}`\n```php\ntransformations = transf_gen.transf_gen(verbose=True,\n                                        PitchShift='sample_rate=16000, n_steps=[1, 1.5, 0.1], p=1.0',\n                                        Speed={'orig_freq': 16000, 'factor': [0.9, 1.5, 0.1], 'p': 1},\n                                        LowPassFilter={'min_cutoff_freq': 700, 'max_cutoff_freq': 800, 'sample_rate': sampling_rate, 'p': 1},\n)\n```\n**b)** Use pseudo SoX command.\nSoX command **must** be in this format:\n\n`--sox=\"norm gain 0 highpass 1000 phaser 0.5 0.6 1 0.45 0.6 -s\"`\n\n(When you don't want to apply some codec after applying SoX effects)\n\nOR\n\n`--sox=\"norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s\" amr audio_bitrate 4.75k`\n\n(In this case, you want to apply codec after applying SoX effects -> Codec is entered in the form `codec_name` `codec_parameter_name` `codec_parameter_value` directly after the SoX effects command)\n```python\nexample_sox = '--sox=\"norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s\" amr audio_bitrate 4.75k'\n```\n\n**c)** Use a file with multiple pseudo SoX commands. Random SoX command from this file will be chosen and applied to your data.\n\nFile **must** to be loaded using `sox_parser.load_sox_file` function. \n```php\nsox_file_content_to_write = '''--sox=\"norm gain 0 highpass 1000 phaser 0.5 0.6 1 0.45 0.6 -s\"\n#--sox=\"norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s\"\n--sox=\"norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s\" gsm\n--sox=\"norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s\" amr audio_bitrate 4.75k\n'''\nwith open('sox_file_example.txt', 'w') as f:\n    f.write(sox_file_content_to_write)\n\nsox_file_content = sox_parser.load_sox_file('sox_file_example.txt')\nprint('SOX FILE LOADED:', sox_file_content, type(sox_file_content))\n```\n\n\n\n**3. Apply augmentations**\n\n**a)** Use generated the `transformations` list, `single SoX command` or `loaded SoX file content` while initializing `CollateFunction` class. \n\nUse this initiated class as an argument for the `collate_fn` parameter of PyTorch's dataloader.\n```php\ncollate_fn = core.CollateFunction(\n    transformations=transformations, device='cpu', sox_effects=None, sample_rate=sampling_rate, verbose=True,\n    #transformations=None, device='cpu', sox_effects='--sox=\"norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s\" amr audio_bitrate 4.75k', sample_rate=sampling_rate, verbose=False,\n    #transformations=None, device='cpu', sox_effects=sox_file_content, sample_rate=sampling_rate, verbose=False,\n)\n\ndataset = torchaudio.datasets.LIBRISPEECH(\"../data\", url=\"train-clean-100\", download=True)\naug_dataloader = torch.utils.data.DataLoader(\n    dataset,\n    batch_size=1,\n    num_workers=0,\n    collate_fn=collate_fn,\n)\naugmented_record_from_dataset = next(iter(aug_dataloader))\ndisplay(Audio(augmented_record_from_dataset[0].squeeze(0).squeeze(0).squeeze(0).cpu(), rate=sampling_rate))\n```\n`OR`\n\n**b)** Use generated the `transformations` list, `single SoX command` or `loaded SoX file content` while initializing `AugmentWaveform` class and apply the augmentations to the audio signal.\n```php\naugment = core.AugmentWaveform(\n    transformations=transformations, device='cpu', sox_effects=None, sample_rate=16000, verbose=False,\n    #transformations=None, device='cpu', sox_effects='--sox=\"norm gain 20 highpass 300 phaser 0.5 0.6 1 0.45 0.6 -s\" amr audio_bitrate 4.75k', sample_rate=16000, verbose=False,\n    #transformations=None, device='cpu', sox_effects=sox_file_content, sample_rate=16000, verbose=False,\n)\n# Load test wav file\nsignal, fs = torchaudio.load('../data/test.wav')\n# Apply transformations\nwaveform = augment(signal.numpy()[0])\ndisplay(Audio(waveform, rate=fs))\n```\n\n\n# EXAMPLES OF AVAILABLE AUGMENTATIONS\n## !!!Put following examples as an argument for `transf_gen.transf_gen` function to generate a list of transformations!!!\n\nLike this:\n```php\ntransformations = transf_gen.transf_gen(verbose=True,\n                                        AddBackgroundNoise=f'background_paths=\"../data/musan/noise/free-sound\", min_snr_in_db=10, max_snr_in_db=20, p=1, sample_rate={sampling_rate}',\n                                        AddColoredNoise=f'min_snr_in_db=9, max_snr_in_db=10, p=1, sample_rate={sampling_rate}',\n                                        )\n```\nYou can enter augmentation parameters as a string or as a dictionary.\n\n`PitchShift='sample_rate=16000, n_steps=[1, 1.5, 0.1], p=1.0'`\n\n`PitchShift={'sample_rate': 16000, 'n_steps': [1, 1.5, 0.1], 'p': 1.0}`\n\n<a id=\"addbackgroundnoise\"></a>\n### [\u2b06\ufe0f](#available-augmentations) AddBackgroundNoise [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/background_noise.py#L32-L51)\n```python\nAddBackgroundNoise=f'''background_paths=\"../data/musan/noise/free-sound\",\n                       min_snr_in_db=10, \n                       max_snr_in_db=20, \n                       p=1, \n                       sample_rate={sampling_rate}''',\n```\n<a id=\"addcolorednoise\"></a>\n### [\u2b06\ufe0f](#available-augmentations) AddColoredNoise [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/colored_noise.py#L49-L74)\n```python\nAddColoredNoise=f'''min_snr_in_db=9,\n                    max_snr_in_db=10, \n                    p=1, \n                    sample_rate={sampling_rate}''',\n```\n<a id=\"addgaussiannoise\"></a>\n### [\u2b06\ufe0f](#available-augmentations) AddGaussianNoise [docs](https://iver56.github.io/audiomentations/waveform_transforms/add_gaussian_noise/)\n```python\nAddGaussianNoise={'min_amplitude': 0.001, \n                  'max_amplitude': 0.015, \n                  'p': 1},\n```\n<a id=\"addshortnoises\"></a>\n### [\u2b06\ufe0f](#available-augmentations) AddShortNoises [docs](https://iver56.github.io/audiomentations/waveform_transforms/add_short_noises/)\n```python\nAddShortNoises={'sounds_path': \"../data/musan/noise/free-sound\",\n                'min_snr_in_db': 3.0,\n                'max_snr_in_db': 30.0,\n                'noise_rms': \"relative_to_whole_input\",\n                'min_time_between_sounds': 2.0,\n                'max_time_between_sounds': 8.0,\n                'noise_transform': AA.PolarityInversion(),\n                'p': 1.0},\n```\n<a id=\"adjustduration\"></a>\n### [\u2b06\ufe0f](#available-augmentations) AdjustDuration [docs](https://iver56.github.io/audiomentations/waveform_transforms/adjust_duration/)\n```python\nAdjustDuration={'duration_seconds': 3.5, \n                'padding_mode': 'silence', \n                'p': 1},\n```\n<a id=\"airabsorption\"></a>\n### [\u2b06\ufe0f](#available-augmentations) AirAbsorption [docs](https://iver56.github.io/audiomentations/waveform_transforms/air_absorption/)\n```python\nAirAbsorption={'min_distance': 10.0, \n               'max_distance': 50.0, \n               'min_humidity': 80.0, \n               'max_humidity': 90.0, \n               'min_temperature': 10.0, \n               'max_temperature': 20.0, \n               'p': 1.0},\n```\n<a id=\"applyimpulseresponse\"></a>\n### [\u2b06\ufe0f](#available-augmentations) ApplyImpulseResponse [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/impulse_response.py#L33-L55)\n```python\nApplyImpulseResponse=f'''ir_paths=\"../data/Rir.wav\", \n                         p=1, \n                         sample_rate={sampling_rate}''',\n```\n<a id=\"bandpassfilter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) BandPassFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/band_pass_filter.py#L25-L46)\n```python\nBandPassFilter=f'''min_center_frequency=200, \n                   max_center_frequency=4000, \n                   min_bandwidth_fraction=0.5, \n                   max_bandwidth_fraction=1.99, \n                   sample_rate={sampling_rate}, \n                   p=1''',\n```\n<a id=\"bandstopfilter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) BandStopFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/band_stop_filter.py#L16-L38)\n```python\nBandStopFilter=f'''min_center_frequency=200, \n                   max_center_frequency=4000, \n                   min_bandwidth_fraction=0.5, \n                   max_bandwidth_fraction=1.99, \n                   sample_rate={sampling_rate}, \n                   p=1''',\n```\n<a id=\"clippingdistortion\"></a>\n### [\u2b06\ufe0f](#available-augmentations) ClippingDistortion [docs](https://iver56.github.io/audiomentations/waveform_transforms/clipping_distortion/)\n```python\nClippingDistortion={'min_percentile_threshold': 10, \n                    'max_percentile_threshold': 30, \n                    'p': 1},\n```\n<a id=\"frequencymasking\"></a>\n### [\u2b06\ufe0f](#available-augmentations) FrequencyMasking [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.FrequencyMasking.html)\n```python\nFrequencyMasking={'freq_mask_param': 80},\n```\n<a id=\"volume--gain\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Volume / Gain [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.Vol.html)\n```python\nVol={'gain': [2.5, 3, 0.1], \n     'p': 1.0},\n```\n<a id=\"gaintransition\"></a>\n### [\u2b06\ufe0f](#available-augmentations) GainTransition [docs](https://iver56.github.io/audiomentations/waveform_transforms/gain_transition/)\n```python\nGainTransition={'min_gain_db': 30, \n                'max_gain_db': 40, \n                'min_duration': 5, \n                'max_duration': 16, \n                'duration_unit': 'seconds', \n                'p': 1},\n```\n<a id=\"highpassfilter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) HighPassFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/high_pass_filter.py#L15-L31)\n```python\nHighPassFilter=f'''min_cutoff_freq=700,\n                   max_cutoff_freq=800,\n                   sample_rate={sampling_rate},\n                   p=1''',\n```\n<a id=\"highshelffilter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) HighShelfFilter [docs](https://iver56.github.io/audiomentations/waveform_transforms/high_shelf_filter/)\n```python\nHighShelfFilter={'min_center_freq': 2000, \n                 'max_center_freq': 5000, \n                 'min_gain_db': 10.0, \n                 'max_gain_db': 16.0, \n                 'min_q': 0.5, \n                 'max_q': 1.0, \n                 'p': 1},\n```\n<a id=\"limiter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Limiter [docs](https://iver56.github.io/audiomentations/waveform_transforms/limiter/)\n```python\nLimiter='''min_threshold_db=-24, \n           max_threshold_db=-2,\n           min_attack=0.0005, \n           max_attack=0.025, \n           min_release=0.05, \n           max_release=0.7, \n           threshold_mode=\"relative_to_signal_peak\", \n           p=1''',\n```\n<a id=\"loudnessnormalization\"></a>\n### [\u2b06\ufe0f](#available-augmentations) LoudnessNormalization [docs](https://iver56.github.io/audiomentations/waveform_transforms/loudness_normalization/)\n```python\nLoudnessNormalization={'min_lufs': -31, \n                       'max_lufs': -13, \n                       'p': 1},\n```\n<a id=\"lowpassfilter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) LowPassFilter [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/low_pass_filter.py#L27-L42)\n```python\nLowPassFilter={'min_cutoff_freq': 700, \n               'max_cutoff_freq': 800, \n               'sample_rate': sampling_rate, \n               'p': 1},\n```\n<a id=\"lowshelffilter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) LowShelfFilter [docs](https://iver56.github.io/audiomentations/waveform_transforms/low_shelf_filter/)\n```python\nLowShelfFilter={'min_center_freq': 20, \n                'max_center_freq': 600, \n                'min_gain_db': -16.0, \n                'max_gain_db': 16.0, \n                'min_q': 0.5, \n                'max_q': 1.0, \n                'p': 1},\n```\n<a id=\"mp3compression\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Mp3Compression [docs](https://iver56.github.io/audiomentations/waveform_transforms/mp3_compression/)\n```python\nMp3Compression={'min_bitrate': 8, \n                'max_bitrate': 8, \n                'backend': 'pydub', \n                'p': 1},\n```\n<a id=\"melspectrogram\"></a>\n### [\u2b06\ufe0f](#available-augmentations) MelSpectrogram [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.MelSpectrogram.html)\n```python\nMelSpectrogram={'sample_rate': 16000},\n```\n<a id=\"normalize\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Normalize [docs](https://iver56.github.io/audiomentations/waveform_transforms/normalize/)\n```python\nNormalize={'p': 1},\n```\n<a id=\"padding\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Padding [docs](https://iver56.github.io/audiomentations/waveform_transforms/padding/)\n```python\nPadding={'mode': 'silence', \n         'min_fraction': 0.02, \n         'max_fraction': 0.8, \n         'pad_section': 'start', \n         'p': 1},\n```\n<a id=\"peaknormalization\"></a>\n### [\u2b06\ufe0f](#available-augmentations) PeakNormalization [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/peak_normalization.py#L34-L36)\n```python\nPeakNormalization={'p': 1, \n                   'sample_rate': sampling_rate},\n```\n<a id=\"peakingfilter\"></a>\n### [\u2b06\ufe0f](#available-augmentations) PeakingFilter [docs](https://iver56.github.io/audiomentations/waveform_transforms/peaking_filter/)\n```python\nPeakingFilter={'min_center_freq': 51, \n               'max_center_freq': 7400, \n               'min_gain_db': -22, \n               'max_gain_db': 22, \n               'min_q': 0.5, \n               'max_q': 1.0, \n               'p': 1},\n```\n<a id=\"pitchshift\"></a>\n### [\u2b06\ufe0f](#available-augmentations) PitchShift [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.PitchShift.html)\n```python\nPitchShift={'sample_rate': 16000, \n            'n_steps': [1, 1.5, 0.1],\n            'bins_per_octave': 12, \n            'n_fft': 512, \n            'win_length':512, \n            'hop_length': 512//4, \n            'p': 1.0},\n```\n<a id=\"polarityinversion\"></a>\n### [\u2b06\ufe0f](#available-augmentations) PolarityInversion [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/polarity_inversion.py#L30-L32)\n```python\nPolarityInversion={'p': 1, \n                   'sample_rate': sampling_rate},\n```\n<a id=\"time-inversion\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Time inversion [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/time_inversion.py#L28-L39)\n```python\nTimeInversion={'p': 1, \n               'sample_rate': sampling_rate},\n```\n<a id=\"applyrir\"></a>\n### [\u2b06\ufe0f](#available-augmentations) ApplyRIR\n```php\n# Use this to see available materials you can use as walls_mat, floor_mat and ceiling_mat argument\n# from AudioAugmentor import rir_setup\n# rir_setup.get_all_materials_info()\n\nrir_kwargs = {\n    'audio_sample_rate': 16000,\n    'x_range': (0, 100), \n    'y_range': (0, 100), \n    'num_vertices_range': (3, 6),\n    'mic_height': 1.5,\n    'source_height': 1.5,\n    'walls_mat': 'curtains_cotton_0.5',\n    'room_height': 2.0,\n    'max_order': 3,\n    'floor_mat': 'carpet_cotton',\n    'ceiling_mat': 'hard_surface',\n    'ray_tracing': True,\n    'air_absorption': True,\n}\ntransformations = transf_gen.transf_gen(verbose=True,\n                                        ApplyRIR=rir_kwargs,\n                                        )\n```\n<a id=\"sevenbandparametriceq\"></a>\n### [\u2b06\ufe0f](#available-augmentations) SevenBandParametricEQ [docs](https://iver56.github.io/audiomentations/waveform_transforms/seven_band_parametric_eq/)\n```python\nSevenBandParametricEQ={'min_gain_db': -10, \n                       'max_gain_db': 10, \n                       'p': 1},\n```\n<a id=\"shift\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Shift [docs](https://github.com/asteroid-team/torch-audiomentations/blob/9baf5c516a44651025bd7e8d8ead35888b58bbdc/torch_audiomentations/augmentations/shift.py#L66-L93)\n```python\nShift={'min_shift': 1, \n       'max_shift': 2, \n       'p': 1, \n       'sample_rate': sampling_rate},\n```\n<a id=\"speed\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Speed [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.Speed.html)\n```python\nSpeed={'orig_freq': 16000, \n       'factor': [0.9, 1.5, 0.1], \n       'p': 1},\n```\n<a id=\"spectrogram\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Spectrogram [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.Spectrogram.html)\n```python\nSpectrogram={'sample_rate': 16000},\n```\n<a id=\"tanhdistortion\"></a>\n### [\u2b06\ufe0f](#available-augmentations) TanhDistortion [docs](https://iver56.github.io/audiomentations/waveform_transforms/tanh_distortion/)\n```python\nTanhDistortion={'min_distortion': 0.1, \n                'max_distortion': 0.8, \n                'p': 1},\n```\n<a id=\"timemasking\"></a>\n### [\u2b06\ufe0f](#available-augmentations) TimeMasking [docs](https://pytorch.org/audio/main/generated/torchaudio.transforms.TimeMasking.html)\n```python\nTimeMasking={'time_mask_param': 80},\n```\n<a id=\"timestretch\"></a>\n### [\u2b06\ufe0f](#available-augmentations) TimeStretch [docs](https://iver56.github.io/audiomentations/waveform_transforms/time_stretch/)\n```python\nTimeStretch='''min_rate=0.9, \n               max_rate=1.1, \n               p=0.2, \n               leave_length_unchanged=False''',\n```\n<a id=\"codecs-using-torchaudio\"></a>\n### [\u2b06\ufe0f](#available-augmentations) Codecs using torchaudio\nYou can select just one. No need to use them all. :)\n```php\ntransformations = transf_gen.transf_gen(verbose=True,\n                                        ac3=True,\n                                        adpcm_ima_wav=True,\n                                        adpcm_ms=True,\n                                        adpcm_yamaha=True,\n                                        eac3=True,\n                                        flac=True,\n                                        libmp3lame=True,\n                                        mp2=True,\n                                        pcm_alaw=True,\n                                        pcm_f32le=True,\n                                        pcm_mulaw=True,\n                                        pcm_s16le=True,\n                                        pcm_s24le=True,\n                                        pcm_s32le=True,\n                                        pcm_u8=True,\n                                        wmav1=True,\n                                        wmav2=True,\n                                        )\n```\n<a id=\"g726\"></a>\n### [\u2b06\ufe0f](#available-augmentations) g726\n```python\ng726={'audio_bitrate': '40k'},\n```\n<a id=\"gsm\"></a>\n### [\u2b06\ufe0f](#available-augmentations) gsm\n```python\ngsm=True,\n```\n<a id=\"amr\"></a>\n### [\u2b06\ufe0f](#available-augmentations) amr\n```python\namr={'audio_bitrate': '4.75k'},\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) [2024] [Ladislav Va\u0161ina]  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Python package for simple application of wide range of audio augmentations.",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/LadislavVasina1/AudioAugmentor",
        "Issues": "https://github.com/LadislavVasina1/AudioAugmentor/issues",
        "Repository": "https://github.com/LadislavVasina1/AudioAugmentor"
    },
    "split_keywords": [
        "audio",
        "augmentation",
        "pytorch",
        "machine learning",
        "deep learning",
        "data augmentation",
        "audio processing",
        "audio augmentation",
        "audio data augmentation",
        "audio data processing",
        "torchaudio",
        "ffmpeg",
        "ffmpeg-python",
        "audiomentations",
        "torch-audiomentations",
        "rir",
        "room impulse response",
        "room simulation",
        "pyroomacoustics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b44e0a29a11a110053263120efea82ab6da64f432fd55822ed7c36bdf8b21b0",
                "md5": "7e3aeffb91a2b0061e02b71560cb91c1",
                "sha256": "5acff548b9238cabaa95c58d6986c6802d5c25fe7399df35715a549bf151b43e"
            },
            "downloads": -1,
            "filename": "AudioAugmentor-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7e3aeffb91a2b0061e02b71560cb91c1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 25722,
            "upload_time": "2024-03-11T17:27:18",
            "upload_time_iso_8601": "2024-03-11T17:27:18.719897Z",
            "url": "https://files.pythonhosted.org/packages/5b/44/e0a29a11a110053263120efea82ab6da64f432fd55822ed7c36bdf8b21b0/AudioAugmentor-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "412cfdc3bb01adb794a208744747d63ef647c074a44ee675591f01b495dd2071",
                "md5": "7d935050743e1c7159155b8a069d9eb1",
                "sha256": "4bf1f7f51c95967f54bc3f1ab8d36f3fe12a5345a34dc122f5de1fbca78e4696"
            },
            "downloads": -1,
            "filename": "AudioAugmentor-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "7d935050743e1c7159155b8a069d9eb1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 34396,
            "upload_time": "2024-03-11T17:27:22",
            "upload_time_iso_8601": "2024-03-11T17:27:22.537947Z",
            "url": "https://files.pythonhosted.org/packages/41/2c/fdc3bb01adb794a208744747d63ef647c074a44ee675591f01b495dd2071/AudioAugmentor-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-11 17:27:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LadislavVasina1",
    "github_project": "AudioAugmentor",
    "github_not_found": true,
    "lcname": "audioaugmentor"
}
        
Elapsed time: 0.20447s