arg_parser.py 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # *****************************************************************************
  2. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. # * Redistributions of source code must retain the above copyright
  7. # notice, this list of conditions and the following disclaimer.
  8. # * Redistributions in binary form must reproduce the above copyright
  9. # notice, this list of conditions and the following disclaimer in the
  10. # documentation and/or other materials provided with the distribution.
  11. # * Neither the name of the NVIDIA CORPORATION nor the
  12. # names of its contributors may be used to endorse or promote products
  13. # derived from this software without specific prior written permission.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. # DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
  19. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. #
  26. # *****************************************************************************
  27. import argparse
  28. def parse_waveglow_args(parent, add_help=False):
  29. """
  30. Parse commandline arguments.
  31. """
  32. parser = argparse.ArgumentParser(parents=[parent], add_help=add_help)
  33. # misc parameters
  34. parser.add_argument('--n-mel-channels', default=80, type=int,
  35. help='Number of bins in mel-spectrograms')
  36. # glow parameters
  37. parser.add_argument('--flows', default=12, type=int,
  38. help='Number of steps of flow')
  39. parser.add_argument('--groups', default=8, type=int,
  40. help='Number of samples in a group processed by the steps of flow')
  41. parser.add_argument('--early-every', default=4, type=int,
  42. help='Determines how often (i.e., after how many coupling layers) \
  43. a number of channels (defined by --early-size parameter) are output\
  44. to the loss function')
  45. parser.add_argument('--early-size', default=2, type=int,
  46. help='Number of channels output to the loss function')
  47. parser.add_argument('--sigma', default=1.0, type=float,
  48. help='Standard deviation used for sampling from Gaussian')
  49. parser.add_argument('--segment-length', default=8000, type=int,
  50. help='Segment length (audio samples) processed per iteration')
  51. # wavenet parameters
  52. wavenet = parser.add_argument_group('WaveNet parameters')
  53. wavenet.add_argument('--wn-kernel-size', default=3, type=int,
  54. help='Kernel size for dialted convolution in the affine coupling layer (WN)')
  55. wavenet.add_argument('--wn-channels', default=256, type=int,
  56. help='Number of channels in WN')
  57. wavenet.add_argument('--wn-layers', default=8, type=int,
  58. help='Number of layers in WN')
  59. return parser