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

前端 未结 5 886
庸人自扰
庸人自扰 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:33

    I'm not absolutely sure if that fulfills your requirements, but I immediately thought PyGame

    http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.Sound

    from pygame import mixer
    
    mixer.init()
    s = mixer.Sound('sound.wav')
    s.play()
    

提交回复
热议问题