Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python3

What is winsound.Beep() in Python 3?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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

  • 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.

Return value

  • Beep returns None.

Example

The following code provides an example of how to use the Beep function:

import winsound
winsound.Beep(1500, 2000)

In the example above, the system will play a beep sound with a frequency of 1500 Hertz for 2 seconds.

RELATED TAGS

python3

CONTRIBUTOR

Hammad Nasir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring