On this page
  1. winsound
  2. Import
  3. Overview
  4. Quick Start
  5. Implementation Walkthrough
  6. 1. Playing a WAV File Asynchronously
  7. Gotchas & Boundaries
  8. Common Functions

winsound

Prev: winreg | Up: stdlib_module | Next: wsgiref
Rel: os, io, time, argparse, getopt
Ref: docs.python.org — winsound
Tags: #public #python3 #stdlib


Import

import winsound

Overview

Windows-only audio feedback module for playing simple frequency beeps (Beep()), system notification sounds (MessageBeep()), or WAV files (PlaySound()). Use winsound for zero-dependency audio alerts in Windows desktop utilities or long-running scripts.

Quick Start

import sys

if sys.platform == "win32":
    import winsound

    # Play the standard Windows notification chime
    winsound.MessageBeep(winsound.MB_OK)

Implementation Walkthrough

1. Playing a WAV File Asynchronously

Combine SND_FILENAME | SND_ASYNC to start playback without blocking your script (and pass None, SND_PURGE to stop it):

import sys

def notify_done(wav_path: str) -> None:
    if sys.platform == "win32":
        import winsound
        winsound.PlaySound(wav_path, winsound.SND_FILENAME | winsound.SND_ASYNC)

Gotchas & Boundaries

Common Functions

Linked from

Related notes