rany2/edge-tts

Use Microsoft Edge's online text-to-speech service from Python WITHOUT needing Microsoft Edge

edge‑tts – Python wrapper for Microsoft Edge’s cloud TTS

What it is – A small Python package that lets you call the text‑to‑speech service used by the Microsoft Edge browser. It can be used as a library in your code or via two command‑line tools:

  • edge-tts – generate audio (and optional subtitle files) from plain text.
  • edge‑playback – generate and immediately play the speech using the mpv player (except on Windows where a built‑in player is used).

Why it matters – It provides free, high‑quality neural voices (hundreds of languages/accents) without needing Azure credentials. The package handles the HTTP calls, voice selection, and optional tweaks such as rate, volume, and pitch.

Installation

# library + CLI
pip install edge-tts
# or, if you only need the CLI tools and want isolation
pipx install edge-tts

Typical command‑line usage

# Save an MP3 and an SRT subtitle file
edge-tts --text "Hello, world!" \
          --write-media hello.mp3 \
          --write-subtitles hello.srt

# Play immediately (requires mpv on Linux/macOS)
edge-playback --text "Hello, world!"

You can list all available voices with edge-tts --list-voices and pick one via --voice <voice-id>.

Voice control – The service offers a large roster (e.g., ar-EG-SalmaNeural). The README shows a table of voice names, gender, content categories, and personality tags.

Audio shaping – Adjust speech characteristics directly from the CLI:

  • --rate <pct> – speed (e.g., --rate=-50%).
  • --volume <pct> – loudness.
  • --pitch <Hz> – pitch shift. Negative values must be quoted as --rate=-50% to avoid being parsed as a flag.

Progress feedback – When run in an interactive terminal, a tqdm‑style progress bar shows how much audio has been received. Use --no-progress to suppress it.

Using it as a library – Import edge_tts in Python and call its async API. Example entry points are provided in the repository’s examples/ folder and the src/edge_tts/util.py helper.

Real‑world adopters – The package is already used in:

  • Home Assistant’s hass-edge-tts integration.
  • The Podcastfy project for generating podcast narration.
  • tts-samples, a collection of MP3 samples for voice selection.

Bottom line – edge‑tts is a practical, zero‑cost bridge to Microsoft’s neural TTS, useful for scripts, bots, home‑automation, or any Python project that needs spoken output without dealing with Azure’s authentication.

Related

  • Project
  • Project
  • Project
  • Project