title: How to resample audio file using Tensorflow API
body: <p>I'm using tf.data.Dataset as pipeline in tensorflow to read and transform audio. 
  I wanted to add audio resampling to reduce overfitting. I googled for a way to resample files in python/tensorflow and I found python only solutions like resampy. It works great but it slows down my pipline 10 times as I had to use tf.py_func to run it. My audio files are 1 second long with rate 16000, below is my code that does the resampling and then pads or clip the resulting array:</p>
  
  <pre><code>def _resample(pcm, label):
      if resample_range &lt; 1e-8:
          return pcm, label
  
      import resampy
      desired_samples=16000
      def clip_o_pad(pcm):
          margin = pcm.shape[0] - desired_samples + 2
          if margin &gt; 0:
              out = pcm[margin // 2: (pcm.shape[0] - margin // 2)]
          elif margin &lt; 0:
              out = np.pad(clip, -margin // 2, 'constant', constant_values=(0))
          else:
              out = pcm
          return out[:desired_samples]
  
      def _resample_py(pcm):
          pcm = pcm.reshape(desired_samples)
          new_rate = np.random.randint(desired_samples*(1-resample_range), desired_samples*(1+resample_range))
          resampled = resampy.resample(pcm, desired_samples, new_rate)
          out = clip_o_pad(resampled)
          out = out.reshape(desired_samples,1)
          return out
  
      return tf.py_func(_resample_py, [pcm], pcm.dtype), label
  </code></pre>
  
  <p>Do you know about any library / function in tensorflow that would allow me to do the same in pure tensorflow graph (ie without using py_func)</p>