code: def process_kaldi_directory(
      data_dir,
      prefix,
      src,
      tgt,
      src_field,
      num_proc,
      nlsyms,
      lower_case,
  ):
      # read all files
      text_dict = open(str(data_dir / "text")).readlines()
      text_dict = [line.strip().split() for line in text_dict]
      text_dict = {line[0]: " ".join(line[1:]) for line in text_dict}
  
      if tgt is not None:
          tgt_dict = open(str(data_dir / "text.tgt")).readlines()
          tgt_dict = [line.strip().split() for line in tgt_dict]
          tgt_dict = {line[0]: " ".join(line[1:]) for line in tgt_dict}
      else:
          tgt_dict = None
  
      wav_dict = open(str(data_dir / "wav.scp")).readlines()
      wav_dict = [line.strip().split() for line in wav_dict]
      wav_dict = {line[0]: " ".join(line[1:]) for line in wav_dict}
  
      if (data_dir / "segments").is_file():
          logging.info("segments file found. Use it.")
          seg_dict = open(str(data_dir / "segments")).readlines()
          seg_dict = [line.strip().split() for line in seg_dict]
          seg_dict = {
              line[0]: (line[1], float(line[-2]), float(line[-1]))
              for line in seg_dict
          }
  
      # if the input file is not compatible with librosa, call get_utt2dur.sh
      # before calling this script
      elif (data_dir / "utt2dur").is_file():
          logging.info("utt2dur file found. Use it.")
          seg_dict = open(str(data_dir / "utt2dur")).readlines()
          seg_dict = [line.strip().split() for line in seg_dict]
          seg_dict = {
              line[0]: (line[0], 0, float(line[1])) for line in seg_dict
          }
  
      else:
          logging.info("segments not found. find the duration then")
          seg_dict = find_durations(wav_dict, num_proc, src_field)
  
      talks = {}
      for uttid, seg_info in seg_dict.items():
          wavid, start, end = seg_info
  
          if wavid not in talks:
              talks[wavid] = []
  
          text = preprocess_text(text_dict[uttid], nlsyms)
          text = text.lower() if lower_case else text
          if len(text) <= 0:
              logging.info(f"{uttid} has the empty text. skip")
              continue
  
          if tgt_dict is not None:
              tgt_text = tgt_text[uttid]
          else:
              tgt_text = text
  
          tgt_text = preprocess_text(tgt_text, nlsyms)
          tgt_text = tgt_text.lower() if lower_case else tgt_text
          if len(tgt_text) <= 0:
              logging.info(f"{uttid} has the empty tgt text. skip")
              continue
  
          talks[wavid].append(
              Utterance(
                  utt_id=f"{prefix}_{wavid}_{uttid}",
                  wav_id=f"{prefix}_{wavid}",
                  wav_path=wav_dict[wavid],
                  start_time=start,
                  end_time=end,
                  lang=f"<{src}>",
                  task=f"<st_{tgt}>"
                  if tgt_dict is not None
                  else "<asr>",
                  text=tgt_text,
                  asr_text=text,
              )
          )
  
      return talks.values()
  
file_path: espnet/egs2/owsm_v3/s2t1/local/kaldi_to_whisper.py
imports: import logging
  from argparse import ArgumentParser
  from io import BytesIO
  from multiprocessing import Pool
  from pathlib import Path
  import kaldiio
  import librosa
  import soundfile
  from utils import SYMBOL_NA, SYMBOL_NOSPEECH, SYMBOLS_TIME, LongUtterance, Utterance, generate_long_utterances
label_desc: Use image node_id 5 for calling a global function with example usage: process_kaldi_directory(data_dir, prefix, src, tgt, src_field, num_proc, nlsyms, lower_case) and returns: talks