code: def make_segment(file_id, tempo, notes, threshold, sil=["P", "B"]):
      segments = []
      segment = SegInfo()
      for note in notes:
          # Divide songs by 'P' (pause) or 'B' (breath)
          if note.lyric in sil:
              if len(segment.segs) > 0:
                  segments.extend(segment.split(threshold=threshold))
                  segment = SegInfo()
              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/mini_librispeech/diar1/pyscripts/utils/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