What is winsound.Beep() in Python 3?
Overview
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)
Parameters
frequencyis a value between37to32767Hertz that specifies the frequency of the beep.durationis the number of milliseconds for which the beep must be played.
Return value
BeepreturnsNone.
Example
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.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved