Voice Reply
Generate voice audio replies using local Piper TTS via sherpa-onnx. Completely offline, no cloud APIs needed.
Features
- - 100% Local - No internet connection required after setup
- No API Keys - Free to use, no accounts needed
- Multi-language - German and English voices included
- Telegram Ready - Outputs voice notes that display as bubbles
- Auto-detect Language - Automatically selects voice based on text
Prerequisites
- 1. sherpa-onnx runtime installed
- Piper voice models downloaded
- ffmpeg for audio conversion
Installation
Quick Install
CODEBLOCK0
Manual Installation
1. Install sherpa-onnx
CODEBLOCK1
2. Download Voice Models
CODEBLOCK2
3. Install ffmpeg
CODEBLOCK3
4. Set Environment Variables
Add to your OpenClaw service or shell:
CODEBLOCK4
Usage
CODEBLOCK5
Parameters
| Parameter | Description | Default |
|---|
| text | The text to convert to speech | (required) |
| language |
de for German,
en for English | auto-detect |
Examples
CODEBLOCK6
Output Format
The script outputs two lines that OpenClaw processes for Telegram:
CODEBLOCK7
- -
[[audio_as_voice]] - Tag that tells Telegram to display as voice bubble - INLINECODE3 - Path to the generated OGG Opus audio file
Available Voices
| Language | Voice | Quality | Description |
|---|
| German (de) | thorsten | medium | Natural male voice, clear pronunciation |
| English (en) |
ryan | high | Clear US male voice, professional tone |
Adding More Voices
Browse available Piper voices at:
- - https://rhasspy.github.io/piper-samples/
- https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
Download and extract to $PIPER_VOICES_DIR, then modify the script to include the new voice.
Troubleshooting
"TTS binary not found"
Ensure
SHERPA_ONNX_DIR is set and contains
bin/sherpa-onnx-offline-tts.
"Failed to generate audio"
Check that voice model files exist:
*.onnx,
tokens.txt, INLINECODE9
Audio plays as file instead of voice bubble
Ensure the output includes
[[audio_as_voice]] tag on its own line before the
MEDIA: line.
Credits
语音回复
使用sherpa-onnx通过本地Piper TTS生成语音音频回复。完全离线,无需云API。
功能特性
- - 100%本地化 - 设置完成后无需网络连接
- 无需API密钥 - 免费使用,无需注册账号
- 多语言支持 - 包含德语和英语语音
- Telegram就绪 - 输出以气泡形式显示的语音消息
- 自动语言检测 - 根据文本自动选择语音
前置条件
- 1. 已安装sherpa-onnx运行环境
- 已下载Piper语音模型
- 已安装ffmpeg用于音频转换
安装指南
快速安装
bash
cd scripts
sudo ./install.sh
手动安装
1. 安装sherpa-onnx
bash
sudo mkdir -p /opt/sherpa-onnx
cd /opt/sherpa-onnx
curl -L -o sherpa.tar.bz2 https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.23/sherpa-onnx-v1.12.23-linux-x64-shared.tar.bz2
sudo tar -xjf sherpa.tar.bz2 --strip-components=1
rm sherpa.tar.bz2
2. 下载语音模型
bash
sudo mkdir -p /opt/piper-voices
cd /opt/piper-voices
德语 - thorsten(中等质量,自然男声)
curl -L -o thorsten.tar.bz2 https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-de_DE-thorsten-medium.tar.bz2
sudo tar -xjf thorsten.tar.bz2 && rm thorsten.tar.bz2
英语 - ryan(高质量,清晰美式男声)
curl -L -o ryan.tar.bz2 https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-ryan-high.tar.bz2
sudo tar -xjf ryan.tar.bz2 && rm ryan.tar.bz2
3. 安装ffmpeg
bash
sudo apt install -y ffmpeg
4. 设置环境变量
添加到OpenClaw服务或shell配置中:
bash
export SHERPAONNXDIR=/opt/sherpa-onnx
export PIPERVOICESDIR=/opt/piper-voices
使用方法
bash
{baseDir}/bin/voice-reply 要转换的文本 [语言]
参数说明
| 参数 | 描述 | 默认值 |
|---|
| text | 要转换为语音的文本 | (必填) |
| language |
de表示德语,en表示英语 | 自动检测 |
使用示例
bash
德语(显式指定)
{baseDir}/bin/voice-reply Hallo, ich bin dein Assistent! de
英语(显式指定)
{baseDir}/bin/voice-reply Hello, I am your assistant! en
自动检测(通过变音符号和常用词检测德语)
{baseDir}/bin/voice-reply Guten Tag, wie geht es dir?
自动检测(默认为英语)
{baseDir}/bin/voice-reply The weather is nice today.
输出格式
脚本输出两行内容,由OpenClaw处理用于Telegram:
[[audioasvoice]]
MEDIA:/tmp/voice-reply-output.ogg
- - [[audioasvoice]] - 标记,告诉Telegram以语音气泡形式显示
- MEDIA:路径 - 生成的OGG Opus音频文件路径
可用语音
| 语言 | 语音 | 质量 | 描述 |
|---|
| 德语 (de) | thorsten | 中等 | 自然男声,发音清晰 |
| 英语 (en) |
ryan | 高 | 清晰美式男声,专业音色 |
添加更多语音
浏览可用的Piper语音:
- - https://rhasspy.github.io/piper-samples/
- https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
下载并解压到$PIPERVOICESDIR,然后修改脚本以包含新语音。
故障排除
TTS binary not found
确保已设置SHERPA
ONNXDIR且包含bin/sherpa-onnx-offline-tts。
Failed to generate audio
检查语音模型文件是否存在:*.onnx、tokens.txt、espeak-ng-data/
音频以文件形式播放而非语音气泡
确保输出中MEDIA:行之前有独立的[[audio
asvoice]]标记行。
致谢