Generate speech using Microsoft Edge's online TTS service, free, no API Key required, supports 300+ voices.
Use Cases
- User says "convert this text to speech" or "read it with a Chinese female voice"
- Need to quickly generate speech without configuring an API Key
- Alternative when kokoro-tts is not installed
Execution Method
Command-Line Usage
# 基本用法
edge-tts --text "你好,今天天气真不错" --write-media output.mp3
Specify Voice
edge-tts --voice zh-CN-XiaoxiaoNeural --text "你好" --write-media output.mp3
With Subtitlesedge-tts --voice zh-CN-XiaoxiaoNeural --text "你好"
--write-media output.mp3 --write-subtitles output.vtt
### Python API
```python
import edge_tts
import asyncio
async def generate():
communicate = edge_tts.Communicate("你好,这是测试语音。", "zh-CN-XiaoxiaoNeural")
await communicate.save("output.mp3")
asyncio.run(generate())
Recommended Chinese Voices
| Voice | Gender | Style |
|---|---|---|
zh-CN-XiaoxiaoNeural |
Female | Warm and friendly (recommended) |
zh-CN-XiaoyiNeural |
Female | Lively |
zh-CN-YunjianNeural |
Male | Professional broadcast |
zh-CN-YunxiNeural |
Male | Young and natural |
List all available voices
edge-tts --list-voices | grep zh-CN
Adjust Speed and Pitch
edge-tts --voice zh-CN-XiaoxiaoNeural \
--rate "+20%" --pitch "+5Hz" \
--text "加速播放" --write-media output.mp3
Output Specifications
- By default use
zh-CN-XiaoxiaoNeural(Chinese) oren-US-JennyNeural(English) - Output in MP3 format, return the file path
- Requires network connection (not an offline solution)