def istft( signal, num_samples, *, stft_size=512, stft_shift=128, stft_window_length=None, stft_window='hann', ): time_signal = _istft( signal, size=stft_size, shift=stft_shift, window_length=stft_window_length, window=stft_window, # num_samples=num_samples, # this stft does not support num_samples ) pad = True if pad: assert time_signal.shape[-1] >= num_samples, (time_signal.shape, num_samples) assert time_signal.shape[-1] < num_samples + stft_shift, ( time_signal.shape, num_samples) time_signal = time_signal[..., :num_samples] else: raise ValueError( pad, 'When padding is False in the stft, the signal is cutted.' 'This operation can not be inverted.', ) return time_signal
def istft(signal, num_samples): return _istft(signal, 512, 128)[..., :num_samples]