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

前端 未结 5 903
庸人自扰
庸人自扰 2020-12-28 16:56

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 \"I

5条回答
  •  半阙折子戏
    2020-12-28 17:28

    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.

提交回复
热议问题