def preemphasis(x, coef=0.97):
"""Pre-emphasis
Args:
x (1d-array): Input signal.
coef (float): Pre-emphasis coefficient.
Returns:
array: Output filtered signal.
See also:
:func:`inv_preemphasis`
Examples:
>>> from nnmnkwii.util import example_audio_file
>>> from scipy.io import wavfile
>>> fs, x = wavfile.read(example_audio_file())
>>> x = x.astype(np.float64)
>>> from nnmnkwii import preprocessing as P
>>> y = P.preemphasis(x, coef=0.97)
>>> assert x.shape == y.shape
"""
b = np.array([1., -coef], x.dtype)
a = np.array([1.], x.dtype)
return signal.lfilter(b, a, x)
评论列表
文章目录