code: def load_and_process_transcriptions(
      src_data, transcriptions_path, song_folder
  ):
      # Step 1: Load the WAV file and the transcription file
      transcriptions = (
          open(transcriptions_path, "r", encoding="utf-8")
          .read()
          .strip()
          .split("\n")
      )
      midi_obj = miditoolkit.midi.parser.MidiFile(
          os.path.join(
              src_data,
              "raw_data",
              "midis",
              "{}.midi".format(song_folder),
          )
      )
      midi_notes = []
      midis = []
      tempo = midi_obj.tempo_changes[0].tempo
      ppq = midi_obj.ticks_per_beat
      # Populate the list with start and end times of each note
      for note in midi_obj.instruments[0].notes:
          start_time = note.start * 60000 / tempo / ppq
          end_time = note.end * 60000 / tempo / ppq
          midi_notes.append((start_time, end_time))
          pitch = note.pitch
          midis.append(pitch)
      # Step 2: Split the content in each row to name, lyrics, phns, pitch, duration,
      # is_slur by |
      parsed_transcriptions = [row.split("|") for row in transcriptions]
  
      # Step 3: Find all the rows' corresponding name in the txt file starting with 2001
      relevant_transcriptions = [
          row
          for row in parsed_transcriptions
          if row[0].startswith(str(song_folder))
      ]
  
      # Step 4: Sum the duration of each file to get the total duration of each subfile
      total_durations = {}
      total_pitches = {}
      for row in relevant_transcriptions:
          name, _, phns, pitches, _, duration, _ = row
          phns = phns.split(" ")
          duration = duration.split(" ")
          pitches = pitches.split(" ")
          while phns[-1] == "AP" or phns[-1] == "SP":
              phns = phns[:-1]
              duration = duration[:-1]
          if phns[0] == "SP" or phns[0] == "AP":
              phns = phns[1:]
              duration = duration[1:]
              pitches = pitches[1:]
  
          # sum duration by the string of durations, first split the string by space,
          # then convert the string to float, then sum the float
          total_durations[name] = (
              sum(float(d) for d in duration) * 1000
          )  # Convert to milliseconds
          total_pitches[name] = pitches
      return total_durations, total_pitches, midi_notes, midis
  
imports: import argparse
  import logging
  import os
  import re
  import shutil
  import librosa
  import miditoolkit
  import numpy
  from tqdm import tqdm
  from espnet2.fileio.score_scp import SingingScoreWriter
label_desc: Use image node_id 5 for calling a global function with example usage: load_and_process_transcriptions(src_data, transcriptions_path, song_folder) and returns: total_durations,  total_pitches,  midi_notes,  midis