code: def __call__(self, aud, input_fs, is_personalized_MOS=False):
      if self.convert_to_torch:
          device = "cuda" if self.use_gpu else "cpu"
          if isinstance(aud, torch.Tensor):
              aud = aud.to(device=device)
          else:
              aud = torch.as_tensor(
                  aud, dtype=torch.float32, device=device
              )
      else:
          aud = (
              aud.cpu().detach().numpy()
              if isinstance(aud, torch.Tensor)
              else aud
          )
      if input_fs != SAMPLING_RATE:
          if self.convert_to_torch:
              audio = torch.as_tensor(
                  librosa.resample(
                      aud.detach().cpu().numpy(),
                      orig_sr=input_fs,
                      target_sr=SAMPLING_RATE,
                  ),
                  dtype=aud.dtype,
                  device=aud.device,
              )
          else:
              audio = librosa.resample(
                  aud, orig_sr=input_fs, target_sr=SAMPLING_RATE
              )
      else:
          audio = aud
      len_samples = int(INPUT_LENGTH * SAMPLING_RATE)
      while len(audio) < len_samples:
          if self.convert_to_torch:
              audio = torch.cat((audio, audio))
          else:
              audio = np.append(audio, audio)
  
      num_hops = (
          int(np.floor(len(audio) / SAMPLING_RATE) - INPUT_LENGTH) + 1
      )
      hop_len_samples = SAMPLING_RATE
      predicted_mos_sig_seg_raw = []
      predicted_mos_bak_seg_raw = []
      predicted_mos_ovr_seg_raw = []
      predicted_mos_sig_seg = []
      predicted_mos_bak_seg = []
      predicted_mos_ovr_seg = []
      predicted_p808_mos = []
  
      for idx in range(num_hops):
          audio_seg = audio[
              int(idx * hop_len_samples) : int(
                  (idx + INPUT_LENGTH) * hop_len_samples
              )
          ]
          if len(audio_seg) < len_samples:
              continue
  
          if self.convert_to_torch:
              input_features = audio_seg.float()[None, :]
              p808_input_features = self.audio_melspec(
                  audio=audio_seg[:-160]
              ).float()[None, :, :]
              p808_mos = self.p808_model(p808_input_features)
              (
                  mos_sig_raw,
                  mos_bak_raw,
                  mos_ovr_raw,
              ) = self.primary_model(input_features)[0]
          else:
              input_features = np.array(audio_seg).astype("float32")[
                  np.newaxis, :
              ]
              p808_input_features = np.array(
                  self.audio_melspec(audio=audio_seg[:-160])
              ).astype("float32")[np.newaxis, :, :]
              p808_mos = self.p808_onnx_sess.run(
                  None, {"input_1": p808_input_features}
              )[0][0][0]
              (
                  mos_sig_raw,
                  mos_bak_raw,
                  mos_ovr_raw,
              ) = self.onnx_sess.run(None, {"input_1": input_features})[
                  0
              ][
                  0
              ]
          mos_sig, mos_bak, mos_ovr = self.get_polyfit_val(
              mos_sig_raw, mos_bak_raw, mos_ovr_raw, is_personalized_MOS
          )
          predicted_mos_sig_seg_raw.append(mos_sig_raw)
          predicted_mos_bak_seg_raw.append(mos_bak_raw)
          predicted_mos_ovr_seg_raw.append(mos_ovr_raw)
          predicted_mos_sig_seg.append(mos_sig)
          predicted_mos_bak_seg.append(mos_bak)
          predicted_mos_ovr_seg.append(mos_ovr)
          predicted_p808_mos.append(p808_mos)
  
      to_array = torch.stack if self.convert_to_torch else np.array
      return {
          "OVRL_raw": to_array(predicted_mos_ovr_seg_raw).mean(),
          "SIG_raw": to_array(predicted_mos_sig_seg_raw).mean(),
          "BAK_raw": to_array(predicted_mos_bak_seg_raw).mean(),
          "OVRL": to_array(predicted_mos_ovr_seg).mean(),
          "SIG": to_array(predicted_mos_sig_seg).mean(),
          "BAK": to_array(predicted_mos_bak_seg).mean(),
          "P808_MOS": to_array(predicted_p808_mos).mean(),
      }
  
file_path: espnet/espnet2/enh/layers/dnsmos.py
imports: import json
  import math
  import librosa
  import numpy
  import requests
  import torch
  import torchaudio
label_desc: Use image node_id 4 for calling the DNSMOS_local obj's underlying member method code with example usage: obj.__call__(aud, input_fs, is_personalized_MOS) and returns: dict