class_docstr: SeparateSpeech class
  
  Examples:
      >>> import soundfile
      >>> separate_speech = SeparateSpeech("enh_config.yml", "enh.pth")
      >>> audio, rate = soundfile.read("speech.wav")
      >>> separate_speech(audio)
      [separated_audio1, separated_audio2, ...]
class_docstr_tok: ["SeparateSpeech","class","Examples",":",">",">",">","import","soundfile",">",">",">","separate_speech","=","SeparateSpeech","(","``","enh_config.yml","''",",","``","enh.pth","''",")",">",">",">","audio",",","rate","=","soundfile.read","(","``","speech.wav","''",")",">",">",">","separate_speech","(","audio",")","[","separated_audio1",",","separated_audio2",",","...","]"]
code: def __init__(
      self,
      train_config: Union[Path, str] = None,
      model_file: Union[Path, str] = None,
      inference_config: Union[Path, str] = None,
      segment_size: Optional[float] = None,
      hop_size: Optional[float] = None,
      normalize_segment_scale: bool = False,
      show_progressbar: bool = False,
      ref_channel: Optional[int] = None,
      normalize_output_wav: bool = False,
      device: str = "cpu",
      dtype: str = "float32",
  ):
      assert check_argument_types()
  
      # 1. Build Enh model
      if inference_config is None:
          (
              enh_model,
              enh_train_args,
          ) = TSETask.build_model_from_file(
              train_config, model_file, device
          )
      else:
          # Overwrite model attributes
          train_config = get_train_config(
              train_config, model_file=model_file
          )
          with train_config.open("r", encoding="utf-8") as f:
              train_args = yaml.safe_load(f)
  
          with Path(inference_config).open("r", encoding="utf-8") as f:
              infer_args = yaml.safe_load(f)
  
          supported_keys = list(
              chain(
                  *[
                      [k, k + "_conf"]
                      for k in ("encoder", "extractor", "decoder")
                  ]
              )
          )
          for k in infer_args.keys():
              if k not in supported_keys:
                  raise ValueError(
                      "Only the following top-level keys are supported: %s"
                      % ", ".join(supported_keys)
                  )
  
          recursive_dict_update(train_args, infer_args, verbose=True)
          enh_train_args = argparse.Namespace(**train_args)
          enh_model = build_model_from_args_and_file(
              TSETask, enh_train_args, model_file, device
          )
  
      enh_model.to(dtype=getattr(torch, dtype)).eval()
  
      self.device = device
      self.dtype = dtype
      self.enh_train_args = enh_train_args
      self.enh_model = enh_model
  
      # only used when processing long speech, i.e.
      # segment_size is not None and hop_size is not None
      self.segment_size = segment_size
      self.hop_size = hop_size
      self.normalize_segment_scale = normalize_segment_scale
      self.normalize_output_wav = normalize_output_wav
      self.show_progressbar = show_progressbar
  
      self.num_spk = enh_model.num_spk
      task = f"{self.num_spk}-speaker extraction"
  
      # reference channel for processing multi-channel speech
      if ref_channel is not None:
          logging.info(
              "Overwrite enh_model.extractor.ref_channel with {}".format(
                  ref_channel
              )
          )
          enh_model.extractor.ref_channel = ref_channel
          self.ref_channel = ref_channel
      else:
          self.ref_channel = enh_model.ref_channel
  
      self.segmenting = (
          segment_size is not None and hop_size is not None
      )
      if self.segmenting:
          logging.info("Perform segment-wise speech %s" % task)
          logging.info(
              "Segment length = {} sec, hop length = {} sec".format(
                  segment_size, hop_size
              )
          )
      else:
          logging.info("Perform direct speech %s on the input" % task)
  
imports: import argparse
  import logging
  import sys
  from itertools import chain
  from pathlib import Path
  from typing import Any, List, Optional, Sequence, Tuple, Union
  import humanfriendly
  import numpy
  import torch
  import yaml
  from tqdm import trange
  from typeguard import check_argument_types
  from espnet2.enh.loss.criterions.tf_domain import FrequencyDomainMSE
  from espnet2.enh.loss.criterions.time_domain import SISNRLoss
  from espnet2.enh.loss.wrappers.pit_solver import PITSolver
  from espnet2.fileio.sound_scp import SoundScpWriter
  from espnet2.tasks.enh_tse import TargetSpeakerExtractionTask
  from espnet2.torch_utils.device_funcs import to_device
  from espnet2.torch_utils.set_all_random_seed import set_all_random_seed
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  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 SeparateSpeech object  with example: obj = SeparateSpeech(train_config, model_file, inference_config, segment_size, hop_size, normalize_segment_scale, show_progressbar, ref_channel, normalize_output_wav, device, dtype)