remove unused embeddings export

This commit is contained in:
Edresson 2021-05-27 19:10:24 -03:00
parent 1496f271dc
commit 825734a3a9
1 changed files with 3 additions and 6 deletions

View File

@ -22,7 +22,7 @@ parser.add_argument(
help="Path to config file for training.",
)
parser.add_argument("data_path", type=str, help="Data path for wav files - directory or CSV file")
parser.add_argument("output_path", type=str, help="path for training outputs.")
parser.add_argument("output_path", type=str, help="path for output speakers.json.")
parser.add_argument(
"--target_dataset",
type=str,
@ -47,7 +47,6 @@ if args.target_dataset != "":
BaseDatasetConfig(name=args.target_dataset, path=args.data_path, meta_file_train=None, meta_file_val=None),
]
wav_files, _ = load_meta_data(dataset_config, eval_split=False)
output_files = [wav_file[1].replace(data_path, args.output_path).replace(".wav", ".npy") for wav_file in wav_files]
else:
# if target dataset is not defined
if len(split_ext) > 0 and split_ext[1].lower() == ".csv":
@ -71,10 +70,8 @@ else:
# Parse all wav files in data_path
wav_files = glob.glob(data_path + "/**/*.wav", recursive=True)
output_files = [wav_file.replace(data_path, args.output_path).replace(".wav", ".npy") for wav_file in wav_files]
for output_file in output_files:
os.makedirs(os.path.dirname(output_file), exist_ok=True)
os.makedirs(args.output_path, exist_ok=True)
# define Encoder model
model = setup_model(c)
@ -96,7 +93,6 @@ for idx, wav_file in enumerate(tqdm(wav_files)):
mel_spec = mel_spec.cuda()
embedd = model.compute_embedding(mel_spec)
embedd = embedd.detach().cpu().numpy()
np.save(output_files[idx], embedd)
if args.target_dataset != "":
# create speaker_mapping if target dataset is defined
@ -110,3 +106,4 @@ if args.target_dataset != "":
# save speaker_mapping if target dataset is defined
mapping_file_path = os.path.join(args.output_path, "speakers.json")
save_speaker_mapping(args.output_path, speaker_mapping)
print("Speaker embedding saved at:", mapping_file_path)