nnmnkwii.preprocessing.modspec(x, n=4096, norm=None, return_phase=False)[source]

Modulation spectrum (MS) computation

Given a parameter trajectory, it computes modulation spectrum. In the library, we define modulation spectrum as power of discrete Fourier transform of parameter trajectory across time-axis. See [1] for example application.


Takamichi, Shinnosuke, et al. “A postfilter to modify the modulation spectrum in HMM-based speech synthesis.” Acoustics, Speech and Signal Processing (ICASSP), 2014 IEEE International Conference on. IEEE, 2014.


This may move in different module in future.

  • y (numpy.ndarray) – Parameter trajectory, shape (T x D).

  • n (int) – DFT length

  • norm (str) – Normalization mode. See numpy.fft.fft().

  • return_phase (bool) – If True, return phase of MS.


Modulation spectrum (n//2 + 1 x D) and phase (if return_phase is True).

Return type

tuple or numpy.ndarray


>>> import numpy as np
>>> from nnmnkwii import preprocessing as P
>>> generated = np.random.rand(10, 2)
>>> ms = P.modspec(generated, n=16)
>>> ms.shape
(9, 2)