Esempio n. 1
0
 def testCep(self):
     order = 4
     ac = ssp.Autocorrelation(self.seq)
     ar, g = ssp.ARLevinson(ac, order)
     print "ar: ", ar
     cep = ssp.ARCepstrum(ar, g)
     print "cep:", cep
     ar2, g2 = ssp.ARCepstrumToPoly(cep)
     print "ar: ", ar2
     npt.assert_array_almost_equal(ar, ar2)
     npt.assert_almost_equal(g, g2)
Esempio n. 2
0
        pcm.WavSink(d, saveFile)

    # Encode to a file
    if opt.encode:
        a = pcm.WavSource(loadFile)
        (ar, g, pitch, hnr) = encode(a, pcm)

        (path, ext) = splitext(saveFile)
        # The cepstrum part is just like HTK
        if opt.lsp:
            # The gain is not part of the LSP; just append it
            l = ssp.ARLineSpectra(ar)
            lg = np.reshape(np.log(g), (len(g), 1))
            k = np.append(l, lg, axis=-1)
        else:
            k = ssp.ARCepstrum(ar, g, lpOrder[r])

        if opt.glottal == 'cepgm':
            theta, magni = ssp.glottal_pole_gm(f, pcm, pitch, hnr)
            t = np.reshape(theta, (len(theta), 1))
            m = np.reshape(np.log(magni), (len(magni), 1))
            e = np.concatenate((t, m), axis=-1)
            # (path, ext) = splitext(saveFile)
            # saveFileGlottal = path + ".cepgm"
            # np.savetxt(saveFileGlottal, e)
            c = np.append(k, e, axis=-1)
        else:
            c = k

        period = float(framePeriod) / r
        ssp.HTKSink(saveFile, c, period, native=opt.native)
Esempio n. 3
0
        #    a, g = ARLasso(a, lpOrder, ridge)
    elif frontend == "snr":
        a = ssp.Periodogram(f)
        n = ssp.Noise(a)
        a = ssp.SNRSpectrum(a, n * 0.1)
        a = ssp.Autocorrelation(a, input='psd')
        a, g = ssp.ARLevinson(a, lpOrder)
        a = ssp.AutocorrelationAllPassWarp(a,
                                           alpha=ssp.mel[pcm.rate],
                                           size=lpOrder + 1)
    elif frontend == "sparse":
        a, g = ssp.ARSparse(f, lpOrder, ssp.parameter("Gamma", 1.414))
    elif frontend == "student":
        m = ssp.AllPassWarpMatrix(frameSize, ssp.mel[pcm.rate])
        fw = np.dot(f, m.T)
        a, g = ssp.ARStudent(fw, lpOrder, ssp.parameter("DoF", 1.0))
    else:
        print("Unknown front end", frontend)

#    a, g = ARAllPassWarp(a, g, alpha=mel[r])

# Finally, turn the AR coefs into cepstrum
    a = ssp.ARCepstrum(a, g, ssp.parameter("nCepstra", 12))
    m = ssp.Mean(a)
    a = ssp.Subtract(a, m)
    m = ssp.StdDev(a)
    a = ssp.Divide(a, m)

    print("htk: ", saveFile)
    ssp.HTKSink(saveFile, a, 0.01, "USER")