edge-tts README

The project's README from github.com/rany2/edge-tts. As one markdown file: README.md.

edge-tts

edge-tts lets you use Microsoft Edge's online text-to-speech service from Python, or from the command line with the edge-tts and edge-playback commands.

Installation

$ uv add edge-tts          # or: pip install edge-tts

To use only the commands, install them as a tool, or run them without installing:

$ uv tool install edge-tts
$ uvx edge-tts --text "Hello, world!" --write-media hello.mp3

Command line

$ edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt

To play the speech back immediately, use edge-playback, which takes the same options except --write-media, --write-subtitles and --list-voices. It requires mpv, except on Windows.

$ edge-playback --text "Hello, world!"

List the available voices with --list-voices, and pick one with --voice:

$ edge-tts --voice ar-EG-SalmaNeural --text "مرحبا كيف حالك؟" --write-media hello.mp3

Adjust the speech with --rate, --volume and --pitch. Write negative values with =, so they aren't read as options:

$ edge-tts --rate=-50% --pitch=-5Hz --text "Hello, world!" --write-media hello.mp3

Run edge-tts --help for all options. Custom SSML isn't supported, because the service only accepts the SSML that Microsoft Edge itself generates.

Python

import edge_tts

edge_tts.Communicate("Hello, world!", "en-GB-SoniaNeural").save_sync("hello.mp3")

See examples/ for async usage, streaming, subtitles and voice selection.

Troubleshooting

See TROUBLESHOOTING.md for common errors, such as NoAudioReceived, and how to deal with them.

Development

uv sync                            # create the environment from uv.lock
uv run pre-commit install          # lint, format and type-check on every commit
uv run pytest

Releases are published to PyPI automatically when a GitHub release is created.

edge-tts (rany2/edge-tts)

speech-synthesis
Searching Database…

What is this?edge-tts is a Python module and CLI that lets you use Microsoft Edge's online text-to-speech service from your code or terminal, without needing Microsoft Edge, Windows, or an API key.
Is this a library or a command-line tool?Both: it's a Python module you can import, and it also ships two CLI commands, edge-tts (generate audio/subtitles) and edge-playback (generate and play immediately).
How do I install and use it?Install with 'pip install edge-tts' (or 'pipx install edge-tts' if you only need the CLI commands), then run something like 'edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt'.
Do I need Microsoft Edge, Windows, or an API key?No - it talks directly to Edge's online TTS service, so you don't need the Edge browser, Windows, or any API key. The only extra dependency is the mpv command-line player if you want to use edge-playback on non-Windows systems.
Can I use custom SSML to fine-tune the speech?No, custom SSML support was removed because Microsoft only allows SSML that Edge itself could generate, so you're limited to the rate, volume, pitch, and voice options exposed by the tool.
Which voices and languages are available?It supports a large list of Microsoft Edge neural voices across many languages (e.g. Arabic, Amharic, Afrikaans, and many more), viewable with 'edge-tts --list-voices'.
Does it work on Windows, macOS, and Linux?Yes, it's a pure Python package that works wherever Python/pip runs; only edge-playback's dependency on mpv differs, and that's not required on Windows.
Can I adjust speech rate, volume, and pitch?Yes, use the --rate, --volume and --pitch flags, e.g. --rate=-50% or --pitch=-50Hz; note negative values need the '=' syntax to avoid being parsed as separate CLI flags.
Does it generate subtitles along with audio?Yes, the edge-tts command can write both an audio file and an .srt subtitle file in the same call, e.g. --write-media hello.mp3 --write-subtitles hello.srt.
What other projects use edge-tts?README mentions hass-edge-tts, Podcastfy, and a 'tts-samples' repo of voice samples as examples of projects built on the edge-tts module.
Creator
rany2
Size
2.1 MB
Stars
12.6K
Age
5y
Commits · 90 Days