Skip to content

Commit

Permalink
0.77.3
Browse files Browse the repository at this point in the history
  • Loading branch information
FBurkhardt committed Dec 26, 2023
1 parent d2c94eb commit bd4ab2e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions nkululeko/augmenting/augmenter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# augmenter.py
import os

import audeer
import audiofile
import numpy as np
import pandas as pd
from audformat.utils import map_file_path
from audiomentations import (
AddGaussianNoise,
AddGaussianSNR,
Expand All @@ -14,8 +10,11 @@
Shift,
TimeStretch,
)
from nkululeko.utils.util import Util
from tqdm import tqdm
import audeer
import audiofile
from audformat.utils import map_file_path
from nkululeko.utils.util import Util


class Augmenter:
Expand All @@ -27,14 +26,17 @@ def __init__(self, df):
self.df = df
self.util = Util("augmenter")
# Define a standard transformation that randomly add augmentations to files
self.audioment = Compose(
[
AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=0.5),
TimeStretch(min_rate=0.8, max_rate=1.25, p=0.5),
PitchShift(min_semitones=-4, max_semitones=4, p=0.5),
Shift(p=0.5),
]
)
# self.audioment = Compose(
# [
# AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=0.5),
# TimeStretch(min_rate=0.8, max_rate=1.25, p=0.5),
# PitchShift(min_semitones=-4, max_semitones=4, p=0.5),
# Shift(p=0.5),
# ]
# )
defaults = "Compose([AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=0.5),TimeStretch(min_rate=0.8, max_rate=1.25, p=0.5),PitchShift(min_semitones=-4, max_semitones=4, p=0.5),Shift(p=0.5),])"
audiomentations = self.util.config_val("AUGMENT", "augmentations", defaults)
self.audioment = eval(audiomentations)

def changepath(self, fp, np):
# parent = os.path.dirname(fp).split('/')[-1]
Expand Down

0 comments on commit bd4ab2e

Please sign in to comment.