# edge-tts

> Use Microsoft Edge's online text-to-speech from Python or the command line

- Category: Multimodal Generation / Audio, Music & Voice
- Language: Python
- Repository: https://github.com/rany2/edge-tts
- Website: https://pypi.org/project/edge-tts/
- Canonical page: https://ai-tldr.dev/tools/edge-tts/

## In short

edge-tts is a Python module that lets you use Microsoft Edge's online text-to-speech service straight from your own code, or through the bundled edge-tts and edge-playback commands. You give it text, and it returns spoken audio in many languages and voices. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Python.

## Overview

edge-tts is a Python module that lets you use Microsoft Edge's online text-to-speech service straight from your own code, or through the bundled edge-tts and edge-playback commands. You give it text, and it returns spoken audio in many languages and voices.

Because it talks to Microsoft's hosted service, you do not need to download or run any large speech model yourself. You can generate an MP3 file, write matching subtitles, and tune the rate, volume and pitch of the result with simple options.

## What it does

- Convert text to spoken audio using Microsoft Edge's online text-to-speech voices
- Choose from a large list of voices across many languages and genders with the --list-voices option
- Write the generated audio to an MP3 file and matching subtitles to an SRT file
- Adjust the rate, volume and pitch of the speech with the --rate, --volume and --pitch options
- Play audio back immediately with the edge-playback command (uses the mpv player on non-Windows systems)
- Use the module directly from Python, or run the edge-tts and edge-playback command-line tools

## Getting started

Install edge-tts with pip, then generate speech from the command line. If you only want the command-line tools, pipx is a cleaner choice.

1. Install with pip

   Install the module and its commands with pip.

```bash
pip install edge-tts
```

2. Install the commands only with pipx

   If you only need the edge-tts and edge-playback commands, pipx keeps them isolated from your other Python packages.

```bash
pipx install edge-tts
```

3. Generate speech and subtitles

   Pass your text and choose where to write the audio and the subtitles.

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

4. Pick a voice and tune the output

   List the available voices, then select one and adjust the rate, volume or pitch. When using a negative value, write the option with an equals sign, for example --rate=-50%, so it is not read as a separate flag.

```bash
edge-tts --list-voices
edge-tts --rate=-50% --text "Hello, world!" --write-media slower.mp3
```

## When to use it

- Generate voiceovers or narration files for videos, slideshows and other media
- Add spoken audio output to your own apps and scripts by calling the Python module
- Create audio versions of articles or notes so you can listen instead of read
- Produce sample clips of many voices and languages to help pick the right voice for a project
