forked from mrq/DL-Art-School
Add noise first to audio_aug
This commit is contained in:
parent
d6007c6de1
commit
908ef5495f
|
@ -45,9 +45,9 @@ class WavAugmentor:
|
||||||
]
|
]
|
||||||
vol_effect = random.choice(volume_effects)
|
vol_effect = random.choice(volume_effects)
|
||||||
effects = [speed_effect, band_effect, vol_effect]
|
effects = [speed_effect, band_effect, vol_effect]
|
||||||
out, sr = torchaudio.sox_effects.apply_effects_tensor(wav, sample_rate, effects)
|
|
||||||
# Add a variable amount of noise
|
# Add a variable amount of noise
|
||||||
out = out + torch.rand_like(out) * random.random() * .05
|
out = wav + torch.rand_like(wav) * random.random() * .05
|
||||||
|
out, sr = torchaudio.sox_effects.apply_effects_tensor(out, sample_rate, effects)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ class WavfileDataset(torch.utils.data.Dataset):
|
||||||
clip2 = self.augmentor.augment(clip2, self.sampling_rate)
|
clip2 = self.augmentor.augment(clip2, self.sampling_rate)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'clip1': clip1,
|
'clip1': clip1[0, :].unsqueeze(0),
|
||||||
'clip2': clip2,
|
'clip2': clip2[0, :].unsqueeze(0),
|
||||||
'path': filename,
|
'path': filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,10 +83,11 @@ if __name__ == '__main__':
|
||||||
}
|
}
|
||||||
from data import create_dataset, create_dataloader, util
|
from data import create_dataset, create_dataloader, util
|
||||||
|
|
||||||
ds, c = create_dataset(params, return_collate=True)
|
ds = create_dataset(params, return_collate=True)
|
||||||
dl = create_dataloader(ds, params, collate_fn=c)
|
dl = create_dataloader(ds, params, collate_fn=c)
|
||||||
i = 0
|
i = 0
|
||||||
for b in tqdm(dl):
|
for b in tqdm(dl):
|
||||||
torchaudio.save(f'{i}_clip1.wav', b['clip1'], ds.sampling_rate)
|
for b_ in range(16):
|
||||||
torchaudio.save(f'{i}_clip2.wav', b['clip2'], ds.sampling_rate)
|
torchaudio.save(f'{i}_clip1_{b_}.wav', b['clip1'][b_], ds.sampling_rate)
|
||||||
i += 1
|
torchaudio.save(f'{i}_clip2_{b_}.wav', b['clip2'][b_], ds.sampling_rate)
|
||||||
|
i += 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user