code: def SSNR(ref_wav, deg_wav, srate=16000, eps=1e-10):
      """Segmental Signal-to-Noise Ratio Objective Speech Quality Measure
      This function implements the segmental signal-to-noise ratio
      as defined in [1, p. 45] (see Equation 2.12).
      """
      clean_speech = ref_wav
      processed_speech = deg_wav
      clean_length = ref_wav.shape[0]
  
      # scale both to have same dynamic range. Remove DC too.
      clean_speech -= clean_speech.mean()
      processed_speech -= processed_speech.mean()
      processed_speech *= np.max(np.abs(clean_speech)) / np.max(
          np.abs(processed_speech)
      )
  
      # Signal-to-Noise Ratio
      dif = ref_wav - deg_wav
      overall_snr = 10 * np.log10(
          np.sum(ref_wav**2) / (np.sum(dif**2) + 10e-20)
      )
      # global variables
      winlength = int(np.round(30 * srate / 1000))  # 30 msecs
      skiprate = winlength // 4
      MIN_SNR = -10
      MAX_SNR = 35
  
      # For each frame, calculate SSNR
      num_frames = int(clean_length / skiprate - (winlength / skiprate))
      start = 0
      time = np.linspace(1, winlength, winlength) / (winlength + 1)
      window = 0.5 * (1 - np.cos(2 * np.pi * time))
      segmental_snr = []
  
      for frame_count in range(int(num_frames)):
          # (1) get the frames for the test and ref speech.
          # Apply Hanning Window
          clean_frame = clean_speech[start : start + winlength]
          processed_frame = processed_speech[start : start + winlength]
          clean_frame = clean_frame * window
          processed_frame = processed_frame * window
  
          # (2) Compute Segmental SNR
          signal_energy = np.sum(clean_frame**2)
          noise_energy = np.sum((clean_frame - processed_frame) ** 2)
          segmental_snr.append(
              10 * np.log10(signal_energy / (noise_energy + eps) + eps)
          )
          segmental_snr[-1] = max(segmental_snr[-1], MIN_SNR)
          segmental_snr[-1] = min(segmental_snr[-1], MAX_SNR)
          start += int(skiprate)
      return overall_snr, segmental_snr
  
file_path: speechbrain/recipes/DNS/enhancement/composite_eval.py
imports: from scipy.linalg import toeplitz
  from tqdm import tqdm
  from pesq import pesq
  import librosa
  import numpy
  import os
  import sys
label_desc: Use image node_id 5 for calling a global function with example usage: SSNR(ref_wav, deg_wav, srate, eps) and returns: overall_snr,  segmental_snr