code: def main():
      args = get_args()
      utt2spk = {}
      utt_list = []
  
      # First we read the utt2spk file and create a mapping
      for line in open(args.input_utt2spk):
          uttid, spkid = line.strip().split()
          utt2spk[uttid] = spkid
  
      # Next we read the input text file and create a list of
      # Utterance class objects
      for line in open(args.input_text):
          parts = line.strip().split(maxsplit=1)
          uttid = parts[0]
          text = "" if len(parts) == 1 else parts[1]
          utterance = Utterance(uttid, utt2spk[uttid], text)
          utt_list.append(utterance)
  
      # We group the utterance list into a dictionary indexed by (reco_id, spk_id)
      reco_spk_to_utts = defaultdict(
          list,
          {
              uid: list(g)
              for uid, g in groupby(
                  utt_list, lambda x: (x.reco_id, x.spk_id)
              )
          },
      )
  
      # Now for each (reco_id, spk_id) pair, we write the concatenated text to an
      # output  (we assign speaker ids 1,2,3,..)
      for i, uid in enumerate(sorted(reco_spk_to_utts.keys())):
          reco_id = reco_spk_to_utts[uid][0].reco_id
          output_file = os.path.join(
              args.output_dir,
              "{}_{}_{}_comb".format(args.affix, i, reco_id),
          )
          output_writer = open(output_file, "w")
          utterances = reco_spk_to_utts[uid]
  
          # We sort all utterances by start time and concatenate.
          utterances.sort(key=lambda x: x.start_time)
          combined_text = " ".join([utt.text for utt in utterances])
  
          output_writer.write("{} {}".format(reco_id, combined_text))
          output_writer.close()
  
file_path: espnet/egs/libri_css/asr1/local/get_perspeaker_output.py
imports: import argparse
  import itertools
  import os
  from collections import defaultdict
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types