Feat: make default style when training (WIP)

This commit is contained in:
litagin02
2023-12-30 14:33:58 +09:00
parent 255ac994ec
commit 67b417fdf9
2 changed files with 24 additions and 2 deletions

17
make_default_style.py Normal file
View File

@@ -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)

View File

@@ -25,8 +25,13 @@ def extract_style_vector(wav_path):
def save_style_vector(wav_path): def save_style_vector(wav_path):
style_vec = extract_style_vector(wav_path) style_vec = extract_style_vector(wav_path)
# `test.wav` -> `test.wav.npy` np.save(f"{wav_path}.npy", style_vec) # `test.wav` -> `test.wav.npy`
np.save(f"{wav_path}.npy", style_vec) 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__": if __name__ == "__main__":