Python Pyaudio -- How To Play A File Streamed Via HTTP
Solution 1:
What is your source and target server environments? [ windows / linux / mac? ]. Also are your trying to play an audio file or video?
In either case you can use Gstreamer with python. I've windows laptop, so I tried with Gstreamer 1.0.x from here
Online examples are for Gstreamer 0.10 that does not work with newer Gstreamer 1.0. There lots of modifications that are platform specific. However, on windows Gstreamer comes with gst-launch binary which works off the shelf. [ For Linux there is equivalent binary ]
Setup
Server Side:
On server side, you need to setup HTTP server. Without knowing specifics of your environment I can say that there are various solutions available , including python http server SimpleHTTPServer
.
See solution here
Client Side :
Once http server is installed and running, on your laptop, you can simply run
C:\Python27\Lib\site-packages\gnome> .\gst-launch.exe playbin uri = http://www.freesound.org/data/previews/148/1482641337920-lq.mp3
Replace http server address with your server address and port.
You can call gst-launch in your python script and go creative with it.
OutPut:
I've opened audio files from freesound.org successfully. It should open a audio file being served from your http server as well.
Post a Comment for "Python Pyaudio -- How To Play A File Streamed Via HTTP"