code: def main():
      parser = get_parser()
      args = parser.parse_args()
  
      logfmt = "%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s"
      if args.verbose > 0:
          logging.basicConfig(level=logging.INFO, format=logfmt)
      else:
          logging.basicConfig(level=logging.WARN, format=logfmt)
      logging.info(get_commandline_args())
  
      if args.preprocess_conf is not None:
          preprocessing = Transformation(args.preprocess_conf)
          logging.info("Apply preprocessing: {}".format(preprocessing))
      else:
          preprocessing = None
  
      with file_writer_helper(
          args.wspecifier,
          filetype=args.filetype,
          write_num_frames=args.write_num_frames,
          compress=args.compress,
          compression_method=args.compression_method,
          pcm_format=args.format,
      ) as writer:
          for utt_id, (rate, array) in kaldiio.ReadHelper(
              args.rspecifier, args.segments
          ):
              if args.filetype == "mat":
                  # Kaldi-matrix doesn't support integer
                  array = array.astype(numpy.float32)
  
              if array.ndim == 1:
                  # (Time) -> (Time, Channel)
                  array = array[:, None]
  
              if args.normalize is not None and args.normalize != 1:
                  array = array.astype(numpy.float32)
                  array = array / (1 << (args.normalize - 1))
  
              if preprocessing is not None:
                  orgtype = array.dtype
                  out = preprocessing(array, uttid_list=utt_id)
                  out = out.astype(orgtype)
  
                  if args.keep_length:
                      if len(out) > len(array):
                          out = numpy.pad(
                              out,
                              [(0, len(out) - len(array))]
                              + [(0, 0) for _ in range(out.ndim - 1)],
                              mode="constant",
                          )
                      elif len(out) < len(array):
                          # The length can be changed by stft, for example.
                          out = out[: len(out)]
  
                  array = out
  
              # shape = (Time, Channel)
              if args.filetype in ["sound.hdf5", "sound"]:
                  # Write Tuple[int, numpy.ndarray] (scipy style)
                  writer[utt_id] = (rate, array)
              else:
                  writer[utt_id] = array
  
file_path: espnet/utils/dump-pcm.py
imports: import argparse
  import logging
  from distutils.util import strtobool
  import kaldiio
  import numpy
  from espnet.transform.transformation import Transformation
  from espnet.utils.cli_utils import get_commandline_args
  from espnet.utils.cli_writers import file_writer_helper
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types