From 67b417fdf93d84e4c2b2f54a63d0639a86922ef2 Mon Sep 17 00:00:00 2001 From: litagin02 Date: Sat, 30 Dec 2023 14:33:58 +0900 Subject: [PATCH] Feat: make default style when training (WIP) --- make_default_style.py | 17 +++++++++++++++++ style_gen.py | 9 +++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 make_default_style.py diff --git a/make_default_style.py b/make_default_style.py new file mode 100644 index 0000000..ca708f6 --- /dev/null +++ b/make_default_style.py @@ -0,0 +1,17 @@ +import os +import numpy as np +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("--wav_dir", type=str, default="data/wav") + +embs = [] +names = [] +for file in os.listdir(wav_dir): + if file.endswith(".npy"): + xvec = np.load(os.path.join(wav_dir, file)) + embs.append(np.expand_dims(xvec, axis=0)) + names.append(file) + +x = np.concatenate(embs, axis=0) +x = np.squeeze(x) diff --git a/style_gen.py b/style_gen.py index 7312bd2..0d5006d 100644 --- a/style_gen.py +++ b/style_gen.py @@ -25,8 +25,13 @@ def extract_style_vector(wav_path): def save_style_vector(wav_path): style_vec = extract_style_vector(wav_path) - # `test.wav` -> `test.wav.npy` - np.save(f"{wav_path}.npy", style_vec) + np.save(f"{wav_path}.npy", style_vec) # `test.wav` -> `test.wav.npy` + return style_vec + + +def save_average_style_vector(style_vectors, filename="style_vectors.npy"): + average_vector = np.mean(style_vectors, axis=0) + np.save(filename, average_vector) if __name__ == "__main__":