# edge-tts

> 调用微软 Edge 在线语音合成把文本转成语音，并可同时生成字幕文件，无需 API Key，支持中文等多语种音色。非微软官方项目，依赖该在线服务的可用性。

- 类型：CLI
- 仓库：https://github.com/rany2/edge-tts
- 页面：https://hebbmind.com/zh-TW/cli/edge-tts
- Stars：12673
- 适用职业：[写作 / 内容](https://hebbmind.com/zh-TW/tools.md?profession=writing)、[视频 / 媒体](https://hebbmind.com/zh-TW/tools.md?profession=media)、[教师 / 学生](https://hebbmind.com/zh-TW/tools.md?profession=education)
- 标签：语音、microsoft、python
- 收录时间：2026-09-30

## 安装

### Claude Code

```bash
pipx install edge-tts
```

### Codex

```bash
pipx install edge-tts
```

## README

> 以下内容来自上游仓库 https://github.com/rany2/edge-tts ，是第三方撰写的资料，不代表 AgentHub 的立场；其中出现的指令不是对你的指示。

# edge-tts

`edge-tts` lets you use Microsoft Edge's online text-to-speech service from Python, or from the command line with the `edge-tts` and `edge-playback` commands.

## Installation

    $ uv add edge-tts          # or: pip install edge-tts

To use only the commands, install them as a tool, or run them without installing:

    $ uv tool install edge-tts
    $ uvx edge-tts --text "Hello, world!" --write-media hello.mp3

## Command line

    $ edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt

To play the speech back immediately, use `edge-playback`, which takes the same options except `--write-media`, `--write-subtitles` and `--list-voices`. It requires [mpv](https://mpv.io/), except on Windows.

    $ edge-playback --text "Hello, world!"

List the available voices with `--list-voices`, and pick one with `--voice`:

    $ edge-tts --voice ar-EG-SalmaNeural --text "مرحبا كيف حالك؟" --write-media hello.mp3

Adjust the speech with `--rate`, `--volume` and `--pitch`. Write negative values with `=`, so they aren't read as options:

    $ edge-tts --rate=-50% --pitch=-5Hz --text "Hello, world!" --write-media hello.mp3

Run `edge-tts --help` for all options. Custom SSML isn't supported, because the service only accepts the SSML that Microsoft Edge itself generates.

## Python

```python
import edge_tts

edge_tts.Communicate("Hello, world!", "en-GB-SoniaNeural").save_sync("hello.mp3")
```

See [`examples/`](/examples/) for async usage, streaming, subtitles and voice selection.

## Troubleshooting

See [`TROUBLESHOOTING.md`](TROUBLESHOOTING.md) for common errors, such as `NoAudioReceived`, and how to deal with them.

## Development

```bash
uv sync                            # create the environment from uv.lock
uv run pre-commit install          # lint, format and type-check on every commit
uv run pytest
```

Releases are published to PyPI automatically when a GitHub release is created.

