code: def process_utterance(
      writer,
      wavscp,
      text,
      utt2spk,
      label,
      audio_dir,
      wav_dumpdir,
      segment,
      tgt_sr=24000,
  ):
      name = segment["item_name"]
      lyrics = segment["txt"]
      phns = segment["phs"]
      midis = segment["notes"]
      syb_dur = segment["notes_dur"]
      phn_dur = segment["ph_dur"]
      keep = segment["is_slur"]
      spk = name.split("#")[0]
  
      # load tempo from midi
      uid = name.encode("unicode_escape").decode().replace("\\u", "#U")
      song_name = uid[: uid.rindex("#")]
      uid = uid.replace(" ", "+")
  
      text.write("m4singer_{} {}\n".format(uid, " ".join(phns)))
      utt2spk.write("m4singer_{} {}\n".format(uid, spk))
  
      # apply bit convert, there is a known issue in direct convert in format wavscp
      cmd = "sox {}.wav -c 1 -t wavpcm -b 16 -r {} {}/m4singer_{}.wav".format(
          os.path.join(
              audio_dir,
              song_name.replace(" ", "\\ "),
              uid.replace("+", "\\ ").split("#")[-1],
          ),
          tgt_sr,
          wav_dumpdir,
          uid,
      )
      os.system(cmd)
      wavscp.write(
          "m4singer_{} {}/m4singer_{}.wav\n".format(
              uid, wav_dumpdir, uid
          )
      )
  
      # write annotation duration info into label
      running_dur = 0
      assert len(phn_dur) == len(phns)
      label_entry = []
      for i in range(len(phns)):
          start = running_dur
          end = running_dur + phn_dur[i]
          label_entry.append(
              "{:.3f} {:.3f} {}".format(start, end, phns[i])
          )
          running_dur += phn_dur[i]
      label.write("m4singer_{} {}\n".format(uid, " ".join(label_entry)))
  
      # load tempo from midi
      tempo = load_midi(args, uid.replace("+", " "), song_name)
  
      # prepare music score
      note_list = create_score(uid, phns, midis, syb_dur, keep)
      score = dict(
          tempo=tempo,
          item_list=["st", "et", "lyric", "midi", "phns"],
          note=note_list,
      )
      writer["m4singer_{}".format(uid)] = score
  
file_path: espnet/egs2/m4singer/svs1/local/data_prep.py
imports: import argparse
  import json
  import os
  import random
  import shutil
  import librosa
  import miditoolkit
  import numpy
  from espnet2.fileio.score_scp import SingingScoreWriter
label_desc: Use image node_id 4 for calling a global function with example usage: process_utterance(writer, wavscp, text, utt2spk, label, audio_dir, wav_dumpdir, segment, tgt_sr) without return types