def test_LSPDF(order): from pysptk.synthesis import LSPDF def __test_synthesis(filt): # dummy source excitation source = __dummy_source() hopsize = 80 # dummy filter coef. windowed = __dummy_windowed_frames(source, frame_len=512, hopsize=hopsize) lpc = pysptk.lpc(windowed, filt.order) lsp = pysptk.lpc2lsp(lpc) # make sure lsp has loggain lsp[:, 0] = np.log(lsp[:, 0]) # synthesis synthesizer = Synthesizer(filt, hopsize) y = synthesizer.synthesis(source, lsp) assert np.all(np.isfinite(y)) __test_synthesis(LSPDF(order))
def __test(order): __test_synthesis(LSPDF(order))
hop_length=HOP_LENGTH).astype(np.float64).T frames *= pysptk.blackman(FRAME_LENGTH) # 窓掛け(ブラックマン窓) # ピッチ抽出 pitch = pysptk.swipe(x, fs=fs, hopsize=HOP_LENGTH, min=MIN_F0, max=MAX_F0, otype="pitch") # 励振源信号(声帯音源)の生成 source_excitation = pysptk.excite(pitch, HOP_LENGTH) # 線形予測分析による線形予測符号化(LPC)係数の抽出 lpc = pysptk.lpc(frames, ORDER) lpc[:, 0] = np.log(lpc[:, 0]) # LPC係数を線スペクトル対に変換 lsp = pysptk.lpc2lsp(lpc, otype=0, fs=fs) # 全極フィルタの作成 synthesizer = Synthesizer(LSPDF(order=ORDER), HOP_LENGTH) # 励振源信号でフィルタを駆動して音声を合成 y = synthesizer.synthesis(source_excitation, lsp) # 音声の書き込み y = y.astype(np.int16) wavfile.write(OUT_WAVE_FILE, fs, y)