forked from mrq/DL-Art-School
Enable multiple wavfile paths to be specified, fix eps bug in mp3 splitter
This commit is contained in:
parent
e19c00398e
commit
d0c74278bf
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user