code: def prep_dipco(
      root_dir, out_dir, scoring_txt_normalization="chime7", eval_opt=0
  ):
      scoring_txt_normalization = choose_txt_normalization(
          scoring_txt_normalization
      )
  
      def normalize_dipco(annotation, txt_normalizer, eval_opt=0):
          annotation_scoring = []
  
          def _get_time(x):
              return (
                  dt.strptime(x, "%H:%M:%S.%f") - dt(1900, 1, 1)
              ).total_seconds()
  
          for indx in range(len(annotation)):
              ex = annotation[indx]
              ex["session_id"] = "S{:02d}".format(
                  dipco_offset + int(ex["session_id"].strip("S"))
              )
              ex["start_time"] = "{:.3f}".format(
                  _get_time(ex["start_time"]["U01"])
              )
              ex["end_time"] = "{:.3f}".format(
                  _get_time(ex["end_time"]["U01"])
              )
              ex["speaker"] = "P{:02d}".format(
                  dipco_offset + int(ex["speaker_id"].strip("P"))
              )
              del ex["speaker_id"]
              if eval_opt > 0:
                  new_ex = {}
                  for k in ex.keys():
                      if k in [
                          "speaker",
                          "start_time",
                          "end_time",
                          "words",
                          "session_id",
                      ]:
                          new_ex[k] = ex[k]
                  annotation[indx] = new_ex
                  ex = annotation[indx]
                  # cannot be used in inference
              ex_scoring = deepcopy(ex)
              ex_scoring["words"] = txt_normalizer(ex["words"])
              if eval_opt == 1:
                  ex[
                      "words"
                  ] = "placeholder"  # diarization only annotation
              if len(ex_scoring["words"]) > 0:
                  if eval_opt == 1:
                      ex_scoring[
                          "words"
                      ] = "placeholder"  # diarization only annotation
                  annotation_scoring.append(ex_scoring)
              # if empty remove segment from scoring
  
          return annotation, annotation_scoring
  
      if eval_opt > 0:
          splits = ["eval"]
      else:
          splits = ["dev"]
  
      for split in splits:
          # here same splits no need to remap
          Path(os.path.join(out_dir, "audio", split)).mkdir(
              parents=True, exist_ok=False
          )
          Path(os.path.join(out_dir, "transcriptions", split)).mkdir(
              parents=True, exist_ok=False
          )
          Path(
              os.path.join(out_dir, "transcriptions_scoring", split)
          ).mkdir(parents=True, exist_ok=True)
          json_dir = os.path.join(root_dir, "transcriptions", split)
          ann_json = glob.glob(os.path.join(json_dir, "*.json"))
          assert len(ann_json) > 0, (
              "DiPCo JSON annotation was not found in {}, please check if "
              "DiPCo data was downloaded correctly and the DiPCo main dir "
              "path is set correctly".format(json_dir)
          )
  
          # we also create audio files symlinks here
          audio_files = glob.glob(
              os.path.join(root_dir, "audio", split, "*.wav")
          )
          sess2audio = {}
          for x in audio_files:
              session_name = Path(x).stem.split("_")[0]
              if (
                  split == "eval"
                  and Path(x).stem.split("_")[-1].startswith("P")
                  and eval_opt != 2
              ):
                  continue
              if session_name not in sess2audio:
                  sess2audio[session_name] = [x]
              else:
                  sess2audio[session_name].append(x)
  
          # for each json file
          to_uem = []
          for j_file in ann_json:
              with open(j_file, "r") as f:
                  annotation = json.load(f)
              sess_name = Path(j_file).stem
  
              annotation, scoring_annotation = normalize_dipco(
                  annotation, scoring_txt_normalization, eval_opt
              )
  
              new_sess_name = "S{:02d}".format(
                  dipco_offset + int(sess_name.strip("S"))
              )
              # create symlinks too but swap names for the sessions too
              for x in sess2audio[sess_name]:
                  filename = (
                      new_sess_name
                      + "_"
                      + "_".join(Path(x).stem.split("_")[1:])
                  )
                  if filename.split("_")[1].startswith("P"):
                      speaker_id = filename.split("_")[1]
                      filename = filename.split("_")[
                          0
                      ] + "_P{:02d}".format(
                          dipco_offset + int(speaker_id.strip("P"))
                      )
                  os.symlink(
                      x,
                      os.path.join(
                          out_dir, "audio", split, filename + ".wav"
                      ),
                  )
  
              with open(
                  os.path.join(
                      out_dir,
                      "transcriptions",
                      split,
                      new_sess_name + ".json",
                  ),
                  "w",
              ) as f:
                  json.dump(annotation, f, indent=4)
              with open(
                  os.path.join(
                      out_dir,
                      "transcriptions_scoring",
                      split,
                      new_sess_name + ".json",
                  ),
                  "w",
              ) as f:
                  json.dump(scoring_annotation, f, indent=4)
  
              uem_start = 0
              uem_end = max(
                  [
                      sf.SoundFile(x).frames
                      for x in sess2audio[sess_name]
                  ]
              )
              c_uem = "{} 1 {} {}\n".format(
                  new_sess_name,
                  "{:.3f}".format(float(uem_start)),
                  "{:.3f}".format(float(uem_end / 16000)),
              )
              to_uem.append(c_uem)
  
          if len(to_uem) > 0:
              assert split in [
                  "dev",
                  "eval",
              ]  # uem only for development set
              Path(os.path.join(out_dir, "uem", split)).mkdir(
                  parents=True
              )
              to_uem = sorted(to_uem)
              with open(
                  os.path.join(out_dir, "uem", split, "all.uem"), "w"
              ) as f:
                  f.writelines(to_uem)
  
file_path: espnet/egs2/chime7_task1/asr1/local/gen_task1_data.py
imports: import argparse
  import glob
  import json
  import os
  from copy import deepcopy
  from datetime import datetime
  from pathlib import Path
  import jiwer
  import soundfile
  from jiwer.transforms import RemoveKaldiNonWords
  from lhotse.recipes.chime6 import TimeFormatConverter, normalize_text_chime6
label_desc: Use image node_id 5 for calling a global function with example usage: prep_dipco(root_dir, out_dir, scoring_txt_normalization, eval_opt) and returns: annotation,  annotation_scoring, unknown