class_docstr: SingingGenerate class
  
  Examples:
      >>> import soundfile
      >>> svs = SingingGenerate("config.yml", "model.pth")
      >>> wav = svs("Hello World")[0]
      >>> soundfile.write("out.wav", wav.numpy(), svs.fs, "PCM_16")
class_docstr_tok: ["SingingGenerate","class","Examples",":",">",">",">","import","soundfile",">",">",">","svs","=","SingingGenerate","(","``","config.yml","''",",","``","model.pth","''",")",">",">",">","wav","=","svs","(","``","Hello","World","''",")","[","0","]",">",">",">","soundfile.write","(","``","out.wav","''",",","wav.numpy","(",")",",","svs.fs",",","``","PCM_16","''",")"]
docstr: Initialize SingingGenerate module.
docstr_tok: ["Initialize","SingingGenerate","module","."]
code: def __init__(
      self,
      train_config: Optional[Union[Path, str]],
      model_file: Optional[Union[Path, str]] = None,
      threshold: float = 0.5,
      minlenratio: float = 0.0,
      maxlenratio: float = 10.0,
      use_teacher_forcing: bool = False,
      use_att_constraint: bool = False,
      use_dynamic_filter: bool = False,
      backward_window: int = 2,
      forward_window: int = 4,
      speed_control_alpha: float = 1.0,
      noise_scale: float = 0.667,
      noise_scale_dur: float = 0.8,
      vocoder_config: Union[Path, str] = None,
      vocoder_checkpoint: Union[Path, str] = None,
      dtype: str = "float32",
      device: str = "cpu",
      seed: int = 777,
      always_fix_seed: bool = False,
      prefer_normalized_feats: bool = False,
  ):
      """Initialize SingingGenerate module."""
      assert check_argument_types()
  
      # setup model
      model, train_args = SVSTask.build_model_from_file(
          train_config, model_file, device
      )
      model.to(dtype=getattr(torch, dtype)).eval()
      self.device = device
      self.dtype = dtype
      self.train_args = train_args
      self.model = model
      self.svs = model.svs
      self.normalize = model.normalize
      self.feats_extract = model.feats_extract
      self.duration_calculator = DurationCalculator()
      self.preprocess_fn = SVSTask.build_preprocess_fn(
          train_args, False
      )
      self.use_teacher_forcing = use_teacher_forcing
      self.seed = seed
      self.always_fix_seed = always_fix_seed
      self.vocoder = None
      self.prefer_normalized_feats = prefer_normalized_feats
      if vocoder_checkpoint is not None:
          vocoder = SVSTask.build_vocoder_from_file(
              vocoder_config, vocoder_checkpoint, model, device
          )
          if isinstance(vocoder, torch.nn.Module):
              vocoder.to(dtype=getattr(torch, dtype)).eval()
          self.vocoder = vocoder
  
      logging.info(f"Extractor:\n{self.feats_extract}")
      logging.info(f"Normalizer:\n{self.normalize}")
      logging.info(f"SVS:\n{self.svs}")
      if self.vocoder is not None:
          logging.info(f"Vocoder:\n{self.vocoder}")
  
      # setup decoding config
      decode_conf = {}
      decode_conf.update({"use_teacher_forcing": use_teacher_forcing})
      if isinstance(self.svs, VITS):
          decode_conf.update(
              noise_scale=noise_scale,
              noise_scale_dur=noise_scale_dur,
          )
      if isinstance(self.svs, singing_tacotron):
          decode_conf.update(
              threshold=threshold,
              maxlenratio=maxlenratio,
              minlenratio=minlenratio,
              use_att_constraint=use_att_constraint,
              use_dynamic_filter=use_dynamic_filter,
              forward_window=forward_window,
              backward_window=backward_window,
          )
      self.decode_conf = decode_conf
  
imports: import argparse
  import logging
  import shutil
  import sys
  import time
  from pathlib import Path
  from typing import Any, Dict, Optional, Sequence, Tuple, Union
  import numpy
  import soundfile
  import torch
  from typeguard import check_argument_types
  from espnet2.fileio.npy_scp import NpyScpWriter
  from espnet2.gan_svs.vits import VITS
  from espnet2.svs.singing_tacotron.singing_tacotron import singing_tacotron
  from espnet2.tasks.svs import SVSTask
  from espnet2.torch_utils.device_funcs import to_device
  from espnet2.torch_utils.set_all_random_seed import set_all_random_seed
  from espnet2.tts.utils import DurationCalculator
  from espnet2.utils import config_argparse
  from espnet2.utils.types import str2bool, str2triple_str, str_or_none
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 to create a new SingingGenerate object  with example: obj = SingingGenerate(train_config, model_file, threshold, minlenratio, maxlenratio, use_teacher_forcing, use_att_constraint, use_dynamic_filter, backward_window, forward_window, speed_control_alpha, noise_scale, noise_scale_dur, vocoder_config, vocoder_checkpoint, dtype, device, seed, always_fix_seed, prefer_normalized_feats)