title: Proper usage of tensorflows STFT function
body: <p>I am trying to construct a plot spectrum of an audio sample similar to the one that is created using Audacity. From Audacity's wiki page, the plot spectrum (attached example) performs:</p>
  
  <blockquote>
    <p>Plot Spectrum take the audio in blocks of 'Size' samples, does the
    FFT, and averages all the blocks together.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/bMmLl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bMmLl.png" alt="enter image description here"></a></p>
  
  <p>I was thinking I would use the STFT functionality recently provided by Tensorflow.</p>
  
  <p>I am using audio blocks of size 512, and my code is as follows:</p>
  
  <pre><code>audio_binary = tf.read_file(audio_file)
  waveform = tf.contrib.ffmpeg.decode_audio(
      audio_binary,
      file_format="wav",
      samples_per_second=4000,
      channel_count=1
  )
  
  stft = tf.contrib.signal.stft(
      waveform,
      512,     # frame_length
      512,     # frame_step
      fft_length=512,
      window_fn=functools.partial(tf.contrib.signal.hann_window, periodic=True), # matches audacity
      pad_end=True,
      name="STFT"
  )
  </code></pre>
  
  <p>But the results of stft are is just an empty array when I expect the FFT results for each frame (of 512 samples)</p>
  
  <p>What is wrong with the way that I am making this call?</p>
  
  <p>I have verified that waveform audio data is being correctly read with just the regular <code>tf.fft</code> function.</p>