I have a large audio file streaming from a web service.
I would like to load the audio data into librosa for batched stream analysis.
I took a look at librosa.core.stream
where the description mentiones:
Any codec supported by
soundfile
is permitted here.
But I can't seem to figure out how I can feed the binary batch data from requests:
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
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 librosa.stream
. But I can't figure out the combination of soundfile
, audioread
, or GStreamer
to do the format conversion.
I am using python==3.6.5 inside conda environtment inside Windows Subsystem for Linux
Any help would be greatly appreciated! Thank you!