Enable multiple wavfile paths to be specified, fix eps bug in mp3 splitter

This commit is contained in:
James Betker 2021-08-11 08:46:02 -06:00
parent e19c00398e
commit d0c74278bf
2 changed files with 8 additions and 4 deletions

View File

@ -15,13 +15,17 @@ from utils.util import opt_get
class WavfileDataset(torch.utils.data.Dataset): class WavfileDataset(torch.utils.data.Dataset):
def __init__(self, opt): def __init__(self, opt):
cache_path = opt_get(opt, ['cache_path'], os.path.join(self.path, 'cache.pth')) # Will fail when multiple paths specified, must be specified in this case.
self.path = os.path.dirname(opt['path']) self.path = os.path.dirname(opt['path'])
cache_path = os.path.join(self.path, 'cache.pth') if not isinstance(self.path, list):
self.path = [self.path]
if os.path.exists(cache_path): if os.path.exists(cache_path):
self.audiopaths = torch.load(cache_path) self.audiopaths = torch.load(cache_path)
else: else:
print("Building cache..") print("Building cache..")
self.audiopaths = find_files_of_type('img', opt['path'], qualifier=is_wav_file)[0] self.audiopaths = []
for p in self.path:
self.audiopaths.extend(find_files_of_type('img', p, qualifier=is_wav_file)[0])
torch.save(self.audiopaths, cache_path) torch.save(self.audiopaths, cache_path)
# Parse options # Parse options

View File

@ -23,7 +23,7 @@ if __name__ == '__main__':
separator = Separator('spleeter:2stems') separator = Separator('spleeter:2stems')
files = find_audio_files(src_dir, include_nonwav=True) files = find_audio_files(src_dir, include_nonwav=True)
for e, file in enumerate(tqdm(files)): for e, file in enumerate(tqdm(files)):
if e < 575: if e < 3055:
continue continue
file_basis = osp.relpath(file, src_dir)\ file_basis = osp.relpath(file, src_dir)\
.replace('/', '_')\ .replace('/', '_')\
@ -56,7 +56,7 @@ if __name__ == '__main__':
bmax = np.abs(bg).mean() bmax = np.abs(bg).mean()
# Only output to the "good" sample dir if the ratio of background noise to vocal noise is high enough. # Only output to the "good" sample dir if the ratio of background noise to vocal noise is high enough.
ratio = vmax / bmax ratio = vmax / (bmax+.0000001)
if ratio >= 25: # These values were derived empirically if ratio >= 25: # These values were derived empirically
od = output_dir od = output_dir
os = clip os = clip