pysptk

A python wrapper for Speech Signal Processing Toolkit (SPTK).

https://github.com/r9y9/pysptk

Full documentation

A full documentation of SPTK is available at http://sp-tk.sourceforge.net.

The wrapper is based on a modified version of SPTK (r9y9/SPTK)

Installation guide

Installation guide

The latest release is availabe on pypi. You can install it by:

pip install pysptk

Note that you have to install numpy to build C-extensions.

If yout want the latest development version, run:

pip install git+https://github.com/r9y9/pysptk

or:

git clone https://github.com/r9y9/pysptk
cd pysptk
python setup.py develop # or install

This should resolve the package dependencies and install pysptk property.

Note

If you use the development version, you need cython installed to compile cython module(s).

API documentation

API

Core SPTK API

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

Note

Almost all of pysptk functions assume that the input array is C-contiguous and has float64 element type.

Library routines
agexp Magnitude squared generalized exponential function
gexp Generalized exponential function
glog Generalized logarithmic function
mseq M-sequence
Adaptive cepstrum analysis
acep Adaptive cepstral analysis
agcep Adaptive generalized cepstral analysis
amcep Adaptive mel-cepstral analysis
Mel-generalized cepstrum analysis
mcep Mel-cepstrum analysis
gcep Generalized-cepstrum analysis
mgcep Mel-generalized cepstrum analysis
uels Unbiased estimation of log spectrum
fftcep FFT-based cepstrum analysis
lpc Linear prediction analysis
MFCC
mfcc MFCC
LPC, LSP and PARCOR conversions
lpc2c LPC to cepstrum
lpc2lsp LPC to LSP
lpc2par LPC to PARCOR
par2lpc PARCOR to LPC
lsp2sp LSP to spectrum
Mel-generalized cepstrum conversions
mc2b Mel-cepsrum to MLSA filter coefficients
b2mc MLSA filter coefficients to mel-cesptrum
c2acr Cepstrum to autocorrelation
c2ir Cepstrum to impulse response
ic2ir Impulse response to cepstrum
c2ndps Cepstrum to Negative Derivative of Phase Spectrum (NDPS)
ndps2c Cepstrum to Negative Derivative of Phase Spectrum (NDPS)
gc2gc Generalized cepstrum transform
gnorm Gain normalization
ignorm Inverse gain normalization
freqt Frequency transform
mgc2mgc Mel-generalized cepstrum transform
mgc2sp Mel-generalized cepstrum transform
mgclsp2sp MGC-LSP to spectrum
F0 analysis
swipe SWIPE’ - A Saw-tooth Waveform Inspired Pitch Estimation
Window functions
blackman Blackman window
hamming Hamming window
hanning Hanning window
bartlett Bartlett window
trapezoid Trapezoid window
rectangular Rectangular window
Waveform generation filters
poledf All-pole digital filter
lmadf LMA digital filter
lspdf LSP synthesis digital filter
ltcdf All-pole lattice digital filter
glsadf GLSA digital filter
mlsadf MLSA digital filter
mglsadf MGLSA digital filter
Utilities for waveform generation filters
poledf_delay Delay for poledf
lmadf_delay Delay for lmadf
lspdf_delay Delay for lspdf
ltcdf_delay Delay for ltcdf
glsadf_delay Delay for glsadf
mlsadf_delay Delay for mlsadf
mglsadf_delay Delay for mglsadf
Other conversions
mgc2b(mgc[, alpha, gamma]) Mel-generalized cepstrum to MGLSA filter coefficients

High-level interface for waveform synthesis

Module pysptk.synthesis provides high-leve interface that wraps low-level SPTK waveform synthesis functions (e.g. mlsadf),

Synthesizer
class pysptk.synthesis.Synthesizer(filt, hopsize)

Speech waveform synthesizer

Attributes:
filt : SynthesisFilter

A speech synthesis filter

hopsize : int

Hop size

synthesis(source, b)

Synthesize a waveform given a source excitation and sequence of filter coefficients (e.g. cepstrum).

Parameters:
source : array

Source excitation

b : array

Filter coefficients

Returns:
y : array, shape (same as source)

Synthesized waveform

synthesis_one_frame(source, prev_b, curr_b)

Synthesize one frame waveform

Parameters:
source : array

Source excitation

prev_b : array

Filter coefficients of previous frame

curr_b : array

Filter coefficients of current frame

Returns:
y : array

Synthesized waveform

SynthesisFilters
LMADF
class pysptk.synthesis.LMADF(order=25, pd=4)

LMA digital filter that wraps lmadf

Attributes:
pd : int

Order of pade approximation. Default is 4.

delay : array

Delay

filt(x, coef)

Filter one sample using using lmadf

Parameters:
x : float

A input sample

coef: array

LMA filter coefficients (i.e. Cepstrum)

Returns:
y : float

A filtered sample

MLSADF
class pysptk.synthesis.MLSADF(order=25, alpha=0.35, pd=4)

MLSA digital filter that wraps mlsadf

Attributes:
alpha : float

All-pass constant

pd : int

Order of pade approximation. Default is 4.

delay : array

Delay

filt(x, coef)

Filter one sample using mlsadf

Parameters:
x : float

A input sample

coef: array

MLSA filter coefficients

Returns:
y : float

A filtered sample

MGLSADF
class pysptk.synthesis.MGLSADF(order=25, alpha=0.35, stage=1)

MGLSA digital filter that wraps mglsadf

Attributes:
alpha : float

All-pass constant

stage : int

-1/gamma

delay : array

Delay

filt(x, coef)

Filter one sample using mglsadf

Parameters:
x : float

A input sample

coef: array

MGLSA filter coefficients

Returns:
y : float

A filtered sample

AllPoleDF
class pysptk.synthesis.AllPoleDF(order=25)

All-pole digital filter that wraps poledf

Attributes:
delay : array

Delay

filt(x, coef)

Filter one sample using using poledf

Parameters:
x : float

A input sample

coef: array

LPC (with loggain)

Returns:
y : float

A filtered sample

AllPoleLatticeDF
class pysptk.synthesis.AllPoleLatticeDF(order=25)

All-pole lttice digital filter that wraps ltcdf

Attributes:
delay : array

Delay

filt(x, coef)

Filter one sample using using ltcdf

Parameters:
x : float

A input sample

coef: array

PARCOR coefficients (with loggain)

Returns:
y : float

A filtered sample

Synthesis filter interface
class pysptk.synthesis.SynthesisFilter

Synthesis filter interface

All synthesis filters must implement this interface

filt(x, coef)

Filter one sample

Parameters:
x : float

A input sample

coef : array

Filter coefficients

Returns:
y : float

A filtered sample

Utilities

Audio files
example_audio_file() Get the path to an included audio example file.

Indices and tables