code: def make_segment(file_id, tempo, notes, threshold, sil=["P", "B"]):
      segments = []
      segment = SegInfo()
      for i in range(len(notes)):
          # Divide songs by 'P' (pause) or 'B' (breath) or GlottalStop
          note = notes[i]
          # fix errors in dataset
          # remove rest note
          if (
              (
                  "i_vow_to_thee_my_country" in file_id
                  and note.lyric in sil
                  and notes[i + 1].lyric == "ろ"
              )
              or (
                  "shabondama" in file_id
                  and note.lyric in sil
                  and notes[i + 1].lyric == "だ"
              )
              or (
                  "kusakeiba" in file_id
                  and note.lyric in sil
                  and notes[i - 3].lyric == "’い"
              )
          ):
              notes[i + 1].st = note.st
              continue
          if note.lyric in sil:
              if len(segment.segs) > 0:
                  segments.extend(segment.split(threshold=threshold))
                  segment = SegInfo()
              continue
          # add pause (split)
          elif (
              (note.lyric is not None and note.lyric[0] in ["・", "’"])
              or (
                  "hana" in file_id
                  and note.lyric == "あ"
                  and notes[i - 1].lyric == "や"
              )
              or (
                  "hana" in file_id
                  and note.lyric == "も"
                  and notes[i - 1].lyric == "に"
              )
              or (
                  "santa_lucia" in file_id
                  and note.lyric == "な"
                  and notes[i - 1].lyric == "わ"
              )
              or (
                  "santa_lucia" in file_id
                  and note.lyric == "そ"
                  and notes[i - 8].lyric == "ぜ"
              )
              or (
                  "furusato" in file_id
                  and note.lyric == "か"
                  and notes[i + 2].lyric == "か"
              )
              or (
                  "aria" in file_id
                  and note.lyric == "でぃ"
                  and notes[i - 1].lyric == "い"
              )
              or (
                  "aria" in file_id
                  and note.lyric == "ぷ"
                  and notes[i - 1].lyric == "じ"
              )
              or (
                  "antagata_dokosa" in file_id
                  and notes[i - 1].lyric == "さ"
                  and notes[i - 2].lyric != "こ"
              )
              or (
                  "kusakeiba" in file_id
                  and note.lyric == "どぅ"
                  and notes[i - 1].lyric == "ぎ"
              )
          ):
              if len(segment.segs) > 0:
                  segments.extend(segment.split(threshold=threshold))
                  segment = SegInfo()
              # remove spcial mark
              if note.lyric[0] in ["・", "’"]:
                  segment.add(
                      note.st, note.et, note.lyric[1:], note.midi
                  )
              else:
                  segment.add(note.st, note.et, note.lyric, note.midi)
              continue
          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/ameboshi/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