edge-tts is a Python module that enables the use of Microsoft Edge's online text-to-speech service directly from Python code or via command-line tools like edge-tts and edge-playback, without requiring Microsoft Edge, Windows, or an API key.
edge-tts is an open-source Python library designed to harness the power of Microsoft Edge's online text-to-speech (TTS) service. This service, powered by advanced neural voices from Microsoft, allows developers and users to convert text into high-quality, natural-sounding speech without the need for installing Microsoft Edge browser, a Windows operating system, or obtaining any API keys. It's particularly useful for applications requiring multilingual voice synthesis, such as accessibility tools, virtual assistants, audiobooks, or automated content narration.
edge-tts for generation and edge-playback for playback with subtitles).To get started, install via pip:
pip install edge-tts
For command-line only use, prefer pipx:
pipx install edge-tts
Note that edge-playback requires the mpv player (except on Windows) for immediate audio playback with subtitles.
Generate a simple audio file:
edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt
Play back with subtitles:
edge-playback --text "Hello, world!"
List available voices:
edge-tts --list-voices
This outputs a table of voices like af-ZA-AdriNeural (Female, General, Friendly). Use a specific voice:
edge-tts --voice ar-EG-SalmaNeural --text "مرحبا كيف حالك؟" --write-media hello_ar.mp3 --write-subtitles hello_ar.srt
Modify speech attributes:
--rate=-50%--volume=-50%--pitch=-50Hz
Example:edge-tts --rate=-50% --text "Hello, world!" --write-media slow_hello.mp3 --write-subtitles slow_hello.srt
For programmatic access, import and use the library. The project provides examples in /examples/ and utility functions in /src/edge_tts/util.py. Key steps include:
edge_tts.list_voices()communicate(text, voice)Example code snippet:
import asyncio
import edge_tts
async def tts_example():
text = "Hello from edge-tts!"
voice = "en-US-AriaNeural"
communicate = edge_tts.Communicate(text, voice)
await communicate.save("output.mp3")
asyncio.run(tts_example())<voice> and <prosody> tags). Advanced SSML is not supported due to service restrictions.--list-voices for the latest.With over 9,500 GitHub stars, edge-tts is widely adopted. It's integrated into projects like:
This library democratizes access to premium TTS technology, making it ideal for AI-driven applications, educational tools, and content creators seeking cost-effective speech synthesis.