forked from OlaWod/FreeVC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preprocess_flist.py
51 lines (42 loc) · 1.72 KB
/
preprocess_flist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import argparse
from tqdm import tqdm
from random import shuffle
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--train_list", type=str, default="./filelists/train.txt", help="path to train list")
parser.add_argument("--val_list", type=str, default="./filelists/val.txt", help="path to val list")
parser.add_argument("--test_list", type=str, default="./filelists/test.txt", help="path to test list")
parser.add_argument("--source_dir", type=str, default="./dataset/vctk-16k", help="path to source dir")
args = parser.parse_args()
train = []
val = []
test = []
idx = 0
for speaker in tqdm(os.listdir(args.source_dir)):
wavs = os.listdir(os.path.join(args.source_dir, speaker))
shuffle(wavs)
train += wavs[2:-10]
val += wavs[:2]
test += wavs[-10:]
shuffle(train)
shuffle(val)
shuffle(test)
print("Writing", args.train_list)
with open(args.train_list, "w") as f:
for fname in tqdm(train):
speaker = fname[:4]
wavpath = os.path.join("DUMMY", speaker, fname)
f.write(wavpath + "\n")
print("Writing", args.val_list)
with open(args.val_list, "w") as f:
for fname in tqdm(val):
speaker = fname[:4]
wavpath = os.path.join("DUMMY", speaker, fname)
f.write(wavpath + "\n")
print("Writing", args.test_list)
with open(args.test_list, "w") as f:
for fname in tqdm(test):
speaker = fname[:4]
wavpath = os.path.join("DUMMY", speaker, fname)
f.write(wavpath + "\n")