Synthesis#

pylstraight.synthesize(f0: np.ndarray, ap: np.ndarray, sp: np.ndarray, fs: int, *, frame_shift: float = 5.0, f0_format: str = 'linear', ap_format: str = 'a', sp_format: str = 'linear', syn_param: SynParam | None = None) np.ndarray[source]#

Synthesize waveform from F0, aperiodicity, and spectrum.

Parameters:
f0np.ndarray [shape=(nframe,)]

The fundamental frequency.

apnp.ndarray [shape=(nframe, nfreq)]

The aperiodicity.

spnp.ndarray [shape=(nframe, nfreq)]

The spectrum.

fsint

The sampling frequency in Hz.

frame_shiftfloat

The frame shift in msec.

f0_format[‘inverse’, ‘linear’, ‘log’]

The format of F0.

ap_format[‘a’, ‘p’, ‘a/p’, ‘p/a’]

The format of aperiodicity.

sp_format[‘db’, ‘log’, ‘linear’, ‘power’]

The format of spectrum.

syn_paramSynParam or None

Control parameters for the synthesis. If given, override the other parameters. You have full control and responsibility.

Returns:
outnp.ndarray [shape=(nsample,)]

The synthesized waveform.

Examples

>>> import pylstraight as pyls
>>> import numpy as np
>>> f, fs = 200, 16000
>>> x = np.sin(2 * np.pi * f / fs * np.arange(2400)) / 2
>>> f0 = np.ones(30) * f
>>> ap = pyls.extract_ap(x, fs, f0)
>>> sp = pyls.extract_sp(x, fs, f0)
>>> y = pyls.synthesize(f0, ap, sp, fs)
>>> y.shape
(2400,)
pylstraight.init_syn_param() SynParam[source]#

Make a default synthesis parameter set.

Returns:
outSynParam

Control parameter set for the synthesis.