Python的Pyaudio - 如何发挥通过HTTP流式文件 [英] Python Pyaudio -- How to play a file streamed via HTTP

查看:486
本文介绍了Python的Pyaudio - 如何发挥通过HTTP流式文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何发挥存在在我的服务器通过HTTP服务的MP3。我试图找出pyglet但也有与AVBin太多的问题,使这项工作(这是在源$ C ​​$ C除以零)。所以,我决定尝试PyAudio,但我想不出如何与它进行流从HTTP的MP3音源。所有的例子都是wav文件,我需要的例子,而不是文档或恐怕我得弄清楚如何音频作品的细节上的最低水平。所有的文档是混乱对我们这些不知道的行话(采样率等)。谁能帮助?

I am trying to figure out how to play an mp3 that exists on my server served through HTTP. I tried to figure out pyglet but there were too many issues with AVBin to make that work (something about dividing by zero in the source code). So, I decided to try PyAudio, but I can't figure out how to stream an mp3 source from HTTP with it. All the examples are wav files and I need examples rather than the docs or I'm afraid I'll have to figure out the particulars of how audio works on the lowest level. All the documentation is confusing for those of us that don't know the lingo (sample rate, etc). Can anyone help?

推荐答案

什么是您的源和目标服务器环境? [Windows / Linux版/ Mac吗? ]。也是您试图播放音频文件或视频?

What is your source and target server environments? [ windows / linux / mac? ]. Also are your trying to play an audio file or video?

在这两种情况下,你可以使用的Gstreamer与Python 的。我有Windows笔记本电脑,所以我试图在GStreamer 1.0.x的从这里

In either case you can use Gstreamer with python. I've windows laptop, so I tried with Gstreamer 1.0.x from here

在线实例是为的Gstreamer 0.10不与较新的Gstreamer 1.0工作。有很多修改是特定的平台。
但是,在Windows的Gstreamer带有GST推出二进制文件,作品下架。 [对于Linux有相当于二进制]

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 ]

在服务器端,你需要设置HTTP服务器。不知道你的环境的具体情况我可以说,有可用的各种解决方案,包括Python HTTP服务器 SimpleHTTPServer 。结果
见配液<一个href=\"http://stackoverflow.com/questions/17351016/set-up-python-simplehttpserver-on-windows\">here

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

在HTTP服务器安装并运行,在你的笔记本电脑,你可以简单地运行结果
C:\\ Python27 \\ LIB \\站点包\\侏儒&GT; \\ GST-的launch.exe playbin URI = http://www.freesound.org/data/$p$pviews/148/1482641337920-lq.mp3

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

您的服务器地址和端口替换HTTP服务器地址。

Replace http server address with your server address and port.

您可以拨打GST推出在python脚本去创作它。

You can call gst-launch in your python script and go creative with it.

我从成功freesound.org打开音频文件。它应该打开一个音频文件从你的HTTP服务器所服务也是如此。

I've opened audio files from freesound.org successfully. It should open a audio file being served from your http server as well.

在这里输入的形象描述

这篇关于Python的Pyaudio - 如何发挥通过HTTP流式文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆