code: def main():
      """Make rttm based on diarization inference results"""
      args = get_parser().parse_args()
      sampling_rate = humanfriendly.parse_size(args.sampling_rate)
      # logging info
      if args.verbose > 1:
          logging.basicConfig(
              level=logging.DEBUG,
              format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
          )
      elif args.verbose > 0:
          logging.basicConfig(
              level=logging.INFO,
              format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
          )
      else:
          logging.basicConfig(
              level=logging.WARN,
              format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
          )
          logging.warning("Skip DEBUG/INFO messages")
  
      scp_reader = NpyScpReader(args.diarize_scp)
  
      with open(args.out_rttm_file, "w") as wf:
          for key in scp_reader.keys():
              data = scp_reader[key]
              a = np.where(data[:] > args.threshold, 1, 0)
              if args.median > 1:
                  a = medfilt(a, (args.median, 1))
              factor = (
                  args.frame_shift * args.subsampling / sampling_rate
              )
              for spkid, frames in enumerate(a.T):
                  frames = np.pad(frames, (1, 1), "constant")
                  (changes,) = np.where(np.diff(frames, axis=0) != 0)
                  fmt = "SPEAKER {:s} 1 {:7.2f} {:7.2f} <NA> <NA> {:s} <NA>"
                  for s, e in zip(changes[::2], changes[1::2]):
                      print(
                          fmt.format(
                              key,
                              s * factor,
                              (e - s) * factor,
                              key + "_" + str(spkid),
                          ),
                          file=wf,
                      )
  
      logging.info("Constructed RTTM for {}".format(args.diarize_scp))
  
file_path: espnet/egs2/mucs21_subtask1/asr1/pyscripts/utils/make_rttm.py
imports: import argparse
  import logging
  import humanfriendly
  import numpy
  from scipy.signal import medfilt
  from espnet2.fileio.npy_scp import NpyScpReader
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types