Skip to main content

Microsoft Edge's TTS

Project description

say it first

The project was modified from https://pypi.org/project/edge-tts/, but the original project was a CLI and was not easy to call externally, so it was tweaked briefly and may be integrated with Azure TTS capabilities later

build

参考文档: https://zhuanlan.zhihu.com/p/128020789

pip install --upgrade setuptools

如果构建出错: pip uninstall setuptools wheel -y pip install setuptools wheel rm -rf build dist python setup.py sdist bdist_wheel

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 and volume

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

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: --pitch was removed in 6.0.3 as it no longer appears to have any effect.

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edge-tts-ext-6.1.8.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

edge_tts_ext-6.1.8-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file edge-tts-ext-6.1.8.tar.gz.

File metadata

  • Download URL: edge-tts-ext-6.1.8.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.3

File hashes

Hashes for edge-tts-ext-6.1.8.tar.gz
Algorithm Hash digest
SHA256 20831a69d93812c152e761a1ce160b3a9d6bb982b38fa2b01662692eba6b30ab
MD5 4c5e0fcd0b5b1f660cd1465691317534
BLAKE2b-256 a965ea63dfead310a0a9f9e2942a4a9bc2b08bd0b45393a6a71544594df788dd

See more details on using hashes here.

File details

Details for the file edge_tts_ext-6.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for edge_tts_ext-6.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b1f153ac43e7e7237c33167dd8cd38f331db055fc9636b6ab934be50f99cf664
MD5 07decfcbf2c1f7fa8a4da717aacbe923
BLAKE2b-256 d4c8973248cdad489a724f3c16046bfbc79c416a3c91bc6652efe7c3fa953d63

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page