code: def prepare_segments_text_utt2spk_worker(
      transcription_dir,
      set_type,
      store_dir,
      processing_id=None,
      processing_num=None,
  ):
      segments_lines = []
      text_sentence_lines = []
      utt2spk_lines = []
      tier_name = "内容层"
      rejected_text_list = ["<NOISE>", "<DEAF>"]
      punctuation_list = ["。", "，", "？"]
      sound_list = ["呃", "啊", "噢", "嗯", "唉"]
      min_duration = 0.04
  
      wav_lines = sorted(
          text2lines(
              textpath="{}/temp/wav.scp".format(store_dir),
              lines_content=None,
          )
      )
      for wav_idx in range(len(wav_lines)):
          if processing_id is None:
              processing_token = True
          else:
              if wav_idx % processing_num == processing_id:
                  processing_token = True
              else:
                  processing_token = False
          if processing_token:
              wav_id, wav_path = wav_lines[wav_idx].split(" ")
              room, speakers, config, index = wav_id.split("_")[:4]
              speaker_list = [
                  speakers[i : i + 3]
                  for i in range(1, len(speakers), 3)
              ]
              for speaker in speaker_list:
                  tg = read_textgrid_from_file(
                      filepath=os.path.join(
                          transcription_dir,
                          set_type,
                          "{}_{}_{}_{}_Near_{}.TextGrid".format(
                              room, speakers, config, index, speaker
                          ),
                      )
                  )
                  target_tier = False
                  for tier in tg.tiers:
                      if tier.name == tier_name:
                          target_tier = tier
                  if not target_tier:
                      raise ValueError("no tier: {}".format(tier_name))
                  for interval in target_tier.intervals:
                      if (
                          interval.text not in rejected_text_list
                          and interval.xmax - interval.xmin
                          >= min_duration
                      ):
                          start_stamp = (
                              interval.xmin - interval.xmin % 0.04
                          )
                          start_stamp = round(start_stamp, 2)
                          end_stamp = (
                              interval.xmax
                              + 0.04
                              - interval.xmax % 0.04
                              if interval.xmax % 0.04 != 0
                              else interval.xmax
                          )
                          end_stamp = round(end_stamp, 2)
                          utterance_id = (
                              "S{}_{}_{}_{}_{}_".format(
                                  speaker, room, speakers, config, index
                              )
                              + "{0:06d}".format(
                                  int(round(start_stamp * 100, 0))
                              )
                              + "-"
                              + "{0:06d}".format(
                                  int(round(end_stamp * 100, 0))
                              )
                          )
                          text = interval.text
                          for punctuation in punctuation_list:
                              text = text.replace(punctuation, "")
                          if text not in sound_list:
                              segments_lines.append(
                                  "{} {} {} {}".format(
                                      utterance_id,
                                      wav_id,
                                      start_stamp,
                                      end_stamp,
                                  )
                              )
                              text_sentence_lines.append(
                                  "{} {}".format(utterance_id, text)
                              )
                              utt2spk_lines.append(
                                  "{} S{}".format(utterance_id, speaker)
                              )
      return [segments_lines, text_sentence_lines, utt2spk_lines]
  
imports: import argparse
  import codecs
  import glob
  import os
  import sys
  from multiprocessing import Pool
label_desc: Use image node_id 7 for calling a global function with example usage: prepare_segments_text_utt2spk_worker(transcription_dir, set_type, store_dir, processing_id, processing_num) and returns: list