Core SPTK API

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)

Warning

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.

Note

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
acorr(x, order) Autocorrelation

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, use_scipy]) Linear prediction analysis

MFCC

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, …]) LPC to LSP
lpc2par(lpc) LPC to PARCOR
par2lpc(par) PARCOR to LPC
lsp2lpc(lsp[, has_gain, loggain, fs, itype]) LSP to LPC
lsp2sp(lsp[, fftlen, has_gain, loggain, fs, …]) 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
levdur(r[, eps, use_scipy]) Solve an Autocorrelation Normal Equation Using Levinson-Durbin Method
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

zerodf(x, b, delay) All zero digital filter
zerodft(x, b, delay) Transpose All zero digital filter
poledf(x, a, delay) All-pole digital filter
poledft(x, a, delay) Transpose 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
glsadft(x, c, stage, delay) Transpose GLSA digital filter
mlsadf(x, b, alpha, pd, delay) MLSA digital filter
mlsadft(x, b, alpha, pd, delay) Transpose MLSA digital filter
mglsadf(x, b, alpha, stage, delay) MGLSA digital filter
mglsadft(x, b, alpha, stage, delay) Transpose MGLSA digital filter

Utilities for waveform generation filters

zerodf_delay(order) Delay for zerodf
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

Metrics

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