code: def build_audio(is_clean, params, index, audio_samples_length=-1):
      """Construct an audio signal from source files"""
  
      fs_output = params["fs"]
      silence_length = params["silence_length"]
      if audio_samples_length == -1:
          audio_samples_length = int(
              params["audio_length"] * params["fs"]
          )
  
      output_audio = np.zeros(0)
      remaining_length = audio_samples_length
      files_used = []
      clipped_files = []
  
      if is_clean:
          source_files = params["cleanfilenames"]
          idx = index
      else:
          if "noisefilenames" in params.keys():
              source_files = params["noisefilenames"]
              idx = index
          # if noise files are organized into individual subdirectories,
          # pick a directory randomly
          else:
              noisedirs = params["noisedirs"]
              # pick a noise category randomly
              idx_n_dir = np.random.randint(0, np.size(noisedirs))
              source_files = glob.glob(
                  os.path.join(
                      noisedirs[idx_n_dir], params["audioformat"]
                  )
              )
              shuffle(source_files)
              # pick a noise source file index randomly
              idx = np.random.randint(0, np.size(source_files))
  
      # initialize silence
      silence = np.zeros(int(fs_output * silence_length))
  
      # iterate through multiple clips until we have a long enough signal
      tries_left = MAXTRIES
      while remaining_length > 0 and tries_left > 0:
          # read next audio file and resample if necessary
  
          idx = (idx + 1) % np.size(source_files)
          input_audio, fs_input = audioread(source_files[idx])
          if input_audio is None:
              sys.stderr.write(
                  "WARNING: Cannot read file: %s\n" % source_files[idx]
              )
              continue
          if fs_input != fs_output:
              input_audio = librosa.resample(
                  input_audio, fs_input, fs_output
              )
  
          # if current file is longer than remaining desired length, and this is
          # noise generation or this is training set, subsample it randomly
          if len(input_audio) > remaining_length and (
              not is_clean or not params["is_test_set"]
          ):
              idx_seg = np.random.randint(
                  0, len(input_audio) - remaining_length
              )
              input_audio = input_audio[
                  idx_seg : idx_seg + remaining_length
              ]
  
          # check for clipping, and if found move onto next file
          if is_clipped(input_audio):
              clipped_files.append(source_files[idx])
              tries_left -= 1
              continue
  
          # concatenate current input audio to output audio stream
          files_used.append(source_files[idx])
          output_audio = np.append(output_audio, input_audio)
          remaining_length -= len(input_audio)
  
          # add some silence if we have not reached desired audio length
          if remaining_length > 0:
              silence_len = min(remaining_length, len(silence))
              output_audio = np.append(
                  output_audio, silence[:silence_len]
              )
              remaining_length -= silence_len
  
      if (
          tries_left == 0
          and not is_clean
          and "noisedirs" in params.keys()
      ):
          print(
              "There are not enough non-clipped files in the "
              + noisedirs[idx_n_dir]
              + " directory to complete the audio build"
          )
          return [], [], clipped_files, idx
  
      return output_audio, files_used, clipped_files, idx
  
file_path: espnet/egs2/dns_icassp22/enh1/local/noisyspeech_synthesizer.py
imports: import argparse
  import configparser
  import glob
  import multiprocessing
  import os
  import sys
  from pathlib import Path
  from random import shuffle
  import librosa
  import numpy
  import pandas
  from audiolib import activitydetector, audioread, audiowrite, is_clipped, segmental_snr_mixer
  from scipy import signal
  import utils
label_desc: Use image node_id 2 for calling a global function with example usage: build_audio(is_clean, params, index, audio_samples_length) and returns: output_audio,  files_used,  clipped_files,  idx, list,  list,  clipped_files,  idx