code: def segment_dataset(args):
      root_path = os.path.join(
          args.src_data.replace("/tmp", ""), "segments"
      )
      output_path = os.path.join(root_path, "wav")
      if not os.path.exists(output_path):
          os.makedirs(output_path)
      transcript_filepath = os.path.join(
          root_path, "transcriptions.txt"
      )
  
      transcript_file = open(transcript_filepath, "w")
      for subdir in os.listdir(args.src_data):
          # check if subdir has files
          if not os.listdir(os.path.join(args.src_data, subdir)):
              continue
          if subdir == "segments":
              continue
          full_subdir_path = os.path.join(args.src_data, subdir)
  
          if os.path.isdir(full_subdir_path) and "-unseg" not in subdir:
              print(f"Processing: {full_subdir_path}")
              songid = subdir
              # skip between 436 and 440
              if (
                  int(songid.split("-")[0]) <= 440
                  and int(songid.split("-")[0]) >= 436
              ):
                  continue
              wav_files = glob.glob(
                  os.path.join(full_subdir_path, "*.wav")
              )
              midi_file = glob.glob(
                  os.path.join(full_subdir_path, "*.mid")
              )[0]
              partitions = get_partitions(midi_file)
              for wav_file in wav_files:
                  match = re.search(
                      r"([0-9-]+)-([a-zA-Z-]+)\.wav", wav_file
                  )
                  assert songid == match.group(1)
                  singer = match.group(2)
                  segids, wav_scp = save_wav_segments_from_partitions(
                      output_path, wav_file, partitions, songid, singer
                  )
                  (
                      lyrics,
                      phonemes,
                      pitches,
                      note_durations,
                      phn_durations,
                      is_slur,
                  ) = get_info_from_partitions(midi_file, partitions)
                  for i, segid in enumerate(segids):
                      filename = (
                          wav_scp[i][1].split("/")[-1].split(".")[0]
                      )
                      lyrics_str = " ".join(lyrics[i])
                      phonemes_str = " ".join(phonemes[i])
                      pitches_str = " ".join(
                          f"{pitch}" for pitch in pitches[i]
                      )
                      note_durations_str = " ".join(
                          f"{duration:.6f}"
                          for duration in note_durations[i]
                      )
                      phn_durations_str = " ".join(
                          f"{duration:.6f}"
                          for duration in phn_durations[i]
                      )
                      is_slur_str = " ".join(
                          f"{slur}" for slur in is_slur[i]
                      )
                      transcript_line = (
                          f"{filename}|{lyrics_str}|{phonemes_str}|"
                          f"{pitches_str}|{note_durations_str}|{phn_durations_str}|"
                          f"{is_slur_str}"
                      )
                      transcript_file.write(transcript_line + "\n")
      transcript_file.close()
      train_transcript_filepath = os.path.join(root_path, "train.txt")
      test_transcript_filepath = os.path.join(root_path, "test.txt")
      # loop through the transcript file and split into train and test based on song id
      with open(transcript_filepath, "r") as f:
          transcript = f.readlines()
          train_transcript = []
          test_transcript = []
          for line in transcript:
              song_id = line.split("|")[0].split("_")[0].split("-")[0]
              if int(song_id) > 440:
                  test_transcript.append(line)
              else:
                  train_transcript.append(line)
      with open(train_transcript_filepath, "w") as f:
          f.writelines(train_transcript)
      with open(test_transcript_filepath, "w") as f:
          f.writelines(test_transcript)
  
imports: import argparse
  import glob
  import logging
  import os
  import re
  import shutil
  import subprocess
  import wave
  from typing import List, TextIO, Tuple
  import miditoolkit
  import numpy
  from local.pinyin_dict import PINYIN_DICT
  from tqdm import tqdm
  from espnet2.fileio.score_scp import SingingScoreWriter
label_desc: Use image node_id 13 for calling a global function with example usage: segment_dataset(args) without return types