Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, datadir, args, transform=None, splits=[.8, .1, .1], shuffle_files=True, train='train'):
self.args = args
# Metadata and raw
self.data_files = []
# Spectral transforms
self.features_files = []
# Construct set of extractors
self.construct_extractors(args)
# Construct the FFT extractor
self.multi_fft = MultiscaleFFT(args.scales)
# Retrieve list of files
tmp_files = sorted(glob.glob(datadir + '/raw/*.wav'))
self.data_files.extend(tmp_files)
if (not os.path.exists(datadir + '/data') or len(glob.glob(datadir + '/data/*.npy')) == 0):
os.makedirs(datadir + '/data')
self.preprocess_dataset(datadir)
feat_files = sorted(glob.glob(datadir + '/data/*.npy'))
self.features_files.extend(feat_files)
# Analyze dataset
self.analyze_dataset()
# Create splits
self.create_splits(splits, shuffle_files)
# Compute mean and std of dataset
self.compute_normalization()
# Now we can create the normalization / augmentation transform
self.transform = transform