I tried several ways: from within a terminal window, with R and with Julia. None was successful so far. I guess the main issue is the fact that online streams do not have and ‘end’.
Perhaps someone here can help me out, as I am not too familiar with the Julia Audio packages. Any help is welcome, thanks in advance!
I looked into PortAudio.jl and I can now sample from an analog input like my mic. Works very well.
Now I need to grab a few seconds of data from an online audio stream, i.e. already digitized. Unfortunately, MP3.jl doesn’t support reading from a stream as far as I know…
Have you tried with sockets to grab few seconds of data like pyaudio example ?
This example was for julia 0.6, but it may still work: How to read from socket in non-blocking mode - #6 by Keno
Instead of while !eof(socket)
You can use size of received data…
using HTTP
HTTP.open("GET", "http://ais.absoluteradio.co.uk/absoluteclassicrock.mp3") do http
n = Ref(0)
r = startread(http)
while !eof(http) && n[] < 1000
bytes = read(http, 100)
println("GET data: $bytes")
n[]+=length(bytes)
end
@show n
end