Skip to main content

edge-tts

edge-tts is a Python module that allows you to use Microsoft Edge's online text-to-speech service from within your Python code or using the provided edge-tts or edge-playback command.

Installation

To install it, run the following command:

$ pip install edge-tts

If you only want to use the edge-tts and edge-playback commands, it would be better to use pipx:

$ pipx install edge-tts

Usage

Basic usage

If you want to use the edge-tts command, you can simply run it with the following command:

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

If you wish to play it back immediately with subtitles, you could use the edge-playback command:

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

Note that edge-playback requires the installation of the mpv command line player, except on Windows.

All edge-tts commands work with edge-playback with the exception of the --write-media, --write-subtitles and --list-voices options.

Changing the voice

You can change the voice used by the text-to-speech service by using the --voice option. The --list-voices option can be used to list all available voices.

$ edge-tts --list-voices
Name                               Gender    ContentCategories      VoicePersonalities
---------------------------------  --------  ---------------------  --------------------------------------
af-ZA-AdriNeural                   Female    General                Friendly, Positive
af-ZA-WillemNeural                 Male      General                Friendly, Positive
am-ET-AmehaNeural                  Male      General                Friendly, Positive
am-ET-MekdesNeural                 Female    General                Friendly, Positive
ar-AE-FatimaNeural                 Female    General                Friendly, Positive
ar-AE-HamdanNeural                 Male      General                Friendly, Positive
ar-BH-AliNeural                    Male      General                Friendly, Positive
ar-BH-LailaNeural                  Female    General                Friendly, Positive
ar-DZ-AminaNeural                  Female    General                Friendly, Positive
ar-DZ-IsmaelNeural                 Male      General                Friendly, Positive
ar-EG-SalmaNeural                  Female    General                Friendly, Positive
...

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

Custom SSML

Support for custom SSML was removed because Microsoft prevents the use of any SSML that could not be generated by Microsoft Edge itself. This means that all the cases where custom SSML would be useful cannot be supported as the service only permits a single <voice> tag with a single <prosody> tag inside it. Any available customization options that could be used in the <prosody> tag are already available from the library or the command line itself.

Changing rate, volume and pitch

You can change the rate, volume and pitch of the generated speech by using the --rate, --volume and --pitch options. When using a negative value, you will need to use --[option]=-50% instead of --[option] -50% to avoid the option being interpreted as a command line option.

$ edge-tts --rate=-50% --text "Hello, world!" --write-media hello_with_rate_lowered.mp3 --write-subtitles hello_with_rate_lowered.srt
$ edge-tts --volume=-50% --text "Hello, world!" --write-media hello_with_volume_lowered.mp3 --write-subtitles hello_with_volume_lowered.srt
$ edge-tts --pitch=-50Hz --text "Hello, world!" --write-media hello_with_pitch_lowered.mp3 --write-subtitles hello_with_pitch_lowered.srt

Progress

When stderr is a terminal, a progress bar is drawn on it while the audio is generated:

 42%|███████████████████▌                          | 1.5MB  00:03<00:04

The percentage is the audio received so far against the total length estimated from the service's boundary metadata, so it tracks how much work is left rather than how much text has been read out. The bar is suppressed when stderr is redirected, when subtitles are being written to stderr with --write-subtitles -, and when --no-progress is passed.

$ edge-tts --no-progress --text "Hello, world!" --write-media hello.mp3

Python module

It is possible to use the edge-tts module directly from Python. Examples from the project itself include:

Other projects that use the edge-tts module include:

Metadata

Release files for edge-tts 7.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for edge-tts 7.3.0
File Size Uploaded
edge_tts-7.3.0.tar.gz 35.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for edge-tts 7.3.0
File Interpreter ABI Platform
edge_tts-7.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 74.7 kB

Release files / edge_tts-7.3.0.tar.gz

Download URL edge_tts-7.3.0.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e6c3e7a62439f3a1567bc20aa704b2aadd4acd6afb3cd539fbe65b7c1a9e7c82
BLAKE2b-256 checksum
How to use checksums
dde34c7694643c3d244977a9d62ddececf574aca9a61a48284ad968647f133a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / edge_tts-7.3.0-py3-none-any.whl

Download URL edge_tts-7.3.0-py3-none-any.whl
Size 38.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31dce50bc55156b0542645e61a847249ce2a41072f6447c9729fd3f0b11834b0
BLAKE2b-256 checksum
How to use checksums
995a06f5ca7f830fa1445e3a1e068b40a484a486c6af6541cf42cfe5e7a02a3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

7.3.1

2 release files

This release

7.3.0 This release

2 release files

7.2.8

2 release files

7.2.7

2 release files

7.2.6

2 release files

7.2.5

2 release files

7.2.4

2 release files

7.2.3

2 release files

7.2.2

2 release files

7.2.1

2 release files

7.2.0

2 release files

7.1.0

2 release files

7.0.2

2 release files

7.0.1

2 release files

7.0.0

2 release files

6.1.19

2 release files

6.1.18

2 release files

6.1.15

2 release files

6.1.14

2 release files

6.1.13

2 release files

6.1.12

2 release files

6.1.11

2 release files

6.1.10

2 release files

6.1.9

2 release files

6.1.8

2 release files

6.1.7

2 release files

6.1.6

2 release files

6.1.5

2 release files

6.1.4

2 release files

6.1.3

2 release files

6.1.2

2 release files

6.1.1

2 release files

6.1.0

2 release files

6.0.9

2 release files

6.0.8

2 release files

6.0.7

2 release files

6.0.6

2 release files

6.0.5

2 release files

6.0.4

2 release files

6.0.3

2 release files

6.0.2

2 release files

6.0.1

2 release files

6.0.0

2 release files

5.0.7

2 release files

5.0.6

2 release files

5.0.5

2 release files

5.0.4

2 release files

5.0.3

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.0.11

2 release files

4.0.10

2 release files

4.0.9

2 release files

4.0.8

2 release files

4.0.7

2 release files

4.0.6

2 release files

4.0.5

2 release files

4.0.4

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page