Add --max-speakers

This commit is contained in:
Michael Hansen 2023-05-17 16:34:27 -05:00
parent b87c930fa1
commit 87f249822f
2 changed files with 10 additions and 1 deletions

View file

@ -42,6 +42,8 @@ python3 generate_samples.py 'okay, piper.' --max-samples 100 --batch-size 10 --o
On an NVidia 2080 Ti with 11GB, a batch size of 100 was possible (generating approximately 100 samples per second).
Setting `--max-speakers` to a value less than 904 (the number if LibriTTS) is recommended. Because very few samples of later speakers were in the original dataset, using them can cause audio artifacts.
See `--help` for more options, including adjust the `--length-scales` (speaking speeds) and `--slerp-weights` (speaker blending) which are cycled per batch.
### Augmentation

View file

@ -30,6 +30,11 @@ def main() -> None:
parser.add_argument("--noise-scales", nargs="+", type=float, default=[0.667])
parser.add_argument("--noise-scale-ws", nargs="+", type=float, default=[0.8])
parser.add_argument("--output-dir", default="output")
parser.add_argument(
"--max-speakers",
type=int,
help="Maximum number of speakers to use (default: all)",
)
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG)
@ -53,6 +58,8 @@ def main() -> None:
voice = config["espeak"]["voice"]
sample_rate = config["audio"]["sample_rate"]
num_speakers = config["num_speakers"]
if args.max_speakers is not None:
num_speakers = min(num_speakers, args.max_speakers)
phonemizer = Phonemizer(voice)
phonemes_str = phonemizer.phonemize(args.text)
@ -83,7 +90,7 @@ def main() -> None:
)
)
speakers_iter = it.product(range(num_speakers), range(num_speakers))
speakers_iter = it.cycle(it.product(range(num_speakers), range(num_speakers)))
speakers_batch = list(it.islice(speakers_iter, 0, args.batch_size))
batch_idx = 0
while speakers_batch: