`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.
If you want to use the `edge-tts` command, you can simply run it with the following command:
$ edge-tts --text "Hello, world!" > 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 "مرحبا كيف حالك؟" > hello_in_arabic.mp3
### Custom SSML
It is possible to send Microsoft's text-to-speech servers a custom SSML document which would allow greater customization of the speech.
Information about the SSML format can be found here on Microsoft's own website: https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-synthesis-markup
As a short example, if you want to apply the following SSML document and play it back using `edge-tts`.
It is possible to make minor changes to the generated speech without resorting to custom SSML. However, you must note that you couldn't use the `--custom-ssml` option with the `--pitch`, `--rate`, `--volume`, etc. options.