Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a cross platform way to play a sound file in python?

Tags:

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.

The error is "IOError: [Errorno Invalid output device (no default output device)] -9996

Is there another library I could try to use? Another method?

like image 414
Gilbert Avatar asked Nov 09 '08 18:11

Gilbert


1 Answers

You can use wxPython

sound = wx.Sound('sound.wav')
sound.Play(wx.SOUND_SYNC)

or

sound.Play(wx.SOUND_ASYNC)

Here is an example from the wxPython demo.

like image 195
Toni Ruža Avatar answered Sep 20 '22 15:09

Toni Ruža