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:
try:
do_something()
except:
winsound.Beep(440, 1000)