def average_mcd(self, loaded_ref_wav, loaded_syn_wav, cost_function, MCD_mode, score_rate):
        """
        Calculate the average MCD.
        :param ref_mcep_files: list of strings, paths to MCEP target reference files
        :param synth_mcep_files: list of strings, paths to MCEP converted synthesised files
        :param cost_function: distance metric used
        :param plain: if plain=True, use Dynamic Time Warping (dtw)
        :returns: average MCD, total frames processed
        """
        # load wav from given wav file
        #loaded_ref_wav = self.load_wav(ref_audio_file, sample_rate=self.SAMPLING_RATE)
        #loaded_syn_wav = self.load_wav(syn_audio_file, sample_rate=self.SAMPLING_RATE)

        if MCD_mode == "plain":
            # pad 0
            if len(loaded_ref_wav)<len(loaded_syn_wav):
                loaded_ref_wav = np.pad(loaded_ref_wav, (0, len(loaded_syn_wav)-len(loaded_ref_wav)))
            else:
                loaded_syn_wav = np.pad(loaded_syn_wav, (0, len(loaded_ref_wav)-len(loaded_syn_wav)))

            # extract MCEP features (vectors): 2D matrix (num x mcep_size)
            ref_mcep_vec = self.wav2mcep_numpy(loaded_ref_wav, score_rate)
            syn_mcep_vec = self.wav2mcep_numpy(loaded_syn_wav, score_rate)

            if MCD_mode == "plain":
                # print("Calculate plain MCD ...")
                path = []
                # for i in range(num_temp):
                for i in range(len(ref_mcep_vec)):
                    path.append((i, i))
            elif MCD_mode == "dtw":
                # print("Calculate MCD-dtw ...")
                _, path = fastdtw(ref_mcep_vec[:, 1:], syn_mcep_vec[:, 1:], dist=euclidean)
            elif MCD_mode == "dtw_sl":
                # print("Calculate MCD-dtw-sl ...")
                cof = len(ref_mcep_vec)/len(syn_mcep_vec) if len(ref_mcep_vec)>len(syn_mcep_vec) else len(syn_mcep_vec)/len(ref_mcep_vec)
                _, path = fastdtw(ref_mcep_vec[:, 1:], syn_mcep_vec[:, 1:], dist=euclidean)

            frames_tot, min_cost_tot = self.calculate_mcd_distance(ref_mcep_vec, syn_mcep_vec, path)

            if MCD_mode == "dtw_sl":
                mean_mcd = cof * self.log_spec_dB_const * min_cost_tot / frames_tot
            else:
                mean_mcd = self.log_spec_dB_const * min_cost_tot / frames_tot

            return mean_mcd

        Calculate the average MCD.
        :param ref_mcep_files: list of strings, paths to MCEP target reference files
        :param synth_mcep_files: list of strings, paths to MCEP converted synthesised files
        :param cost_function: distance metric used
        :param plain: if plain=True, use Dynamic Time Warping (dtw)
        :returns: average MCD, total frames processed
        
speechscore/scores/mcd.py