code: def make_segment(file_id, tempo, notes, threshold, sil=["P", "B"]):
      segments = []
      segment = SegInfo()
      for i in range(len(notes)):
          note = notes[i]
          # fix errors in dataset
          # fix time
          if "itako48" in file_id:
              # correct note time
              if i == 43:
                  continue
              if i in range(39, 43):
                  note.et = notes[i + 1].et
              # correct rest to note with lyric
              if i == 142:
                  segments.extend(segment.split(threshold=threshold))
                  segment = SegInfo()
                  segment.add(45.0, 45.372, "た", 67)
                  segment.add(45.372, 45.46, "ち", 67)
                  segments.extend(segment.split(threshold=threshold))
                  segment = SegInfo()
          # remove rest note
          if "itako04" in file_id:
              if i in [
                  191,
                  193,
                  194,
                  195,
                  197,
                  199,
                  200,
                  201,
                  202,
                  203,
                  207,
              ]:
                  continue
              # correct timee
              if i == 198:
                  note.et = 81.572
              if i == 192:
                  note.et = 80.92
              # add missing lyric
              if i == 190:
                  note.lyric = "て"
              if i == 205:
                  note.lyric = "あ"
              if i == 208:
                  note.lyric = "ひ"
          # replace wrong note lyric with correct one
          if "itako02" in file_id and note.lyric == "—":
              note.lyric = "P"
          if (
              "itako22" in file_id
              and note.lyric == "ろ"
              and notes[i + 2].lyric == "こ"
          ):
              note.lyric = "お"
          if (
              "itako25" in file_id
              and note.lyric == "<Melodyne> Track 1"
          ):
              note.lyric = "じゃ"
          if "itako27" in file_id and note.lyric == "<Melodyne>":
              note.lyric = "すぃ"
          # Divide songs by 'P' (pause) or 'B' (breath)
          if note.lyric in sil:
              # remove rest note
              if i < len(notes) - 1 and (
                  (
                      "itako21" in file_id
                      and (
                          notes[i + 1].lyric == "び"
                          or notes[i + 2].lyric == "うぉ"
                          or notes[i + 1].lyric == "け"
                          or notes[i + 1].lyric == "だ"
                      )
                  )
                  or (
                      "itako04" in file_id and notes[i + 1].lyric == "こ"
                  )
              ):
                  notes[i + 1].st = note.st
                  continue
              if len(segment.segs) > 0:
                  segments.extend(segment.split(threshold=threshold))
                  segment = SegInfo()
              continue
          # add pause (split)
          if (
              "itako43" in file_id
              and note.lyric == "せ"
              and notes[i + 1].lyric == "い"
          ):
              segments.extend(segment.split(threshold=threshold))
              segment = SegInfo()
          segment.add(note.st, note.et, note.lyric, note.midi)
      if len(segment.segs) > 0:
          segments.extend(segment.split(threshold=threshold))
  
      segments_w_id = {}
      id = 0
      for seg in segments:
          if len(seg) == 0:
              continue
          segments_w_id[pack_zero(file_id, id)] = tempo, seg
          id += 1
      return segments_w_id
  
file_path: espnet/egs2/itako/svs1/local/prep_segments_from_xml.py
imports: import argparse
  import math
  import os
  import sys
  import music21
  from espnet2.fileio.score_scp import SingingScoreWriter, XMLReader
label_desc: Use image node_id 3 for calling a global function with example usage: make_segment(file_id, tempo, notes, threshold, sil) and returns: segments_w_id