code: def input_interface(data_root, roi_json_dir):
      fps = 25
  
      video_dic = {}
      with codecs.open(
          os.path.join(data_root, "mp4.scp"), "r"
      ) as handle:
          lines_content = handle.readlines()
      for video_line in [
          *map(
              lambda x: x[:-1] if x[-1] in ["\n"] else x, lines_content
          )
      ]:
          name, path = video_line.split(" ")
          video_dic[name] = path
  
      vid2spk_dic = {}
      with codecs.open(
          os.path.join(data_root, "vid2spk"), "r"
      ) as handle:
          lines_content = handle.readlines()
      for vid2spk_line in [
          *map(
              lambda x: x[:-1] if x[-1] in ["\n"] else x, lines_content
          )
      ]:
          name, speaker = vid2spk_line.split(" ")
          vid2spk_dic[name] = int(speaker[1:])
  
      segments_dic = {}
      with codecs.open(
          os.path.join(data_root, "segments"), "r"
      ) as handle:
          lines_content = handle.readlines()
      for segment_line in [
          *map(
              lambda x: x[:-1] if x[-1] in ["\n"] else x, lines_content
          )
      ]:
          segment_name, name, start, end = segment_line.split(" ")
          if video_dic[name] not in segments_dic:
              segments_dic[video_dic[name]] = {
                  "roi_json_path": os.path.join(
                      roi_json_dir, "{}.json".format(name)
                  ),
                  "segments_name": [segment_name],
                  "segments_speaker": [vid2spk_dic[segment_name]],
                  "segments_start": [
                      int(np.around(float(start) * fps))
                  ],
                  "segments_end": [int(np.around(float(end) * fps))],
              }
          else:
              segments_dic[video_dic[name]]["segments_name"].append(
                  segment_name
              )
              segments_dic[video_dic[name]]["segments_speaker"].append(
                  vid2spk_dic[segment_name]
              )
              segments_dic[video_dic[name]]["segments_start"].append(
                  int(np.around(float(start) * fps))
              )
              segments_dic[video_dic[name]]["segments_end"].append(
                  int(np.around(float(end) * fps))
              )
  
      return segments_dic
  
file_path: espnet/egs2/misp2021/avsr1/local/prepare_far_video_roi.py
imports: import argparse
  import codecs
  import json
  import os
  import time
  from multiprocessing import Pool
  import cv2
  import numpy
  from tqdm import tqdm
label_desc: Use image node_id 5 for calling a global function with example usage: input_interface(data_root, roi_json_dir) and returns: segments_dic