什么是跨平台的方式在python播放声音文件? [英] What's a cross platform way to play a sound file in python?
本文介绍了什么是跨平台的方式在python播放声音文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用打一个pyaudio .wav文件。它在Windows很大,但是当另一台设备正在使用声音在Ubuntu不起作用。
I tried playing a .wav file using pyaudio. It works great on windows, but doesn't work in Ubuntu when another device is using sound.
该错误是IO错误:[Errorno
无效的输出设备(无默认值
输出设备)-9996
The error is "IOError: [Errorno Invalid output device (no default output device)] -9996
难道还有其他图书馆,我可以尝试使用?另一种方法?
Is there another library I could try to use? Another method?
推荐答案
您可以使用 wxPython的
sound = wx.Sound('sound.wav')
sound.Play(wx.SOUND_SYNC)
或
sound.Play(wx.SOUND_ASYNC)
<一个href=\"http://svn.wxwidgets.org/viewvc/wx/wxPython/tags/wxPy-2.8.9.1/wxPython/demo/Sound.py?view=markup\">Here从wxPython的演示一个例子。
Here is an example from the wxPython demo.
这篇关于什么是跨平台的方式在python播放声音文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文