nnmnkwii.preprocessing.mulaw_quantize¶
-
nnmnkwii.preprocessing.
mulaw_quantize
(x, mu=256)[source]¶ Mu-Law companding + quantize
- Parameters
x (array-like) – Input signal. Each value of input signal must be in range of [-1, 1].
mu (number) – Compression parameter
μ
.
- Returns
- Quantized signal (dtype=int)
y ∈ [0, mu] if x ∈ [-1, 1]
y ∈ [0, mu) if x ∈ [-1, 1)
- Return type
array-like
Note
If you want to get quantized values of range [0, mu) (not [0, mu]), then you need to provide input signal of range [-1, 1).
Examples
>>> from scipy.io import wavfile >>> import pysptk >>> import numpy as np >>> from nnmnkwii import preprocessing as P >>> fs, x = wavfile.read(pysptk.util.example_audio_file()) >>> x = (x / 32768.0).astype(np.float32) >>> y = P.mulaw_quantize(x) >>> print(y.min(), y.max(), y.dtype) 15 246 int64