コード例 #1
0
    def __test(order):
        a1 = pysptk.lpc(x, order, use_scipy=False)
        a2 = pysptk.lpc(x, order, use_scipy=True)
        a3 = pysptk.levdur(pysptk.acorr(x, order), use_scipy=False)
        a4 = pysptk.levdur(pysptk.acorr(x, order), use_scipy=True)

        assert np.all(np.isfinite(a1))
        assert np.allclose(a1, a2)
        assert np.allclose(a1, a3)
        assert np.allclose(a1, a4)
コード例 #2
0
def test_lpc(order):
    x = windowed_dummy_data(1024)

    a1 = pysptk.lpc(x, order, use_scipy=False)
    a2 = pysptk.lpc(x, order, use_scipy=True)
    a3 = pysptk.levdur(pysptk.acorr(x, order), use_scipy=False)
    a4 = pysptk.levdur(pysptk.acorr(x, order), use_scipy=True)

    assert np.all(np.isfinite(a1))
    assert np.allclose(a1, a2)
    assert np.allclose(a1, a3)
    assert np.allclose(a1, a4)
コード例 #3
0
    def __test_synthesis_levdur(filt):
        # dummy source excitation
        source = __dummy_source()

        hopsize = 80

        # dummy filter coef.
        windowed = __dummy_windowed_frames(source,
                                           frame_len=512,
                                           hopsize=hopsize)
        c = pysptk.mcep(windowed, filt.order)
        a = pysptk.c2acr(c)
        lpc = pysptk.levdur(a)
        lpc2 = pysptk.levdur(a, use_scipy=True)
        assert np.allclose(lpc, lpc2)

        # make sure lpc has loggain
        lpc[:, 0] = np.log(lpc[:, 0])

        # synthesis
        synthesizer = Synthesizer(filt, hopsize)
        y = synthesizer.synthesis(source, lpc)
        assert np.all(np.isfinite(y))
コード例 #4
0
ファイル: pitch_augmentation.py プロジェクト: r9y9/nnsvs
def pitch_shift_on_lpc_residual(
    wav,
    sr,
    shift_in_cent,
    frame_length=4096,
    hop_length=240,
    mgc_order=59,
):
    assert wav.dtype == np.int16
    frames = (librosa.util.frame(wav,
                                 frame_length=frame_length,
                                 hop_length=hop_length).astype(np.float64).T)
    frames *= pysptk.blackman(frame_length)
    alpha = pysptk.util.mcepalpha(sr)

    mgc = pysptk.mcep(frames, mgc_order, alpha, eps=1e-5, etype=1)
    c = pysptk.freqt(mgc, mgc_order, -alpha)

    lpc = pysptk.levdur(pysptk.c2acr(c, mgc_order, frame_length))
    # remove gain
    lpc[:, 0] = 0

    # Compute LPC residual
    synth = Synthesizer(AllZeroDF(mgc_order), hop_length)
    wav_lpc = synth.synthesis(wav.astype(np.float64), -lpc)
    residual = wav - wav_lpc

    # Pitch-shift on LPC residual
    residual_shifted = librosa.effects.pitch_shift(residual,
                                                   sr=sr,
                                                   n_steps=shift_in_cent,
                                                   bins_per_octave=1200)

    # Filtering by LPC
    synth = Synthesizer(AllPoleDF(mgc_order), hop_length)
    wav_shifted = synth.synthesis(residual_shifted, lpc)

    return wav_shifted.astype(np.int16)