mindspore/docs/api/api_python/ops/mindspore.ops.func_stft.rst

53 lines
3.6 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.stft
==================
.. py:function:: mindspore.ops.stft(x, n_fft, hop_length=None, win_length=None, window=None, center=True, pad_mode="REFLECT", normalized=False, onesided=None, return_complex=None)
STFT将信号分割成狭窄的时间间隔并对每个片段进行傅立叶变换来量化非平稳信号频率和相位随时间的变化。
忽略批处理维,此操作计算以下表达式:
.. math::
X[\omega, m]=\sum_{k=0}^{\text {win_length-1 }}
\text { window }[k] \text { input }[m \times \text { hop_length }+
k] \exp \left(-j \frac{2 \pi \cdot \omega k}{\text { win_length }}\right)
其中 :math:`m` 是滑动窗口的索引,:math:`ω` 是频率,其范围在 :math:`0 \leq \omega < \text{n\_fft}0≤ω<n_fft`
参数:
- **x** (Tensor) - STFT的时间序列必须是1-D Tensor或2-D Tensor。
- **n_fft** (int) - 傅里叶变换的尺寸。
- **hop_length** (int可选) - 相邻滑动窗口之间的距离。如果为None取值视为 :math:`floor(n_fft / 4)` 。默认值None。
- **win_length** (int可选) - 窗口和STFT过滤器的尺寸。如果为None取值视为 `n_fft` 。默认值None。
- **window** (Tensor可选) - 可选的窗口函数,是一个长度为 `win_length` 的一维Tensor。如果为None视为所含元素都为1。如果 `win_length` < `n_fft` ,在 `window` 两侧填充1至长度为 `n_fft` 后才生效。默认值None。
- **center** (bool可选) - 是否填充 `x` 两侧。默认值True。
- **pad_mode** (str可选) - `center` 为True的时候指定的填充模式。默认值“REFLECT”。
- **normalized** (bool可选) - 控制是否返回规范化的STFT结果。默认值False。
- **onesided** (bool可选) - 控制是否返回一半的结果以避免实数输入计算结果的冗余。默认值None。当 `x``window` 是实数时取值为True否则为False。
- **return_complex** (bool可选) - 若为True返回一个复数Tensor。若为False返回一个实数Tensor
且其具有额外的最后一维以表示实部和虚部。默认值None。当 `x``window` 为复数时取值为True否则为False。
返回:
- **output** (Tensor) - 包含STFT计算的结果的Tensor。
- 如果 `return_complex` 为True则返回一个复数Tensorshape为 :math:`(*, N, T)`
- 如果 `return_complex` 为False则返回一个实数Tensorshape为 :math:`(*, N, T, 2)`
`N` 为傅立叶变换的尺寸,取值受参数 `onesided` 影响:
- 如果 `onesided` 为False :math:`N = n_fft`
- 如果 `onesided` 为True :math:`N = n_fft // 2 + 1`
`T` 为使用的总帧数,计算公式::math:`T = 1 + (len - n_fft) / hop_length` ,其中 :math:`len` 取值受 `center` 影响:
- 如果 `center` 为False:math:`len = signal_length`
- 如果 `center` 为True:math:`len = signal_length + (n_fft // 2) * 2`
其中signal_length为信号长度取值 :math:`x.shape[-1]`
异常:
- **TypeError** - `x` 不是1-D或2-D Tensor。
- **TypeError** - `window` 不是1-DTensor。
- **TypeError** - `center``normalized``onesided``return_complex` 中任意一个被指定了非布尔类型的值。
- **TypeError** - `pad_mode` 被指定了非str类型的值。
- **TypeError** - `n_fft``hop_length``hop_length` 中任意一个不是int类型。