frames *= pysptk.blackman(frame_length) assert frames.shape[1] == frame_length pitch = pysptk.swipe(x.astype(np.float64), fs=sr, hopsize=hop_length, min=60, max=240, otype="pitch") source_excitation = pysptk.excite(pitch, hop_length) # Order of mel-cepstrum mc = pysptk.mcep(frames, order, alpha) logH = pysptk.mgc2sp(mc, alpha, 0.0, frame_length).real print(mc.shape) #plt.plot(mc) #plotname="x_syn_coefs_" + str(order) + ".png" #plt.savefig(plotname) # Convert mel-cesptrum to MLSADF coefficients b = pysptk.mc2b(mc, alpha) synthesizer = Synthesizer(MLSADF(order=order, alpha=alpha), hop_length) x_synthesized = synthesizer.synthesis(source_excitation, b) filenam = "synthesized_sounds/" + "x_syn" + str(order + 1) + ".wav" #wavfile.write("x.wav", sr, x) wavfile.write(filenam, sr, x_synthesized)
def __test(order, alpha, gamma, fftlen): np.random.seed(98765) src = np.random.rand(order + 1) dst = pysptk.mgc2sp(src, alpha, gamma, fftlen) assert len(dst) == (fftlen >> 1) + 1 assert np.all(np.isfinite(dst))
def mgc2sp(mgc, sr): log_spec = pysptk.mgc2sp(mgc, alpha=get_world_alpha(sr), gamma=0, \ fftlen=get_world_fftlen(sr)).real return np.exp(log_spec * 2)