Conversion#
- pylstraight.f0_to_f0(f0: ndarray, in_format: str, out_format: str, fs: int = 0) ndarray [source]#
Convert F0 between different formats.
- Parameters:
- f0np.ndarray [shape=(nframe,)]
The input F0.
- in_format[‘inverse’, ‘linear’, ‘log’]
The format of the input F0.
- out_format[‘inverse’, ‘linear’, ‘log’]
The format of the output F0.
- fsint
The sampling frequency in Hz. This is required when the input or output format is inverse.
- Returns:
- outnp.ndarray [shape=(nframe,)]
The converted F0.
Examples
>>> import pylstraight as pyls >>> import numpy as np >>> f0 = np.array([100, 200, 0, 400]) >>> pyls.f0_to_f0(f0, "linear", "log") array([ 4.60517019e+00, 5.29831737e+00, -1.00000000e+10, 5.99146455e+00]) >>> pyls.f0_to_f0(f0, "linear", "inverse", fs=16000) array([160., 80., 0., 40.])
- pylstraight.ap_to_ap(ap: ndarray, in_format: str, out_format: str) ndarray [source]#
Convert aperiodicity between different formats.
- Parameters:
- apnp.ndarray [shape=(nframe, nfreq)]
The input aperiodicity.
- in_format[‘a’, ‘p’, ‘a/p’, ‘p/a’]
The format of the input aperiodicity.
- out_format[‘a’, ‘p’, ‘a/p’, ‘p/a’]
The format of the output aperiodicity.
- Returns:
- outnp.ndarray [shape=(nframe, nfreq)]
The converted aperiodicity.
Examples
>>> import pylstraight as pyls >>> import numpy as np >>> ap = np.array([[0.3, 0.5, 0.9]]) >>> pyls.ap_to_ap(ap, "a", "p") array([[0.7, 0.5, 0.1]]) >>> pyls.ap_to_ap(ap, "a", "a/p") array([[0.42857143, 1. , 9. ]])
- pylstraight.sp_to_sp(sp: ndarray, in_format: str, out_format: str) ndarray [source]#
Convert spectrum between different formats.
- Parameters:
- spnp.ndarray [shape=(nframe, nfreq)]
The input spectrum.
- in_format[‘db’, ‘log’, ‘linear’, ‘power’]
The format of the input spectrum.
- out_format[‘db’, ‘log’, ‘linear’, ‘power’]
The format of the output spectrum.
- Returns:
- outnp.ndarray [shape=(nframe, nfreq)]
The converted spectrum.
Examples
>>> import pylstraight as pyls >>> import numpy as np >>> sp = np.array([[-10, 60, 0]]) >>> pyls.sp_to_sp(sp, "db", "linear") array([[3.16227766e-01, 1.00000000e+03, 1.00000000e+00]]) >>> pyls.sp_to_sp(sp, "db", "log") array([[-1.15129255, 6.90775528, 0. ]])