6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MCD(Mel-cepstrum distortion)を求める

Last updated at Posted at 2021-02-15

#DTW版作成しました.

MCD(Mel-cepstrum distortion)とは

  • 声質変換系の評価軸としてよく使われるやつ
  • cyclegan-vc2では変換後の評価に使われている
  • MSD(modulation spectra distance)もあるが,簡単に求めるツールを知らんので誰か教えて!!
  • 式は以下の通り参考リンク
\frac{10\sqrt{2}}{\ln10}\frac{1}{T}\sum_t\sqrt{\sum^{25}_i 2||mc(t,i)-mc_{synth}(t,i)||^2}
  • mel-cepstrumに変換その後,差分の二乗を行いルート取るって感じ

どんなツール使うの

  • nnmnkwiiです!
  • 声質変換を触った人は一回は見たことあるツール
  • nnmnkwii.metrics.melcdで求められる!!(神!!)
  • 入力としてmel-cepstrumを求めるのでpyworldで変換!!
  • 以下コード
# -*- coding: utf-8 -*-
import os
import subprocess
import sys
import glob
import librosa
import numpy as np
from nnmnkwii.metrics import melcd
import pyworld

args=sys.argv
if len(args) != 3:
    print("python3 mcd.py [input wavfile1] [input wavfile2]")
    sys.exit()

else:
    sr = 16000
    wav1, _ = librosa.load(sys.argv[1], sr=sr, mono=True)
    wav2, _ = librosa.load(sys.argv[2], sr=sr, mono=True)
    
    wav1 = wav1.astype(np.float64)
    f0_1, timeaxis_1 = pyworld.harvest(wav1, sr, frame_period=5.0, f0_floor=71.0, f0_ceil=800.0)
    sp1 = pyworld.cheaptrick(wav1, f0_1, timeaxis_1, sr)    
    wav2 = wav2.astype(np.float64)
    f0_2, timeaxis_2 = pyworld.harvest(wav2, sr, frame_period=5.0, f0_floor=71.0, f0_ceil=800.0)
    sp2 = pyworld.cheaptrick(wav2, f0_2, timeaxis_2, sr)
    # mel-cepstrum
    coded_sp_1 = pyworld.code_spectral_envelope(sp1, sr, 24)
    coded_sp_2 = pyworld.code_spectral_envelope(sp2, sr, 24)

    result = melcd(coded_sp_1,coded_sp_2 , lengths=None)

    print(result)
  • 以上!!(厚切りジェンソン風(古っる))
6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?