The winsound
module in Python 3 provides an interface to interact with the sound playing machinery in Windows. The Beep
function plays a beep of the specified frequency for the specified duration. If the system is not able to produce the beep sound on the speaker, a RuntimeError
is raised. The syntax of the Beep
function is as follows:
winsound.Beep(frequency, duration)
frequency
is a value between 37
to 32767
Hertz that specifies the frequency of the beep.duration
is the number of milliseconds for which the beep must be played.Beep
returns None
.The following code provides an example of how to use the Beep
function:
import winsoundwinsound.Beep(1500, 2000)
In the example above, the system will play a beep sound with a frequency of 1500
Hertz for 2
seconds.