Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from torchaudio import transforms as T
import random
from glob import glob
from diffusion.utils import Stereo, PadCrop
from diffusion.utils import Stereo, PadCrop, PhaseFlipper, NormInputs

class SampleDataset(torch.utils.data.Dataset):
def __init__(self, paths, global_args):
Expand All @@ -12,20 +12,18 @@ def __init__(self, paths, global_args):

self.augs = torch.nn.Sequential(
#RandomGain(0.9, 1.0),
PadCrop(global_args.sample_size),
PadCrop(global_args.sample_size, randomize=global_args.random_crop),
PhaseFlipper(),
NormInputs(do_norm=global_args.norm_inputs)
)

self.encoding = torch.nn.Sequential(
Stereo()
)

for path in paths:
self.filenames += glob(f'{path}/**/*.wav', recursive=True)
self.filenames += glob(f'{path}/**/*.flac', recursive=True)
self.filenames += glob(f'{path}/**/*.ogg', recursive=True)
self.filenames += glob(f'{path}/**/*.aiff', recursive=True)
self.filenames += glob(f'{path}/**/*.aif', recursive=True)
self.filenames += glob(f'{path}/**/*.mp3', recursive=True)
for ext in ['wav','flac','ogg','aiff','aif','mp3']:
self.filenames += glob(f'{path}/**/*.{ext}', recursive=True)

self.sr = global_args.sample_rate

Expand All @@ -51,7 +49,7 @@ def __getitem__(self, idx):
audio = self.audio_files[idx]
else:
audio = self.load_file(audio_filename)

audio = audio.clamp(-1, 1)

#Run file-level augmentations
Expand Down Expand Up @@ -83,12 +81,8 @@ def __init__(self, paths, global_args):


for path in paths:
self.filenames += glob(f'{path}/**/*.wav', recursive=True)
self.filenames += glob(f'{path}/**/*.flac', recursive=True)
self.filenames += glob(f'{path}/**/*.ogg', recursive=True)
self.filenames += glob(f'{path}/**/*.aiff', recursive=True)
self.filenames += glob(f'{path}/**/*.aif', recursive=True)
self.filenames += glob(f'{path}/**/*.mp3', recursive=True)
for ext in ['wav','flac','ogg','aiff','aif','mp3']:
self.filenames += glob(f'{path}/**/*.{ext}', recursive=True)

self.sr = global_args.sample_rate

Expand Down
Loading