vocoder_train.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import argparse
  2. from pathlib import Path
  3. from utils.argutils import print_args
  4. from vocoder.train import train
  5. if __name__ == "__main__":
  6. parser = argparse.ArgumentParser(
  7. description="Trains the vocoder from the synthesizer audios and the GTA synthesized mels, "
  8. "or ground truth mels.",
  9. formatter_class=argparse.ArgumentDefaultsHelpFormatter
  10. )
  11. parser.add_argument("run_id", type=str, help= \
  12. "Name for this model. By default, training outputs will be stored to saved_models/<run_id>/. If a model state "
  13. "from the same run ID was previously saved, the training will restart from there. Pass -f to overwrite saved "
  14. "states and restart from scratch.")
  15. parser.add_argument("datasets_root", type=Path, help= \
  16. "Path to the directory containing your SV2TTS directory. Specifying --syn_dir or --voc_dir "
  17. "will take priority over this argument.")
  18. parser.add_argument("--syn_dir", type=Path, default=argparse.SUPPRESS, help= \
  19. "Path to the synthesizer directory that contains the ground truth mel spectrograms, "
  20. "the wavs and the embeds. Defaults to <datasets_root>/SV2TTS/synthesizer/.")
  21. parser.add_argument("--voc_dir", type=Path, default=argparse.SUPPRESS, help= \
  22. "Path to the vocoder directory that contains the GTA synthesized mel spectrograms. "
  23. "Defaults to <datasets_root>/SV2TTS/vocoder/. Unused if --ground_truth is passed.")
  24. parser.add_argument("-m", "--models_dir", type=Path, default="saved_models", help=\
  25. "Path to the directory that will contain the saved model weights, as well as backups "
  26. "of those weights and wavs generated during training.")
  27. parser.add_argument("-g", "--ground_truth", action="store_true", help= \
  28. "Train on ground truth spectrograms (<datasets_root>/SV2TTS/synthesizer/mels).")
  29. parser.add_argument("-s", "--save_every", type=int, default=1000, help= \
  30. "Number of steps between updates of the model on the disk. Set to 0 to never save the "
  31. "model.")
  32. parser.add_argument("-b", "--backup_every", type=int, default=25000, help= \
  33. "Number of steps between backups of the model. Set to 0 to never make backups of the "
  34. "model.")
  35. parser.add_argument("-f", "--force_restart", action="store_true", help= \
  36. "Do not load any saved model and restart from scratch.")
  37. args = parser.parse_args()
  38. # Process the arguments
  39. if not hasattr(args, "syn_dir"):
  40. args.syn_dir = args.datasets_root / "SV2TTS" / "synthesizer"
  41. if not hasattr(args, "voc_dir"):
  42. args.voc_dir = args.datasets_root / "SV2TTS" / "vocoder"
  43. del args.datasets_root
  44. args.models_dir.mkdir(exist_ok=True)
  45. # Run the training
  46. print_args(args, parser)
  47. train(**vars(args))