code: def snr_mixer(
      params,
      clean,
      noise,
      snr,
      target_level=-25,
      clipping_threshold=0.99,
  ):
      """Function to mix clean speech and noise at various SNR levels"""
      # cfg = params['cfg']
      if len(clean) > len(noise):
          noise = np.append(noise, np.zeros(len(clean) - len(noise)))
      else:
          clean = np.append(clean, np.zeros(len(noise) - len(clean)))
  
      # Normalizing to -25 dB FS
      clean = clean / (max(abs(clean)) + EPS)
      clean = normalize(clean, target_level)
      rmsclean = (clean**2).mean() ** 0.5
  
      noise = noise / (max(abs(noise)) + EPS)
      noise = normalize(noise, target_level)
      rmsnoise = (noise**2).mean() ** 0.5
  
      # Set the noise level for a given SNR
      noisescalar = rmsclean / (10 ** (snr / 20)) / (rmsnoise + EPS)
      noisenewlevel = noise * noisescalar
  
      # Mix noise and clean speech
      noisyspeech = clean + noisenewlevel
  
      # Randomly select RMS value between -15 dBFS and -35 dBFS and normalize noisyspeech with that value
      # There is a chance of clipping that might happen with very less probability, which is not a major issue.
      noisy_rms_level = np.random.randint(
          params["target_level_lower"], params["target_level_upper"]
      )
      rmsnoisy = (noisyspeech**2).mean() ** 0.5
      scalarnoisy = 10 ** (noisy_rms_level / 20) / (rmsnoisy + EPS)
      noisyspeech = noisyspeech * scalarnoisy
      clean = clean * scalarnoisy
      noisenewlevel = noisenewlevel * scalarnoisy
  
      # Final check to see if there are any amplitudes exceeding +/- 1. If so, normalize all the signals accordingly
      if is_clipped(noisyspeech):
          noisyspeech_maxamplevel = max(abs(noisyspeech)) / (
              clipping_threshold - EPS
          )
          noisyspeech = noisyspeech / noisyspeech_maxamplevel
          clean = clean / noisyspeech_maxamplevel
          noisenewlevel = noisenewlevel / noisyspeech_maxamplevel
          noisy_rms_level = int(
              20
              * np.log10(
                  scalarnoisy
                  / noisyspeech_maxamplevel
                  * (rmsnoisy + EPS)
              )
          )
  
      return clean, noisenewlevel, noisyspeech, noisy_rms_level
  
file_path: speechbrain/recipes/DNS/noisyspeech_synthesizer/audiolib.py
imports: import os
  import numpy
  import soundfile
  import subprocess
  import glob
  import librosa
label_desc: Use image node_id 9 for calling a global function with example usage: snr_mixer(params, clean, noise, snr, target_level, clipping_threshold) and returns: clean,  noisenewlevel,  noisyspeech,  noisy_rms_level