title: Stream binary audio data from http request for librosa analysis
body: <p>I have a large audio file streaming from a web service.</p>
  
  <p>I would like to load the audio data into librosa for batched stream analysis.</p>
  
  <p>I took a look at <a href="https://librosa.github.io/librosa/generated/librosa.core.stream.html" rel="nofollow noreferrer"><code>librosa.core.stream</code></a> where the description mentiones:</p>
  
  <blockquote>
    <p>Any codec supported by <a href="https://pysoundfile.readthedocs.io/en/latest/index.html#module-soundfile" rel="nofollow noreferrer"><code>soundfile</code></a> is permitted here.</p>
  </blockquote>
  
  <p>But I can't seem to figure out how I can feed the binary batch data from requests:</p>
  
  <pre class="lang-py prettyprint-override"><code>import requests
  import numpy as np
  
  audio_url = "http://localhost/media/audioplayback.m4a"
  
  response = requests.get(
      audio_url,
      stream=True,
  )
  
  for chunk in response.iter_content(chunk_size=4096):
      npChunk = np.frombuffer(chunk, dtype=np.float64)
      # Load chunk data into librosa
  </code></pre>
  
  <p>I know I need to convert the audio format but I'm not sure what is the recommended way to do this. I know it is possible to load the data directly into numpy array instead of calling <code>librosa.stream</code>. But I can't figure out the combination of <a href="https://github.com/bastibe/SoundFile" rel="nofollow noreferrer"><code>soundfile</code></a>, <a href="https://github.com/beetbox/audioread" rel="nofollow noreferrer"><code>audioread</code></a>, or <a href="https://gstreamer.freedesktop.org/" rel="nofollow noreferrer"><code>GStreamer</code></a> to do the format conversion.</p>
  
  <p>I am using python==3.6.5 inside conda environtment inside <a href="https://docs.microsoft.com/en-us/windows/wsl/about" rel="nofollow noreferrer">Windows Subsystem for Linux</a></p>
  
  <p>Any help would be greatly appreciated! Thank you!</p>