PyWinRT lets Python call Windows Runtime (WinRT) APIs: Bluetooth, USB and serial devices, cameras, notifications, screen capture, speech and many other APIs that Windows offers apps.
- A projection: it is generated from the WinRT metadata, so every WinRT API in the Windows SDK is there, and the Windows App SDK's too.
- Pythonic:
snake_casenames, collections that are sequences and mappings, async operations youawaitand any bytes-like object where WinRT takes a buffer, as the WinRT type system describes. - Fully typed: every package ships type hints, so editors complete your code and type checkers check it.
Each part of the WinRT API is a package of its own on PyPI. Install the ones your code uses, and each brings the runtime with it:
pip install winrt-Windows.Media.SpeechSynthesisPyWinRT needs CPython 3.11 or later on Windows. Installing says which packages to choose.
from winrt.windows.media.speechsynthesis import SpeechSynthesizer
for voice in SpeechSynthesizer.all_voices:
print(voice.display_name, voice.language)To hear the default voice, install uv and run the text-to-speech sample:
uv run --script https://raw.githubusercontent.com/pywinrt/pywinrt/refs/heads/main/samples/text_to_speech.pyThe documentation covers the rest. You can also write WinUI 3 apps. The PyWinRT tool projects WinRT components of your own, and Versioning says how to package them.
- Moving from 3.x: read the 4.0 release notes and the migration guide.
- Built on PyWinRT: Bleak and Windows-Toasts.
- Support: ask questions in Discussions and report bugs in Issues.
- Contributing: see CONTRIBUTING.md.
- License: MIT.
- History: PyWinRT began as a fork of the
pywinrtcode generator from Microsoft's xlang project and is now an independent project. History tells the rest.