code: def get_RTTM_per_rec(segs, spkrs_list, rec_id):
      """Prepares rttm for each recording"""
  
      rttm = []
  
      # Prepare header
      for spkr_id in spkrs_list:
          # e.g. SPKR-INFO ES2008c 0 <NA> <NA> <NA> unknown ES2008c.A_PM <NA> <NA>
          line = (
              "SPKR-INFO "
              + rec_id
              + " 0 <NA> <NA> <NA> unknown "
              + spkr_id
              + " <NA> <NA>"
          )
          rttm.append(line)
  
      # Append remaining lines
      for row in segs:
          # e.g. SPEAKER ES2008c 0 37.880 0.590 <NA> <NA> ES2008c.A_PM <NA> <NA>
  
          if float(row[1]) < float(row[0]):
              msg1 = (
                  "Possibly Incorrect Annotation Found!! transcriber_start (%s) > transcriber_end (%s)"
                  % (row[0], row[1])
              )
              msg2 = (
                  "Excluding this incorrect row from the RTTM : %s, %s, %s, %s"
                  % (
                      rec_id,
                      row[0],
                      str(round(float(row[1]) - float(row[0]), 4)),
                      str(row[2]),
                  )
              )
              logger.info(msg1)
              logger.info(msg2)
              continue
  
          line = (
              "SPEAKER "
              + rec_id
              + " 0 "
              + str(round(float(row[0]), 4))
              + " "
              + str(round(float(row[1]) - float(row[0]), 4))
              + " <NA> <NA> "
              + str(row[2])
              + " <NA> <NA>"
          )
          rttm.append(line)
  
      return rttm
  
file_path: speechbrain/recipes/AMI/Diarization/ami_prepare.py
imports: import os
  import logging
  import xml.etree.ElementTree
  import glob
  import json
  from ami_splits import get_AMI_split
  from speechbrain.dataio.dataio import load_pkl, save_pkl
label_desc: Use image node_id 2 for calling a global function with example usage: get_RTTM_per_rec(segs, spkrs_list, rec_id) and returns: rttm