<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/ops/signal/spectral_ops.py#L34-L92) |

Computes the [Short-time Fourier Transform](https://en.wikipedia.org/wiki/Short-time_Fourier_transform) of `signals`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.signal.stft`](https://www.tensorflow.org/api_docs/python/tf/signal/stft)

<br />

    tf.signal.stft(
        signals,
        frame_length,
        frame_step,
        fft_length=None,
        window_fn=https://www.tensorflow.org/api_docs/python/tf/signal/hann_window,
        pad_end=False,
        name=None
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Simple audio recognition: Recognizing keywords](https://www.tensorflow.org/tutorials/audio/simple_audio) |

Implemented with TPU/GPU-compatible ops and supports gradients.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `signals` | A `[..., samples]` `float32`/`float64` `Tensor` of real-valued signals. |
| `frame_length` | An integer scalar `Tensor`. The window length in samples. |
| `frame_step` | An integer scalar `Tensor`. The number of samples to step. |
| `fft_length` | An integer scalar `Tensor`. The size of the FFT to apply. If not provided, uses the smallest power of 2 enclosing `frame_length`. |
| `window_fn` | A callable that takes a window length and a `dtype` keyword argument and returns a `[window_length]` `Tensor` of samples in the provided datatype. If set to `None`, no windowing is used. |
| `pad_end` | Whether to pad the end of `signals` with zeros when the provided frame length and step produces a frame that lies partially past its end. |
| `name` | An optional name for the operation. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `[..., frames, fft_unique_bins]` `Tensor` of `complex64`/`complex128` STFT values where `fft_unique_bins` is `fft_length // 2 + 1` (the unique components of the FFT). ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `signals` is not at least rank 1, `frame_length` is not scalar, or `frame_step` is not scalar. |

<br />