edge-tts

rany2活跃维护

用 Python 直接调用微软 Edge 的在线语音合成服务,无需安装 Edge 浏览器或密钥,即可把文本转成自然语音。

Use Microsoft Edge's online text-to-speech service from Python WITHOUT needing Microsoft Edge

7.3.1发布于 2026-10-13 15:57 UTC12,501star +20 / 7 天1,179fork同步于 2026-11-10 11:28 UTC

怎么上手

由 README 提炼,执行前请确认
pip install edge-tts
edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt
硬件要求按 README 说明

README 未说明硬件要求;这是调用微软在线服务的客户端,本地不跑模型,无需 GPU 或显存。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Python 调用微软 Edge 在线语音合成服务,无需安装 Edge 浏览器即可生成语音

用 Python 直接调用微软 Edge 的在线语音合成服务,无需安装 Edge 浏览器或密钥,即可把文本转成自然语音。

核心能力

  • 通过 edge-tts 命令行把文本合成 mp3 并导出 srt 字幕
  • 用 --list-voices 列出多语言多音色并指定 --voice 切换
  • 用 --rate、--volume、--pitch 调整语速、音量与音调
  • 提供 Python 模块接口,可在代码中直接调用
  • stderr 为终端时显示基于边界元数据的生成进度条

容易踩的坑

edge-playback 需额外安装 mpv 播放器(Windows 除外);传负值参数要写成 --rate=-50% 而非 --rate -50%;自定义 SSML 已被移除,服务只允许单个 voice 与 prosody 标签。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本7.3.1
  1. 7.3.1最新正式版2026-10-13 · 2026-10-13 15:57 UTC

    What's Changed

    Full Changelog: https://github.com/rany2/edge-tts/compare/7.3.0...7.3.1

  2. 7.3.02026-10-13 · 2026-10-13 15:34 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/rany2/edge-tts/compare/7.2.8...7.3.0

  3. 7.2.82026-03-22 · 2026-03-22 19:58 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/rany2/edge-tts/compare/7.2.7...7.2.8

  4. 7.2.72025-12-12 · 2025-12-12 20:55 UTC
    查看更新说明

    What's Changed

    New Contributors

    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

  5. 7.2.62025-12-11 · 2025-12-11 16:33 UTC
    查看更新说明

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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: