
Piper:快速本地神经文本转语音引擎|部署与使用全指南
项目仓库: https://github.com/OHF-Voice/piper1-gpl(原 rhasspy/piper)
维护方:Open Home Foundation · 许可证:GPL(piper1-gpl) · 形态:CLI + Python API + HTTP API + C/C++ 库 · 嵌入 espeak-ng 音素化
1 项目简介
Piper 是一个快速、本地的神经文本转语音引擎,内嵌 espeak-ng 做音素化。它被 Home Assistant、NVDA 屏幕阅读器、OpenVoiceOS、LocalAI 等广泛使用。设计目标是在普通 CPU 上低延迟本地合成语音,适合树莓派、嵌入式、无障碍等场景。
1.1 核心信息一览
| 项目项 | 内容 |
|---|---|
| 项目名称 | Piper |
| 仓库地址 | github.com/OHF-Voice/piper1-gpl(原 rhasspy/piper) |
| PyPI | piper-tts |
| 维护方 | Open Home Foundation |
| 形态 | CLI + Python API + HTTP API + C/C++ 库 |
| 嵌入 | espeak-ng 音素化 |
| 语音列表 | docs/VOICES.md |
1.2 适用场景
- 本地低延迟 TTS(树莓派、嵌入式、Home Assistant)。
- 屏幕阅读器(NVDA 已集成)。
- 多语言本地语音合成。
2 功能特性
- 快速本地:CPU 即可低延迟。
- 多语言语音:大量预训练语音模型。
- 多种接口:CLI、Python API、HTTP API、C/C++ 库。
- espeak-ng 音素化:支持多语言。
- 可训练新语音:
docs/TRAINING.md。
3 官方界面预览
在线示例:rhasspy.github.io/piper-samples。
4 官方跳转链接汇总
| 类别 | 链接 | 说明 |
|---|---|---|
| 仓库 | github.com/OHF-Voice/piper1-gpl | 源码 |
| CLI 文档 | docs/CLI.md | 命令行 |
| Python API | docs/API_PYTHON.md | Python 用法 |
| HTTP API | docs/API_HTTP.md | Web 服务 |
| 语音列表 | docs/VOICES.md | 可用语音 |
5 前置要求与服务器配置
5.1 软件前提
- Python 3.9+。
- espeak-ng(嵌入式音素化)。
5.2 硬件建议
CPU 即可;普通树莓派也能跑。
6 方式一:pip 安装与 CLI
pip install piper-tts
# 合成
echo "Hello world" | piper --model en_US-amy-medium --output_file hello.wav7 方式二:Python API
from piper import PiperVoice
voice = PiperVoice.load("en_US-amy-medium.onnx")
voice.synthesize("Hello world", "hello.wav")8 方式三:HTTP 服务
按 docs/API_HTTP.md 启动 Web 服务,通过 HTTP 调用
TTS。
9 常见故障排查
- 缺 espeak-ng:按文档安装系统包。
- 找不到语音:从 VOICES.md
下载对应
.onnx与.onnx.json。
10 风险与合规说明
- piper1-gpl 为 GPL 许可;商用前核对。
- 语音模型各有许可,下载时查看。
本文基于官方 README 整理,仅供学习与部署参考;以仓库最新说明为准。