• Stars
    star
    4,938
  • Rank 8,492 (Top 0.2 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Microsoft Edge's online text-to-speech service from Python WITHOUT needing Microsoft Edge or Windows or an API key

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.vtt

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 --write-subtitles hello_in_arabic.vtt

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 rate, volume and pitch

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

$ edge-tts --rate=-50% --text "Hello, world!" --write-media hello_with_rate_halved.mp3 --write-subtitles hello_with_rate_halved.vtt
$ edge-tts --volume=-50% --text "Hello, world!" --write-media hello_with_volume_halved.mp3 --write-subtitles hello_with_volume_halved.vtt
$ edge-tts --pitch=-50Hz --text "Hello, world!" --write-media hello_with_pitch_halved.mp3 --write-subtitles hello_with_pitch_halved.vtt

In addition, it is required to use --rate=-50% instead of --rate -50% (note the lack of an equal sign) otherwise the -50% 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. For a list of example applications:

More Repositories

1

warp.sh

WARP wireguard config generator in POSIX Shell
Shell
192
star
2

edge-srt-to-speech

Convert SubRip to speech using Microsoft Edge's TTS service
Python
43
star
3

ha-open-meteo-solar-forecast

Home Assistant Open-Meteo Solar Forecast Integration
Python
35
star
4

winactivate

Windows HWID/KMS38 activator easily buildable from source or with GitHub Actions
PowerShell
26
star
5

open-meteo-solar-forecast

Python module that uses Open-Meteo to get solar production forecast
Python
14
star
6

mt76

Use https://github.com/rany2/openwrt instead
C
8
star
7

openwrt

My OpenWRT Tree
C
8
star
8

grott

Growatt inverter monitor
Python
8
star
9

firefox_installer

Install Firefox from Mozilla.org on Linux
Python
7
star
10

jqGrid

jQuery grid plugin (maintained version of https://github.com/free-jqgrid/jqGrid adding jQuery 3.x support and fix some known bugs)
JavaScript
6
star
11

botty

The BNET Botty IRC Bot
Python
3
star
12

riseupvpn.py

RiseupVPN in Python
Python
3
star
13

device_oneplus_avicii-TWRP

TWRP DT for Avicii
C++
1
star
14

kernel_oneplus_sm7250-TWRP

op_sm7250 kernel for TWRP
C
1
star
15

device_oneplus_aviciiv2-TWRP

TWRP DT for Avicii (ROMs that use FBEv2)
C++
1
star
16

popura-package-rpm

RH RPM source files for Popura
1
star
17

go-textsynth

Text Synth client in Go
Go
1
star
18

yggdrasil-opensuse-pkg

SUSE RPM source files for Yggdrasil and Popura
1
star
19

go-fastcli

fast.com client in go
Go
1
star
20

ddgmail

A command line tool to use DuckDuckGo's E-mail forwarding service
Python
1
star
21

onions-everywhere

Automatically redirect to onion domain if it's available. This implements the Onion-Location functionality found in Tor Browser.
JavaScript
1
star