2011-01-23 31 views

回答

3

如果你不依賴於numpy的心,我的包AUDIOLAB的工作得很好,只要libsndfile本身支持開箱的支持oggfile(它應該在Linux上,如果你的版本是足夠新):

# the dependencies 
sudo apt-get install libsndfile-dev python-numpy cython python-setuptools 
# install audiolab 
cd audiolab-0.11 && python setup.py install --user 

基本的API很簡單:

from scikits.audiolab.pysndfile.matapi import oggread 
data, fs, enc = oggread("myfile.ogg") 

控制輸出D類,範圍等更完整的API ...也可以。你可以發現PyPI上發佈,並在github

+0

是否Python的3下這項工作? – detly

1

前段時間我嘗試在Python中編寫一些遊戲原型,並使用了pygame。 http://www.pygame.org/news.html 你應該能夠在突觸中找到它,它應該安裝所有需要的依賴項,如果ogg不起作用,你可能需要libvorbis,但你很可能已經安裝了它。無論如何,最好的辦法是閱讀pygame。如果這不是一個讓你可能需要另一個圖書館的遊戲。但是,我可以建議的是嘗試搜索。

0

我用PY-的GStreamer播放OGG文件與下面的代碼的代碼

import sys, os 

##FOR UBUNTU 13.04 onwards 
import gi 
gi.require_version('Gst', '1.0') 
from gi.repository import GObject, Gst, Gtk 
##end 
GObject.threads_init() 
Gst.init(None) 

uri = "http://blender-podcast.org/episodes/Blender_Podcast_Episode_028.ogg" 
#pipeline = Gst.Pipeline() 
#delay = Gst.ElementFactory.make("audiodelay","delay") 
player = Gst.ElementFactory.make("playbin", "player") 
fakesink = Gst.ElementFactory.make("fakesink", "fakesink") 
# pipeline.add(player) 
# pipeline.add(fakesink) 

player.set_property('uri', uri) 
player.set_property("video-sink", fakesink) 
player.set_state(Gst.State.PLAYING) 
Gtk.main() 

安裝

sudo apt-get install libgstreamer1.0-0 libgstreamer1.0-0-dbg libgstreamer1.0-dev liborc-0.4-0 liborc-0.4-0-dbg liborc-0.4-dev liborc-0.4-doc gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-alsa gstreamer1.0-doc gstreamer1.0-omx gstreamer1.0-plugins-bad gstreamer1.0-plugins-bad-dbg gstreamer1.0-plugins-bad-doc gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-base-dbg gstreamer1.0-plugins-base-doc gstreamer1.0-plugins-good gstreamer1.0-plugins-good-dbg gstreamer1.0-plugins-good-doc gstreamer1.0-plugins-ugly gstreamer1.0-plugins-ugly-dbg gstreamer1.0-plugins-ugly-doc gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-x libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-bad1.0-dev libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev