def inv_preemphasis(x, coef=0.97):
"""Inverse operation of pre-emphasis
Args:
x (1d-array): Input signal.
coef (float): Pre-emphasis coefficient.
Returns:
array: Output filtered signal.
See also:
:func:`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
>>> x_hat = P.inv_preemphasis(P.preemphasis(x, coef=0.97), coef=0.97)
>>> assert np.allclose(x, x_hat)
"""
b = np.array([1.], x.dtype)
a = np.array([1., -coef], x.dtype)
return signal.lfilter(b, a, x)
评论列表
文章目录