code: def vad_for_folder(input_path, out_path):
      """do vad for a folder"""
      files = os.listdir(input_path)
      for file in files:
          try:
              audio, sample_rate = read_wave(
                  os.path.join(input_path, file)
              )
          except Exception as e:
              print(e)
  
          vad = webrtcvad.Vad(3)
          frames = frame_generator(30, audio, sample_rate)
          frames = list(frames)
          segments = vad_collector(sample_rate, 30, 30, vad, frames)
  
          total_segment = bytes()
  
          for i, segment in enumerate(segments):
              total_segment += segment
  
          # abandon short emotions (< 0.2s)
          if len(total_segment) > 6400:  # 0.2 * 16000 * 2
              write_wave(
                  os.path.join(out_path, file),
                  total_segment,
                  sample_rate,
              )
  
file_path: speechbrain/recipes/ZaionEmotionDataset/emotion_diarization/datasets/vad.py
imports: import collections
  import webrtcvad
  import contextlib
  import wave
  import os
label_desc: Use image node_id 5 for calling a global function with example usage: vad_for_folder(input_path, out_path) without return types