Go to file
rany cc7ac64909 Create dependabot.yml
Signed-off-by: rany2 <rany2@riseup.net>
2022-09-27 12:16:55 +03:00
.github Create dependabot.yml 2022-09-27 12:16:55 +03:00
examples remove subrip example, now standalone 2022-03-10 18:32:30 +02:00
src lint 2022-07-27 20:17:42 +03:00
.gitignore Update to edge-tts 3.0.1 2021-12-04 00:57:45 +02:00
build_and_publish.sh Update to edge-tts 4.0.0 2021-12-07 22:09:43 +02:00
build.sh Update to edge-tts 4.0.0 2021-12-07 22:09:43 +02:00
clean.sh Update to edge-tts 4.0.0 2021-12-07 22:09:43 +02:00
LICENSE Initial commit 2021-05-10 21:55:15 +03:00
lint.sh Update edge-tts to version 4.0.11 2022-05-29 18:17:48 +03:00
publish.sh Update to edge-tts 4.0.0 2021-12-07 22:09:43 +02:00
pyproject.toml Add requirements.txt and pin version 2022-09-27 12:16:22 +03:00
README.md drop custom SSML support 2022-06-19 21:07:05 +03:00
requirements.txt Add requirements.txt and pin version 2022-09-27 12:16:22 +03:00
setup.cfg Add requirements.txt and pin version 2022-09-27 12:16:22 +03:00
setup.py Update to edge-tts 3.0.1 2021-12-04 00:57:45 +02:00

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

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

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

Note the above requires the installation of the mpv command line player.

All edge-tts commands work in edge-playback as well.

Changing the voice

If you want to change the language of the speech or more generally, the voice.

You must first check the available voices with the --list-voices option:

$ edge-tts --list-voices
Name: Microsoft Server Speech Text to Speech Voice (af-ZA, AdriNeural)
ShortName: af-ZA-AdriNeural
Gender: Female
Locale: af-ZA

Name: Microsoft Server Speech Text to Speech Voice (am-ET, MekdesNeural)
ShortName: am-ET-MekdesNeural
Gender: Female
Locale: am-ET

Name: Microsoft Server Speech Text to Speech Voice (ar-EG, SalmaNeural)
ShortName: ar-EG-SalmaNeural
Gender: Female
Locale: ar-EG

Name: Microsoft Server Speech Text to Speech Voice (ar-SA, ZariyahNeural)
ShortName: ar-SA-ZariyahNeural
Gender: Female
Locale: ar-SA

...

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

Custom SSML

Support for custom SSML has been removed since 5.0.0 because Microsoft has taken the initiative to prevent it from working. You cannot use custom SSML anymore.

Changing pitch, rate, volume, etc.

It is possible to make minor changes to the generated speech.

$ edge-tts --pitch=-10Hz --text "Hello, world!" --write-media hello_with_pitch_down.mp3
$ edge-tts --rate=0.5 --text "Hello, world!" --write-media hello_with_rate_halved.mp3
$ edge-tts --volume=50 --text "Hello, world!" --write-media hello_with_volume_halved.mp3

Keep in mind that the --pitch, --rate, --volume, etc. options are applied to the entire SSML document.

In addition, it is required to use --pitch=-10Hz instead of --pitch -10Hz otherwise the -10Hz would be interpreted as just another argument.

Note on the edge-playback command

edge-playback is just a wrapper around edge-tts that plays back the generated speech. It takes the same arguments as the edge-tts option.

Python module

It is possible to use the edge-tts module directly from Python. The examples directory contains a few examples of how to use it.