Method for playing a sound file in pyaudio at Ubuntu?

39 views Asked by At

I attempted to play a.wav file with pyaudio. It works fine in Windows, but not in Ubuntu when another device is using sound.

and got this error:

IOError: [Errorno Invalid output device (no default output device)] -9996

Is there another way?

2

There are 2 answers

1
MD Kawsar On

Did you try wxPython as example:

sound.Play(wx.SOUND_ASYNC)

and sound variable can be defined like this:

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

you can see this question as reference seems you have the same problem. What's a cross platform way to play a sound file in python?

0
AudioBubble On

simply use simpleaudio

import simpleaudio
wave_obj = simpleaudio.WaveObject.from_wave_file("sound.wav")
play_obj = wave_obj.play()
play_obj.wait_done()