What is winsound?
winsound is a python module which provides access to the basic sound-playing machinery provided by Windows platforms. It includes functions and several constants.
the purpose of introducing to you the
winsound module the task of generating or playing sound or a sound file.
winsound module is defined only for execution on a Windows Platform, hence the name WINsound
the winsound module is a builtin, there is no need for you to install it prior to executing it.
The basic action would be to import it by
This function is used to generate a ‘Beep’ sound. However, the user is required to input the frequency
value and the duration of the sound (these are parameters that shall be passed while calling the function).
Note: The frequency must be in the range 37 through 32,767 hertz.
system will produce a ‘Beep’ sound with the given frequency
for the given duration of time.
It has two parameters first sound and otherone is flag. The sound parameter may be a filename, a system sound alias, audio data as a bytes-like object, or none .Its interpretation depends on the value of flags, which can be a bitwise ORed combination of the constants described below. If the sound parameter is
None, any currently playing waveform sound is stopped. If the system indicates an error,
RuntimeError is raised.
Flags and their description
|SND_FILENAME||The sound parameter is the name of a WAV file.|
|SND_LOOP||Play the sound repeatedly|
|SND_MEMORY||The sound parameter to PlaySound() is a memory image of a WAV file, as a bytes-like object.|
|SND_ASYNC||Return immediately, allowing sounds to play asynchronously.|
|SND_NODEFAULT||If the specified sound cannot be found, do not play the system default sound.|
SND_NOSTOP Do not interrupt sounds currently playing.
print("Playing the file 'Police siren.wav'")
# winsound.PlaySound('filename', flag)
The respective audio file named 'mixkit-police-siren-us-1643.wav' is executed.
Here, mixkit-police-siren-us-1643 is .wav formate file name
and SND_FILENAME is flag name