class_docstr: A class for computing MOS scores using an ONNX model and polynomial fitting.
      
class_docstr_tok: ["A","class","for","computing","MOS","scores","using","an","ONNX","model","and","polynomial","fitting","."]
docstr: Compute MOS scores for an audio segment.
          
docstr_tok: ["Compute","MOS","scores","for","an","audio","segment","."]
code: def __call__(self, fpath, sampling_rate, is_personalized_MOS):
      """Compute MOS scores for an audio segment."""
      aud, input_fs = sf.read(fpath)
      fs = sampling_rate
      if input_fs != fs:
          audio = librosa.resample(aud, input_fs, fs)
      else:
          audio = aud
      actual_audio_len = len(audio)
      len_samples = int(INPUT_LENGTH * fs)
      while len(audio) < len_samples:
          audio = np.append(audio, audio)
  
      num_hops = int(np.floor(len(audio) / fs) - INPUT_LENGTH) + 1
      hop_len_samples = fs
      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 = []
  
      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
  
          input_features = np.array(audio_seg).astype("float32")[
              np.newaxis, :
          ]
          oi = {"input_1": input_features}
          mos_sig_raw, mos_bak_raw, mos_ovr_raw = self.onnx_sess.run(
              None, oi
          )[0][0]
          mos_sig, mos_bak, mos_ovr = self.get_polyfit_val(
              mos_sig_raw,
              mos_bak_raw,
              mos_ovr_raw,
              is_personalized_MOS=0,
          )
          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)
  
      clip_dict = {
          "filename": fpath,
          "len_in_sec": actual_audio_len / fs,
          "sr": fs,
      }
      clip_dict["num_hops"] = num_hops
      clip_dict["OVRL_raw"] = np.mean(predicted_mos_ovr_seg_raw)
      clip_dict["SIG_raw"] = np.mean(predicted_mos_sig_seg_raw)
      clip_dict["BAK_raw"] = np.mean(predicted_mos_bak_seg_raw)
      clip_dict["OVRL"] = np.mean(predicted_mos_ovr_seg)
      clip_dict["SIG"] = np.mean(predicted_mos_sig_seg)
      clip_dict["BAK"] = np.mean(predicted_mos_bak_seg)
      return clip_dict
  
file_path: speechbrain/recipes/DNS/enhancement/dnsmos_local.py
imports: import argparse
  import concurrent.futures
  import glob
  import os
  import librosa
  import numpy
  import onnxruntime
  import pandas
  import soundfile
  from tqdm import tqdm
label_desc: Use image node_id 3 for calling the ComputeScore obj's underlying member method code with example usage: obj.__call__(fpath, sampling_rate, is_personalized_MOS) and returns: clip_dict