MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / inverse_stft

Function inverse_stft

tensorflow/python/ops/signal/spectral_ops.py:157–275  ·  view source on GitHub ↗

Computes the inverse [Short-time Fourier Transform][stft] of `stfts`. To reconstruct an original waveform, a complimentary window function should be used in inverse_stft. Such a window function can be constructed with tf.signal.inverse_stft_window_fn. Example: ```python frame_length =

(stfts,
                 frame_length,
                 frame_step,
                 fft_length=None,
                 window_fn=window_ops.hann_window,
                 name=None)

Source from the content-addressed store, hash-verified

155
156@tf_export('signal.inverse_stft')
157def inverse_stft(stfts,
158 frame_length,
159 frame_step,
160 fft_length=None,
161 window_fn=window_ops.hann_window,
162 name=None):
163 """Computes the inverse [Short-time Fourier Transform][stft] of `stfts`.
164
165 To reconstruct an original waveform, a complimentary window function should
166 be used in inverse_stft. Such a window function can be constructed with
167 tf.signal.inverse_stft_window_fn.
168
169 Example:
170
171 ```python
172 frame_length = 400
173 frame_step = 160
174 waveform = tf.compat.v1.placeholder(dtype=tf.float32, shape=[1000])
175 stft = tf.signal.stft(waveform, frame_length, frame_step)
176 inverse_stft = tf.signal.inverse_stft(
177 stft, frame_length, frame_step,
178 window_fn=tf.signal.inverse_stft_window_fn(frame_step))
179 ```
180
181 if a custom window_fn is used in stft, it must be passed to
182 inverse_stft_window_fn:
183
184 ```python
185 frame_length = 400
186 frame_step = 160
187 window_fn = functools.partial(window_ops.hamming_window, periodic=True),
188 waveform = tf.compat.v1.placeholder(dtype=tf.float32, shape=[1000])
189 stft = tf.signal.stft(
190 waveform, frame_length, frame_step, window_fn=window_fn)
191 inverse_stft = tf.signal.inverse_stft(
192 stft, frame_length, frame_step,
193 window_fn=tf.signal.inverse_stft_window_fn(
194 frame_step, forward_window_fn=window_fn))
195 ```
196
197 Implemented with GPU-compatible ops and supports gradients.
198
199 Args:
200 stfts: A `complex64` `[..., frames, fft_unique_bins]` `Tensor` of STFT bins
201 representing a batch of `fft_length`-point STFTs where `fft_unique_bins`
202 is `fft_length // 2 + 1`
203 frame_length: An integer scalar `Tensor`. The window length in samples.
204 frame_step: An integer scalar `Tensor`. The number of samples to step.
205 fft_length: An integer scalar `Tensor`. The size of the FFT that produced
206 `stfts`. If not provided, uses the smallest power of 2 enclosing
207 `frame_length`.
208 window_fn: A callable that takes a window length and a `dtype` keyword
209 argument and returns a `[window_length]` `Tensor` of samples in the
210 provided datatype. If set to `None`, no windowing is used.
211 name: An optional name for the operation.
212
213 Returns:
214 A `[..., samples]` `Tensor` of `float32` signals representing the inverse

Callers

nothing calls this directly

Calls 10

_enclosing_power_of_twoFunction · 0.85
with_rank_at_leastMethod · 0.80
assert_has_rankMethod · 0.80
maximumMethod · 0.80
name_scopeMethod · 0.45
as_listMethod · 0.45
rankMethod · 0.45
shapeMethod · 0.45
concatMethod · 0.45
set_shapeMethod · 0.45

Tested by

no test coverage detected