code: def main(args):
      # create output folder
      try:
          cmd = f"mkdir -p {args.out_path}"
          os.system(cmd)
      except Exception:
          logging.error("Can not create output folder")
          exit(-1)
  
      # build vad object
      vad = webrtcvad.Vad(int(args.agg))
      # iterating over wavs in dir
      for file in tqdm(os.listdir(args.in_path)):
          if file.endswith(AUDIO_SUFFIX):
              audio_inpath = os.path.join(args.in_path, file)
              audio_outpath = os.path.join(args.out_path, file)
              audio, sample_rate = read_wave(audio_inpath)
              frames = frame_generator(FS_MS, audio, sample_rate)
              frames = list(frames)
              segments = vad_collector(
                  sample_rate, FS_MS, 300, vad, frames
              )
              merge_segments = list()
              timestamp_start = 0.0
              timestamp_end = 0.0
              # removing start, end, and long sequences of sils
              for i, segment in enumerate(segments):
                  merge_segments.append(segment[0])
                  if i and timestamp_start:
                      sil_duration = segment[1] - timestamp_end
                      if sil_duration > THRESHOLD:
                          merge_segments.append(
                              int(THRESHOLD / SCALE) * (b"\x00")
                          )
                      else:
                          merge_segments.append(
                              int((sil_duration / SCALE)) * (b"\x00")
                          )
                  timestamp_start = segment[1]
                  timestamp_end = segment[2]
              segment = b"".join(merge_segments)
              write_wave(audio_outpath, segment, sample_rate)
  
file_path: fairseq/examples/speech_synthesis/preprocessing/vad/__init__.py
imports: import collections
  import contextlib
  import wave
  import argparse
  import os
  import logging
  from tqdm import tqdm
label_desc: Use image node_id 5 for calling a global function with example usage: main(args) without return types