Update preprocess_flist_config.py

This commit is contained in:
Stardust·减 2023-07-22 21:56:02 +08:00 committed by GitHub
parent 0f5847a64c
commit d07d92b61a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ import os
import re import re
import wave import wave
from random import shuffle from random import shuffle
from loguru import logger
from tqdm import tqdm from tqdm import tqdm
import diffusion.logger.utils as du import diffusion.logger.utils as du
@ -46,9 +46,9 @@ if __name__ == "__main__":
if not file.endswith("wav"): if not file.endswith("wav"):
continue continue
if not pattern.match(file): if not pattern.match(file):
print(f"warning文件名{file}中包含非字母数字下划线,可能会导致错误。(也可能不会)") logger.warning(f"文件名{file}中包含非字母数字下划线,可能会导致错误。(也可能不会)")
if get_wav_duration(file) < 0.3: if get_wav_duration(file) < 0.3:
print("skip too short audio:", file) logger.info("Skip too short audio:" + file)
continue continue
new_wavs.append(file) new_wavs.append(file)
wavs = new_wavs wavs = new_wavs
@ -59,13 +59,13 @@ if __name__ == "__main__":
shuffle(train) shuffle(train)
shuffle(val) shuffle(val)
print("Writing", args.train_list) logger.info("Writing" + args.train_list)
with open(args.train_list, "w") as f: with open(args.train_list, "w") as f:
for fname in tqdm(train): for fname in tqdm(train):
wavpath = fname wavpath = fname
f.write(wavpath + "\n") f.write(wavpath + "\n")
print("Writing", args.val_list) logger.info("Writing" + args.val_list)
with open(args.val_list, "w") as f: with open(args.val_list, "w") as f:
for fname in tqdm(val): for fname in tqdm(val):
wavpath = fname wavpath = fname
@ -97,8 +97,8 @@ if __name__ == "__main__":
if args.vol_aug: if args.vol_aug:
config_template["train"]["vol_aug"] = config_template["model"]["vol_embedding"] = True config_template["train"]["vol_aug"] = config_template["model"]["vol_embedding"] = True
print("Writing configs/config.json") logger.info("Writing to configs/config.json")
with open("configs/config.json", "w") as f: with open("configs/config.json", "w") as f:
json.dump(config_template, f, indent=2) json.dump(config_template, f, indent=2)
print("Writing configs/diffusion.yaml") logger.info("Writing to configs/diffusion.yaml")
du.save_config("configs/diffusion.yaml",d_config_template) du.save_config("configs/diffusion.yaml",d_config_template)