def format_for_modelling(m_mag, m_real, m_imag, v_f0, fs, nbins_mel=60, nbins_phase=45):
# alpha:
alpha = define_alpha(fs)
# f0 to Smoothed lf0:
v_voi = (v_f0>0).astype('float')
v_f0_smth = v_voi * signal.medfilt(v_f0)
v_lf0_smth = la.f0_to_lf0(v_f0_smth)
# Mag to Log-Mag-Mel (compression):
m_mag_mel = la.sp_mel_warp(m_mag, nbins_mel, alpha=alpha, in_type=3)
m_mag_mel_log = la.log(m_mag_mel)
# Phase feats to Mel-phase (compression):
m_imag_mel = la.sp_mel_warp(m_imag, nbins_mel, alpha=alpha, in_type=2)
m_real_mel = la.sp_mel_warp(m_real, nbins_mel, alpha=alpha, in_type=2)
# Cutting phase vectors:
m_real_mel = m_real_mel[:,:nbins_phase]
m_imag_mel = m_imag_mel[:,:nbins_phase]
# Removing phase in unvoiced frames ("random" values):
m_real_mel = m_real_mel * v_voi[:,None]
m_imag_mel = m_imag_mel * v_voi[:,None]
# Clipping between -1 and 1:
m_real_mel = np.clip(m_real_mel, -1, 1)
m_imag_mel = np.clip(m_imag_mel, -1, 1)
return m_mag_mel_log, m_real_mel, m_imag_mel, v_lf0_smth
评论列表
文章目录