code: def process_utterance(
      writer,
      wavscp,
      text,
      utt2spk,
      label,
      audio_dir,
      wav_dumpdir,
      segment,
      midi_mapping,
      tempos,
      tgt_sr=24000,
      dataset="lyrics",
  ):
      (
          uid,
          lyrics,
          phns,
          midis,
          syb_dur,
          phn_dur,
          keep,
      ) = segment.strip().split("|")
      phns = phns.split(" ")
      midis = midis.split(" ")
      syb_dur = syb_dur.split(" ")
      phn_dur = phn_dur.split(" ")
      keep = keep.split(" ")
  
      # load tempo from midi
      id = int(uid[0:4])
      tempo = tempos[id]
  
      # note to midi index
      midis = [
          midi_mapping[note] if note != "rest" else 0 for note in midis
      ]
  
      # type convert
      phn_dur = [float(dur) for dur in phn_dur]
      syb_dur = [float(syb) for syb in syb_dur]
      keep = [int(k) for k in keep]
      note_list = create_score(uid, phns, midis, syb_dur, keep)
  
      # 1 - 30
      for i in range(1, 31):
          i_str = str(i)  # Convert outer loop index to string
          wav_file = "{}.wav".format(
              os.path.join(
                  audio_dir, dataset, "segments", i_str + "#" + uid
              )
          )
          if not os.path.exists(wav_file):
              logging.info(
                  "cannot find wav file at {}".format(wav_file)
              )
              continue
  
          text.write(
              "acesinger_{}#{} {}\n".format(i_str, uid, " ".join(phns))
          )
          utt2spk.write(
              "acesinger_{}#{} {}\n".format(i_str, uid, i_str)
          )
  
          cmd = "sox {}.wav -c 1 -t wavpcm -b 16 -r {} {}/acesinger_{}#{}.wav".format(
              os.path.join(
                  audio_dir, dataset, "segments", i_str + "#" + uid
              ),
              tgt_sr,
              wav_dumpdir,
              i_str,
              uid,
          )
          os.system(cmd)
  
          wavscp.write(
              "acesinger_{}#{} {}/acesinger_{}#{}.wav\n".format(
                  i_str, uid, wav_dumpdir, i_str, uid
              )
          )
  
          running_dur = 0
          assert len(phn_dur) == len(phns)
          label_entry = []
  
          # Changed the variable name to avoid shadowing
          for j in range(len(phns)):
              start = running_dur
              end = running_dur + phn_dur[j]
              label_entry.append(
                  "{:.3f} {:.3f} {}".format(start, end, phns[j])
              )
              running_dur += phn_dur[j]
  
          label.write(
              "acesinger_{}#{} {}\n".format(
                  i_str, uid, " ".join(label_entry)
              )
          )
          score = dict(
              tempo=tempo,
              item_list=["st", "et", "lyric", "midi", "phns"],
              note=note_list,
          )
          writer["acesinger_{}#{}".format(i_str, uid)] = score
  
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 9 for calling a global function with example usage: process_utterance(writer, wavscp, text, utt2spk, label, audio_dir, wav_dumpdir, segment, midi_mapping, tempos, tgt_sr, dataset) without return types