All functionality in pysptk.sptk (the core API) is directly accesible from the top-level pysptk.* namespace.

For convenience, vector-to-vector functions (pysptk.mcep, pysptk.mc2b, etc) that takes an input vector as the first argment, can also accept matrix. As for matrix inputs, vector-to-vector functions are applied along with the last axis internally; e.g.

mc = pysptk.mcep(frames) # frames.shape == (num_frames, frame_len)

is equivalent to:

mc = np.apply_along_axis(pysptk.mcep, -1, frames)


The core APIs in pysptk.sptk package are based on the SPTK’s internal APIs (e.g. code in _mgc2sp.c), so the functionalities are not exactly same as SPTK’s CLI. If you find any inconsistency that should be addressed, please file an issue.


Almost all of pysptk functions assume that the input array is C-contiguous and has float64 element type. For vector-to-vector functions, the input array is automatically converted to float64-typed one, the function is executed on it, and then the output array is converted to have the same type with the input you provided.

Library routines

agexp(r, x, y) Magnitude squared generalized exponential function
gexp(r, x) Generalized exponential function
glog(r, x) Generalized logarithmic function
mseq() M-sequence

Adaptive cepstrum analysis

acep(x, c[, lambda_coef, step, tau, pd, eps]) Adaptive cepstral analysis
agcep(x, c[, stage, lambda_coef, step, tau, eps]) Adaptive generalized cepstral analysis
amcep(x, b[, alpha, lambda_coef, step, tau, …]) Adaptive mel-cepstral analysis

Mel-generalized cepstrum analysis

mcep(windowed[, order, alpha, miniter, …]) Mel-cepstrum analysis
gcep(windowed[, order, gamma, miniter, …]) Generalized-cepstrum analysis
mgcep(windowed[, order, alpha, gamma, …]) Mel-generalized cepstrum analysis
uels(windowed[, order, miniter, maxiter, …]) Unbiased estimation of log spectrum
fftcep(logsp[, order, num_iter, …]) FFT-based cepstrum analysis
lpc(windowed[, order, min_det]) Linear prediction analysis


mfcc(x[, order, fs, alpha, eps, window_len, …]) MFCC

LPC, LSP and PARCOR conversions

lpc2c(lpc[, order]) LPC to cepstrum
lpc2lsp(lpc[, numsp, maxiter, eps, loggain, …]) LPC to LSP
lpc2par(lpc) LPC to PARCOR
par2lpc(par) PARCOR to LPC
lsp2sp(lsp[, fftlen]) LSP to spectrum

Mel-generalized cepstrum conversions

mc2b(mc[, alpha]) Mel-cepsrum to MLSA filter coefficients
b2mc(b[, alpha]) MLSA filter coefficients to mel-cesptrum
c2acr(c[, order, fftlen]) Cepstrum to autocorrelation
c2ir(c[, length]) Cepstrum to impulse response
ic2ir(h[, order]) Impulse response to cepstrum
c2ndps(c[, fftlen]) Cepstrum to Negative Derivative of Phase Spectrum (NDPS)
ndps2c(ndps[, order]) Cepstrum to Negative Derivative of Phase Spectrum (NDPS)
gc2gc(src_ceps[, src_gamma, dst_order, …]) Generalized cepstrum transform
gnorm(ceps[, gamma]) Gain normalization
ignorm(ceps[, gamma]) Inverse gain normalization
freqt(ceps[, order, alpha]) Frequency transform
mgc2mgc(src_ceps[, src_alpha, src_gamma, …]) Mel-generalized cepstrum transform
mgc2sp(ceps[, alpha, gamma, fftlen]) Mel-generalized cepstrum transform
mgclsp2sp(lsp[, alpha, gamma, fftlen, gain]) MGC-LSP to spectrum

F0 analysis

swipe(x, fs, hopsize[, min, max, threshold, …]) SWIPE’ - A Saw-tooth Waveform Inspired Pitch Estimation
rapt(x, fs, hopsize[, min, max, voice_bias, …]) RAPT - a robust algorithm for pitch tracking

Excitation generation

excite(pitch[, hopsize, interp_period, …]) Excitation generation

Window functions

blackman(n[, normalize]) Blackman window
hamming(n[, normalize]) Hamming window
hanning(n[, normalize]) Hanning window
bartlett(n[, normalize]) Bartlett window
trapezoid(n[, normalize]) Trapezoid window
rectangular(n[, normalize]) Rectangular window

Waveform generation filters

poledf(x, a, delay) All-pole digital filter
lmadf(x, b, pd, delay) LMA digital filter
lspdf(x, f, delay) LSP synthesis digital filter
ltcdf(x, k, delay) All-pole lattice digital filter
glsadf(x, c, stage, delay) GLSA digital filter
mlsadf(x, b, alpha, pd, delay) MLSA digital filter
mglsadf(x, b, alpha, stage, delay) MGLSA digital filter

Utilities for waveform generation filters

poledf_delay(order) Delay for poledf
lmadf_delay(order, pd) Delay for lmadf
lspdf_delay(order) Delay for lspdf
ltcdf_delay(order) Delay for ltcdf
glsadf_delay(order, stage) Delay for glsadf
mlsadf_delay(order, pd) Delay for mlsadf
mglsadf_delay(order, stage) Delay for mglsadf


cdist(c1, c2[, otype, frame]) Calculation of cepstral distance