Python Sound (“Bell”)

后端 未结 6 1048
无人共我
无人共我 2020-11-29 04:03

I\'d like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use import os and then use a command line spee

6条回答
  •  既然无缘
    2020-11-29 04:26

    I tried the mixer from the pygame module, and it works fine. First install the module:

    $ sudo apt-get install python-pygame
    

    Then in the program, write this:

    from pygame import mixer
    mixer.init() #you must initialize the mixer
    alert=mixer.Sound('bell.wav')
    alert.play()
    

    With pygame you have a lot of customization options, which you may additionally experiment with.

提交回复
热议问题