2022-12-03 16:54:06 +08:00
|
|
|
from models.synthesizer.preprocess import preprocess_dataset
|
|
|
|
from models.synthesizer.hparams import hparams
|
2021-08-07 11:56:00 +08:00
|
|
|
from utils.argutils import print_args
|
|
|
|
from pathlib import Path
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
2021-08-11 23:33:43 +08:00
|
|
|
recognized_datasets = [
|
|
|
|
"aidatatang_200zh",
|
2021-08-17 20:55:28 +08:00
|
|
|
"magicdata",
|
2021-08-25 23:11:29 +08:00
|
|
|
"aishell3"
|
2021-08-11 23:33:43 +08:00
|
|
|
]
|
|
|
|
|
2021-08-07 11:56:00 +08:00
|
|
|
if __name__ == "__main__":
|
2021-09-11 22:59:09 +08:00
|
|
|
print("This method is deprecaded and will not be longer supported, please use 'pre.py'")
|
2021-08-07 11:56:00 +08:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="Preprocesses audio files from datasets, encodes them as mel spectrograms "
|
|
|
|
"and writes them to the disk. Audio files are also saved, to be used by the "
|
|
|
|
"vocoder for training.",
|
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
|
|
|
)
|
|
|
|
parser.add_argument("datasets_root", type=Path, help=\
|
|
|
|
"Path to the directory containing your LibriSpeech/TTS datasets.")
|
|
|
|
parser.add_argument("-o", "--out_dir", type=Path, default=argparse.SUPPRESS, help=\
|
|
|
|
"Path to the output directory that will contain the mel spectrograms, the audios and the "
|
|
|
|
"embeds. Defaults to <datasets_root>/SV2TTS/synthesizer/")
|
|
|
|
parser.add_argument("-n", "--n_processes", type=int, default=None, help=\
|
|
|
|
"Number of processes in parallel.")
|
|
|
|
parser.add_argument("-s", "--skip_existing", action="store_true", help=\
|
|
|
|
"Whether to overwrite existing files with the same name. Useful if the preprocessing was "
|
|
|
|
"interrupted.")
|
|
|
|
parser.add_argument("--hparams", type=str, default="", help=\
|
|
|
|
"Hyperparameter overrides as a comma-separated list of name-value pairs")
|
|
|
|
parser.add_argument("--no_trim", action="store_true", help=\
|
|
|
|
"Preprocess audio without trimming silences (not recommended).")
|
|
|
|
parser.add_argument("--no_alignments", action="store_true", help=\
|
|
|
|
"Use this option when dataset does not include alignments\
|
|
|
|
(these are used to split long audio files into sub-utterances.)")
|
2021-08-11 23:33:43 +08:00
|
|
|
parser.add_argument("--dataset", type=str, default="aidatatang_200zh", help=\
|
2021-08-17 20:55:28 +08:00
|
|
|
"Name of the dataset to process, allowing values: magicdata, aidatatang_200zh.")
|
2021-08-07 11:56:00 +08:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Process the arguments
|
|
|
|
if not hasattr(args, "out_dir"):
|
|
|
|
args.out_dir = args.datasets_root.joinpath("SV2TTS", "synthesizer")
|
2021-08-29 10:55:59 +08:00
|
|
|
assert args.dataset in recognized_datasets, 'is not supported, please vote for it in https://github.com/babysor/MockingBird/issues/10'
|
2021-08-07 11:56:00 +08:00
|
|
|
# Create directories
|
|
|
|
assert args.datasets_root.exists()
|
|
|
|
args.out_dir.mkdir(exist_ok=True, parents=True)
|
|
|
|
|
|
|
|
# Verify webrtcvad is available
|
|
|
|
if not args.no_trim:
|
|
|
|
try:
|
|
|
|
import webrtcvad
|
|
|
|
except:
|
|
|
|
raise ModuleNotFoundError("Package 'webrtcvad' not found. This package enables "
|
|
|
|
"noise removal and is recommended. Please install and try again. If installation fails, "
|
|
|
|
"use --no_trim to disable this error message.")
|
|
|
|
del args.no_trim
|
|
|
|
|
|
|
|
# Preprocess the dataset
|
|
|
|
print_args(args, parser)
|
|
|
|
args.hparams = hparams.parse(args.hparams)
|
2021-08-11 23:33:43 +08:00
|
|
|
|
|
|
|
preprocess_dataset(**vars(args))
|