OUT_PATH = args.out_path QUANT_PATH = os.path.join(OUT_PATH, "quant/") MEL_PATH = os.path.join(OUT_PATH, "mel/") os.makedirs(OUT_PATH, exist_ok=True) os.makedirs(QUANT_PATH, exist_ok=True) os.makedirs(MEL_PATH, exist_ok=True) wav_files = get_files(SEG_PATH) print(" > Number of audio files : {}".format(len(wav_files))) wav_file = wav_files[1] m, quant, wav = process_file(wav_file) # save an example for sanity check if type(CONFIG.mode) is int: wav_hat = ap.dequantize(quant) librosa.output.write_wav(OUT_PATH + "test_converted_audio.wav", wav_hat, sr=CONFIG.audio['sample_rate']) shutil.copyfile(wav_files[1], OUT_PATH + "test_target_audio.wav") # This will take a while depending on size of dataset with Pool(args.num_procs) as p: dataset_ids = list( tqdm(p.imap(extract_feats, wav_files), total=len(wav_files))) # remove None items if args.ignore_errors: dataset_ids = [idx for idx in dataset_ids if idx is not None] # save metadata
# Point SEG_PATH to a folder containing your training wavs # Doesn't matter if it's LJspeech, CMU Arctic etc. it should work fine SEG_PATH = CONFIG.data_path OUT_PATH = os.path.join(CONFIG.out_path, CONFIG.run_name, "data/") QUANT_PATH = os.path.join(OUT_PATH, "quant/") MEL_PATH = os.path.join(OUT_PATH, "mel/") os.makedirs(OUT_PATH, exist_ok=True) os.makedirs(QUANT_PATH, exist_ok=True) os.makedirs(MEL_PATH, exist_ok=True) wav_files = get_files(SEG_PATH) print(" > Number of audio files : {}".format(len(wav_files))) wav_file = wav_files[1] m, x, wav = convert_file(wav_file) # save an example for sanity check x = ap.dequantize(x) librosa.output.write_wav( OUT_PATH + "test_converted_audio.wav", x, sr=CONFIG.audio['sample_rate'] ) shutil.copyfile(wav_files[1], OUT_PATH + "test_target_audio.wav") # This will take a while depending on size of dataset with Pool(8) as p: dataset_ids = list(tqdm(p.imap(process_wav, wav_files), total=len(wav_files))) # save metadata with open(os.path.join(OUT_PATH, "dataset_ids.pkl"), "wb") as f: pickle.dump(dataset_ids, f)