code: def process_data(
      target_dir,
      sentiment_file,
      text_file,
      wavscp_file,
      start_linenum,
      end_linenum,
  ):
      if not os.path.exists(target_dir):
          os.makedirs(target_dir)
  
      utt2spk_list = []
      segments_list = []
      text_list = []
      wavscp_list = []
      reco2file_list = []
  
      with open(sentiment_file, "r", encoding="utf-8") as sf, open(
          text_file, "r", encoding="utf-8"
      ) as tf, open(wavscp_file, "r", encoding="utf-8") as wf:
          prev_spk_id_tf = 0
          prev_linenum_tf = 0
          prev_linenum_wf = 0
          for linenum, line_sf in enumerate(sf):
              if linenum >= start_linenum and linenum < end_linenum:
                  # "sw02005_0[tab]0.0[tab]11.287375[tab]
                  # Neutral-{Questioning}#Neutral-{No emotion}#Neutral-{No emotion}"
                  (
                      utt_id_sf,
                      start,
                      end,
                      sentiment,
                  ) = line_sf.strip().split("\t")
                  # "sw02005_0" -> "sw02005"
                  reco_id_sf = utt_id_sf.split("_")[0]
                  label = majorityvote(sentiment)
                  if label != -1:
                      tf.seek(0)
                      for linenum_tf, line_tf in enumerate(tf):
                          if linenum_tf >= prev_linenum_tf:
                              # "sw02001-A_018732-018950 oh i see uh-huh"
                              # -> "sw02001-A_018732-018950" "oh i see uh-huh"
                              utt_id_tf, transcript = line_tf.strip(
                                  "\n"
                              ).split(" ", 1)
                              # "sw02001-A_018732-018950" -> "sw02001-A" "018732-018950"
                              spk_id_tf, time_id = utt_id_tf.split("_")
                              # "sw02001-A" -> "sw02001"
                              reco_id_tf = spk_id_tf.split("-")[0]
                              # "018732-018950" -> "018732" "018950"
                              (
                                  start_time_id,
                                  end_time_id,
                              ) = time_id.split("-")
                              # in case start and end time slightly differ
                              # in text and sentiment annotation
                              eps = 0.05
                              if (
                                  reco_id_tf == reco_id_sf
                                  and start_time_id
                                  >= float2str(float(start) - eps)
                                  and start_time_id
                                  <= float2str(float(start) + eps)
                                  and end_time_id
                                  >= float2str(float(end) - eps)
                                  and end_time_id
                                  <= float2str(float(end) + eps)
                              ):
                                  # normalize transcript
                                  transcript = normalize_transcript(
                                      transcript
                                  )
                                  utt2spk_list.append(
                                      "{} {}".format(
                                          utt_id_tf, spk_id_tf
                                      )
                                  )
                                  segments_list.append(
                                      "{} {} {:.2f} {:.2f}".format(
                                          utt_id_tf,
                                          spk_id_tf,
                                          float(start),
                                          float(end),
                                      )
                                  )
                                  text_list.append(
                                      "{} {} {}".format(
                                          utt_id_tf, label, transcript
                                      )
                                  )
  
                                  if prev_spk_id_tf != spk_id_tf:
                                      wf.seek(0)
                                      for (
                                          linenum_wf,
                                          line_wf,
                                      ) in enumerate(wf):
                                          if (
                                              linenum_wf
                                              >= prev_linenum_wf
                                          ):
                                              spk_id_wf = line_wf.split(
                                                  " "
                                              )[0]
                                              if spk_id_wf == spk_id_tf:
                                                  wavscp_list.append(
                                                      "{}".format(
                                                          line_wf.strip(
                                                              "\n"
                                                          )
                                                      )
                                                  )
                                                  (
                                                      reco_id_wf,
                                                      channel_id,
                                                  ) = spk_id_wf.split(
                                                      "-"
                                                  )
                                                  reco2file_list.append(
                                                      "{} {} {}".format(
                                                          spk_id_wf,
                                                          reco_id_wf,
                                                          channel_id,
                                                      )
                                                  )
                                                  prev_linenum_wf = (
                                                      linenum_wf
                                                  )
                                                  break
                                  prev_spk_id_tf = spk_id_tf
                                  prev_linenum_tf = linenum_tf
                                  break
      with open(
          os.path.join(target_dir, "utt2spk"), "w", encoding="utf-8"
      ) as utt2spk, open(
          os.path.join(target_dir, "segments"), "w", encoding="utf-8"
      ) as segments, open(
          os.path.join(target_dir, "text"), "w", encoding="utf-8"
      ) as text, open(
          os.path.join(target_dir, "wav.scp"), "w", encoding="utf-8"
      ) as wavscp, open(
          os.path.join(target_dir, "reco2file_and_channel"),
          "w",
          encoding="utf-8",
      ) as reco2file:
          utt2spk.write("\n".join(utt2spk_list) + "\n")
          segments.write("\n".join(segments_list) + "\n")
          text.write("\n".join(text_list) + "\n")
          wavscp.write("\n".join(wavscp_list) + "\n")
          reco2file.write("\n".join(reco2file_list) + "\n")
  
file_path: espnet/egs2/swbd_sentiment/asr1/local/prepare_sentiment.py
imports: import argparse
  import math
  import os
  import re
label_desc: Use image node_id 4 for calling a global function with example usage: process_data(target_dir, sentiment_file, text_file, wavscp_file, start_linenum, end_linenum) without return types