vendredi 13 février 2015

Decoding compressed audio byte array in Python

My goal is to process audio data captured from web stream (internet radio) in Python 3.4. Capturing is done with the use of urllib package:



radio_data = urllib.request.urlopen(url)
while SOME_STATEMENT:
samples = r.read(n_bytes)
# decoding
# processing


'Samples' array contains of audio compressed values (bytes), in my case encoded with OGG. Writing the stream to the file works fine, so the data are good. I need to decode them every single time new frame is captured to apply some processing in real time, without writing to file. I tried it with pyglet, but it accept only a name of the file as argument, and I don't want to change internal code of the library. PyAudio do not support encoded files. There was a solution like Pymedia, but it wasnt ported to Python 3. There is also GStreamer package, but I found solutions working only on saved files, not on binary data. I have found some other packages like decoder-1.5XB-Win32, but they work only on files or cant be used with python 3. Does anyone know solution for decoding audio data (ogg, mp3, aac) directly from array?


Aucun commentaire:

Enregistrer un commentaire