# See the file COPYING for the licence associated with this software. # # Author(s): # Phil Garner # import numpy as np import matplotlib.pyplot as plt import ssp i = np.identity(30) o1 = ssp.AllPassWarpOppenheim(i, alpha=0, size=40) o2 = ssp.AllPassWarpOppenheim(i, alpha=0.1, size=40) o3 = ssp.AllPassWarpOppenheim(i, alpha=0.3, size=40) #o5 = ssp.AllPassWarpOppenheim(i, alpha=-0.1, size=40) #o6 = ssp.AllPassWarpOppenheim(i, alpha=-0.3, size=40) o5 = ssp.AllPassWarpMatrix(30, alpha=-0.1, size=40) o6 = ssp.AllPassWarpMatrix(30, alpha=-0.3, size=40) #m = ssp.AllPassWarpMatrix(4, alpha=0.42, size=40) fig = plt.figure() o1Mat = fig.add_subplot(2,3,1) o2Mat = fig.add_subplot(2,3,2) o3Mat = fig.add_subplot(2,3,3) o5Mat = fig.add_subplot(2,3,5) o6Mat = fig.add_subplot(2,3,6) o1Mat.imshow(o1.T) o2Mat.imshow(o2.T) o3Mat.imshow(o3.T)
ls = ssp.ARSpectrum(a, g, nSpec=128) lap("Spectrum") # Now do some esoteric AR t = ssp.parameter('AR', 'matrix') if t == 'matrix': wa, wg = ssp.ARMatrix(f, order, method=ssp.parameter('Method', 'matrix')) if t == 'arwarp': wa, wg = ssp.ARAllPassWarp(a, g, alpha=ssp.mel[pcm.rate]) elif t == 'acwarp': ac = ssp.Autocorrelation(f) ac = ssp.AutocorrelationAllPassWarp(ac, alpha=ssp.mel[pcm.rate], size=order+1) wa, wg = ssp.ARLevinson(ac, order) elif t == 'tdwarp': m = ssp.AllPassWarpMatrix(256, ssp.mel[pcm.rate]) fw = np.dot(f,m.T) aw = ssp.Autocorrelation(fw) wa, wg = ssp.ARLevinson(aw, order) elif t == 'ridge': ac = ssp.Autocorrelation(f) wa, wg = ssp.ARRidge(ac, order, ridge=0.01) elif t == 'lasso': ac = ssp.Autocorrelation(f) wa, wg = ssp.ARLasso(ac, order, ridge=30) elif t == 'sparse': wa, wg = ssp.ARSparse(f, order, ssp.parameter("Gamma", 1)) elif t == 'student': wa, wg = ssp.ARStudent(f, order, ssp.parameter("DF", 1)) lap(t) ws = ssp.ARSpectrum(wa, wg, nSpec=128)
# ridge = Parameter('Ridge', 0.1) # a, g = ARRidge(a, lpOrder, ridge) # 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)