code: def set(file, s, savedir, sourcedir, segment):
      """Make the Kaldi files.
  
      Args:
          file (str): The file name.
          s (str): Which set. For this code dset is pretrain set.
          sourcedir: LRS2 dataset dir.
          savedir (str): The dir save the Kaldi files.
  
      """
  
      textdir = os.path.join(savedir, "text")
      utt2spkdir = os.path.join(savedir, "utt2spk")
      wavdir = os.path.join(savedir, "wav.scp")
      segmentdir = os.path.join(savedir, "segments")
  
      textfile = os.path.join(sourcedir, file + ".txt")
      mp4dir = os.path.join(sourcedir, file + ".mp4")
  
      if segment is False:
          segmentinfo = segmentation(textfile, file, segment)
          command1 = "ffmpeg -y -i"
          command2 = "-vn -ac 1 -ar 16000 -ab 320k -f wav /tmp/tmp.$$; cat /tmp/tmp.$$ |\n"
          splitname = file.split("/")
          Title = "_".join(["LRS2", splitname[0], splitname[1] + "p"])
          texttxt = [
              " ".join(
                  [Title, segmentinfo[file][str(0)]["segmenttext"]]
              )
          ]
          wavtxt = [" ".join([Title, command1, mp4dir, command2])]
          utttxt = [
              Title
              + " "
              + "_".join(["LRS2", splitname[0], splitname[1] + "p"])
              + "\n"
          ]
  
      else:
          segdir = os.path.join(savedir, "seginfo.txt")
          segmentinfo = segmentation(textfile, file)
          if len(segmentinfo[file]) == 1:
              starttime = float(
                  segmentinfo[file][str(0)]["segmenttime"][0]
              )
              endtime = float(
                  segmentinfo[file][str(0)]["segmenttime"][1]
              )
              command1 = "ffmpeg -y -i"
              command2 = "-vn -ac 1 -ar 16000 -ab 320k -f wav /tmp/tmp.$$; cat /tmp/tmp.$$ |\n"
              splitname = file.split("/")
              Title = "_".join(
                  [
                      "LRS2",
                      splitname[0],
                      splitname[1] + "p",
                      str(int(starttime * 100)).zfill(7),
                      str(int(endtime * 100)).zfill(7),
                  ]
              )
              spkerid = "_".join(
                  ["LRS2", splitname[0], splitname[1] + "p"]
              )
              texttxt = " ".join(
                  [Title, segmentinfo[file][str(0)]["segmenttext"]]
              )
              wavtxt = " ".join([spkerid, command1, mp4dir, command2])
              segtxt = (
                  " ".join(
                      [Title, spkerid, str(starttime), str(endtime)]
                  )
                  + "\n"
              )
              utttxt = Title + " " + spkerid + "\n"
  
          else:
              splitname = file.split("/")
              command1 = "ffmpeg -y -i"
              command2 = "-vn -ac 1 -ar 16000 -ab 320k -f wav /tmp/tmp.$$; cat /tmp/tmp.$$ |\n"
              spkerid = "_".join(
                  ["LRS2", splitname[0], splitname[1] + "p"]
              )
              wavtxt = [" ".join([spkerid, command1, mp4dir, command2])]
              texttxt = []
              utttxt = []
              segtxt = []
              segmentinfos = []
              for i in range(len(segmentinfo[file])):
                  starttime = float(
                      segmentinfo[file][str(i)]["segmenttime"][0]
                  )
                  endtime = float(
                      segmentinfo[file][str(i)]["segmenttime"][1]
                  )
                  if segmentinfo[file][str(i)]["segmenttext"] == "":
                      pass
                  else:
                      Title = "_".join(
                          [
                              "LRS2",
                              splitname[0],
                              splitname[1] + "p",
                              str(int(starttime * 100)).zfill(7),
                              str(int(endtime * 100)).zfill(7),
                          ]
                      )
                      spkerid = "_".join(
                          ["LRS2", splitname[0], splitname[1] + "p"]
                      )
                      segtxt.append(
                          " ".join(
                              [
                                  Title,
                                  spkerid,
                                  str(starttime),
                                  str(endtime),
                              ]
                          )
                          + "\n"
                      )
                      segmentinfos.append(
                          " ".join(
                              [
                                  Title,
                                  mp4dir,
                                  str(starttime),
                                  str(endtime),
                              ]
                          )
                          + "\n"
                      )
  
                      temptext = " ".join(
                          [
                              Title,
                              segmentinfo[file][str(i)]["segmenttext"],
                          ]
                      )
                      if "\n" in temptext:
                          pass
                      else:
                          temptext = temptext + "\n"
                      texttxt.append(temptext)
                      utttxt.append(Title + " " + spkerid + "\n")
  
              with open(segdir, "a") as segprocess:
                  segprocess.writelines(segmentinfos)
                  segprocess.close()
  
      with open(textdir, "a") as textprocess:
          textprocess.writelines(texttxt)
          textprocess.close()
      with open(utt2spkdir, "a") as utt:
          utt.writelines(utttxt)
          utt.close()
      with open(wavdir, "a") as wav:
          wav.writelines(wavtxt)
          wav.close()
      with open(segmentdir, "a") as segs:
          segs.writelines(segtxt)
          segs.close()
  
file_path: espnet/egs/lrs2/asr1/local/pretrain.py
imports: import multiprocessing
  import os
  import sys
label_desc: Use image node_id 5 for calling a global function with example usage: set(file, s, savedir, sourcedir, segment) without return types