Using beep sound at point of error in python

I want to add beep sound when an error occurs in python script. I know how to add windows beep after specific line e.g.

 duration = 1000  # milliseconds
    freq = 440  # Hz
     #some code here
    winsound.Beep(freq, duration)

Is it possible to enable beep whenever there is an error? I am using windows 10, python 3.6, and pycharm IDE. I couldn’t find any feature in pycharm that gives audio notification on error.


You can catch all errors globally and beep when an error occurs:

    winsound.Beep(440, 1000)

Hope it helps you 😉

Leave a Reply

Your email address will not be published. Required fields are marked *