(signal, frame_length, frame_step, fft_length)
return real_spectrogram, imag_spectrogram
tflite-compatible implementation of tf.signal.stft.

  Compute the short-time Fourier transform of a 1D input while avoiding tf ops
  that are not currently supported in tflite (Rfft, Range, SplitV).
  fft_length must be fixed. A Hann window is of frame_length is always
  applied.

  Since fixed (precomputed) framing must be used, signal.shape[-1] must be a
  specific value (so "?"/None is not supported).

  Args:
    signal: 1D tensor containing the time-domain waveform to be transformed.
    frame_length: int, the number of points in each Fourier frame.
    frame_step: int, the number of samples to advance between successive frames.
    fft_length: int, the size of the Fourier transform to apply.

  Returns:
    Two (num_frames, fft_length) tensors containing the real and imaginary parts
    of the short-time Fourier transform of the input signal.
tflite-compatible implementation of tf.signal.stft.
tflite - compatible implementation of tf . signal . stft .
def _stft_tflite(signal, frame_length, frame_step, fft_length):
  """tflite-compatible implementation of tf.signal.stft.

  Compute the short-time Fourier transform of a 1D input while avoiding tf ops
  that are not currently supported in tflite (Rfft, Range, SplitV).
  fft_length must be fixed. A Hann window is of frame_length is always
  applied.

  Since fixed (precomputed) framing must be used, signal.shape[-1] must be a
  specific value (so "?"/None is not supported).

  Args:
    signal: 1D tensor containing the time-domain waveform to be transformed.
    frame_length: int, the number of points in each Fourier frame.
    frame_step: int, the number of samples to advance between successive frames.
    fft_length: int, the size of the Fourier transform to apply.

  Returns:
    Two (num_frames, fft_length) tensors containing the real and imaginary parts
    of the short-time Fourier transform of the input signal.
  """
  # Make the window be shape (1, frame_length) instead of just frame_length
  # in an effort to help the tflite broadcast logic.
  window = tf.reshape(
      tf.constant(
          (0.5 - 0.5 * np.cos(2 * np.pi * np.arange(0, 1.0, 1.0 / frame_length))
          ).astype(np.float32),
          name='window'), [1, frame_length])
  framed_signal = _fixed_frame(
      signal, frame_length, frame_step, first_axis=False)
  framed_signal *= window
  real_spectrogram, imag_spectrogram = _naive_rdft(framed_signal, fft_length)
  return real_spectrogram, imag_spectrogram
def _stft_tflite ( signal , frame_length , frame_step , fft_length ) : # Make the window be shape (1, frame_length) instead of just frame_length # in an effort to help the tflite broadcast logic. window = tf . reshape ( tf . constant ( ( 0.5 - 0.5 * np . cos ( 2 * np . pi * np . arange ( 0 , 1.0 , 1.0 / frame_length ) ) ) . astype ( np . float32 ) , name = 'window' ) , [ 1 , frame_length ] ) framed_signal = _fixed_frame ( signal , frame_length , frame_step , first_axis = False ) framed_signal *= window real_spectrogram , imag_spectrogram = _naive_rdft ( framed_signal , fft_length ) return real_spectrogram , imag_spectrogram