# tf.signal.inverse_stft

<br />

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

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

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.signal.inverse_stft(
        stfts,
        frame_length,
        frame_step,
        fft_length=None,
        window_fn=https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/signal/hann_window,
        name=None
    )

To reconstruct an original waveform, a complementary window function should
be used with `inverse_stft`. Such a window function can be constructed with
[`tf.signal.inverse_stft_window_fn`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/signal/inverse_stft_window_fn).
Example:

    frame_length = 400
    frame_step = 160
    waveform = tf.random.normal(dtype=tf.float32, shape=[1000])
    stft = tf.signal.stft(waveform, frame_length, frame_step)
    inverse_stft = tf.signal.inverse_stft(
        stft, frame_length, frame_step,
        window_fn=tf.signal.inverse_stft_window_fn(frame_step))

If a custom `window_fn` is used with [`tf.signal.stft`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/signal/stft), it must be passed to
[`tf.signal.inverse_stft_window_fn`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/signal/inverse_stft_window_fn):

    frame_length = 400
    frame_step = 160
    window_fn = tf.signal.hamming_window
    waveform = tf.random.normal(dtype=tf.float32, shape=[1000])
    stft = tf.signal.stft(
        waveform, frame_length, frame_step, window_fn=window_fn)
    inverse_stft = tf.signal.inverse_stft(
        stft, frame_length, frame_step,
        window_fn=tf.signal.inverse_stft_window_fn(
           frame_step, forward_window_fn=window_fn))

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

<br />

<br />

<br />

| ## Args ||
|---|---|
| `stfts` | A `complex64`/`complex128` `[..., frames, fft_unique_bins]` `Tensor` of STFT bins representing a batch of `fft_length`-point STFTs where `fft_unique_bins` is `fft_length // 2 + 1` |
| `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 that produced `stfts`. 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. |
| `name` | An optional name for the operation. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `[..., samples]` `Tensor` of `float32`/`float64` signals representing the inverse STFT for each input STFT in `stfts`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `stfts` is not at least rank 2, `frame_length` is not scalar, `frame_step` is not scalar, or `fft_length` is not scalar. |

<br />