Skip to content

Commit

Permalink
don't generate already-generated train/test files
Browse files Browse the repository at this point in the history
  • Loading branch information
kwikwag committed Feb 8, 2020
1 parent 36b59da commit f904559
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions generator.py
Expand Up @@ -24,8 +24,14 @@ def vad_merge(w):


def mix(hp, args, audio, num, s1_dvec, s1_target, s2, train):
srate = hp.audio.sample_rate
dir_ = os.path.join(args.out_dir, 'train' if train else 'test')
dvec_text_path = formatter(dir_, hp.form.dvec, num)

# if output file already exists, skip
if os.path.isfile(dvec_text_path):
return

srate = hp.audio.sample_rate

d, _ = librosa.load(s1_dvec, sr=srate)
w1, _ = librosa.load(s1_target, sr=srate)
Expand Down Expand Up @@ -74,7 +80,6 @@ def mix(hp, args, audio, num, s1_dvec, s1_target, s2, train):
torch.save(torch.from_numpy(mixed_mag), mixed_mag_path)

# save selected sample as text file. d-vec will be calculated soon
dvec_text_path = formatter(dir_, hp.form.dvec, num)
with open(dvec_text_path, 'w') as f:
f.write(s1_dvec)

Expand Down Expand Up @@ -150,6 +155,6 @@ def test_wrapper(num):
with Pool(cpu_num) as p:
r = list(tqdm.tqdm(p.imap(train_wrapper, arr), total=len(arr)))

arr = list(range(10**2))
arr = list(range(10**3))
with Pool(cpu_num) as p:
r = list(tqdm.tqdm(p.imap(test_wrapper, arr), total=len(arr)))

0 comments on commit f904559

Please sign in to comment.