edge-playback 需额外安装 mpv 播放器(Windows 除外);传负值参数要写成 --rate=-50% 而非 --rate -50%;自定义 SSML 已被移除,服务只允许单个 voice 与 prosody 标签。
edge-tts
rany2活跃维护用 Python 直接调用微软 Edge 的在线语音合成服务,无需安装 Edge 浏览器或密钥,即可把文本转成自然语音。
Use Microsoft Edge's online text-to-speech service from Python WITHOUT needing Microsoft Edge
pip install edge-tts
edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srtREADME 未说明硬件要求;这是调用微软在线服务的客户端,本地不跑模型,无需 GPU 或显存。
用 Python 调用微软 Edge 在线语音合成服务,无需安装 Edge 浏览器即可生成语音
用 Python 直接调用微软 Edge 的在线语音合成服务,无需安装 Edge 浏览器或密钥,即可把文本转成自然语音。
核心能力
- 通过 edge-tts 命令行把文本合成 mp3 并导出 srt 字幕
- 用 --list-voices 列出多语言多音色并指定 --voice 切换
- 用 --rate、--volume、--pitch 调整语速、音量与音调
- 提供 Python 模块接口,可在代码中直接调用
- stderr 为终端时显示基于边界元数据的生成进度条
容易踩的坑
- 7.3.1最新正式版2026-10-13 · 2026-10-13 15:57 UTC
What's Changed
- Fix locale-dependent server date parsing by @rany2 in https://github.com/rany2/edge-tts/pull/494
Full Changelog: https://github.com/rany2/edge-tts/compare/7.3.0...7.3.1
- 7.3.02026-10-13 · 2026-10-13 15:34 UTC
查看更新说明
What's Changed
- Show a progress bar on stderr during synthesis by @afunTW in https://github.com/rany2/edge-tts/pull/488
- feat: add Sec-MS-GEC v2 token support by @HarryXiaoCN in https://github.com/rany2/edge-tts/pull/492
- fix: work around mpv CoreAudio playback failure on macOS by @rany2 in https://github.com/rany2/edge-tts/pull/493
New Contributors
- @afunTW made their first contribution in https://github.com/rany2/edge-tts/pull/488
- @HarryXiaoCN made their first contribution in https://github.com/rany2/edge-tts/pull/492
Full Changelog: https://github.com/rany2/edge-tts/compare/7.2.8...7.3.0
- 7.2.82026-03-22 · 2026-03-22 19:58 UTC
查看更新说明
What's Changed
- fix: replace metadata-based offset compensation with CBR byte-count math by @hcgiub001 in https://github.com/rany2/edge-tts/pull/468
- perf: cache SSL context at module level to avoid per-call overhead in https://github.com/rany2/edge-tts/pull/469
New Contributors
- @hcgiub001 made their first contribution in https://github.com/rany2/edge-tts/pull/468
Full Changelog: https://github.com/rany2/edge-tts/compare/7.2.7...7.2.8
- 7.2.72025-12-12 · 2025-12-12 20:55 UTC
查看更新说明
What's Changed
- Update
VoiceTypedDict by @Shoghy in https://github.com/rany2/edge-tts/pull/449
New Contributors
- @Shoghy made their first contribution in https://github.com/rany2/edge-tts/pull/449
Note
This release is only useful for developers that want up-to-date types for
Voice. It does not have an impact on functionality.Full Changelog: https://github.com/rany2/edge-tts/compare/7.2.6...7.2.7
- Update
- 7.2.62025-12-11 · 2025-12-11 16:33 UTC
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
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:
- hass-edge-tts
- Podcastfy
- tts-samples - a collection of mp3 sound samples to facilitate picking a voice for your project.