Install
openclaw skills install coze-ttsText-to-Speech (TTS) using Coze API. Convert text to natural-sounding speech audio files. Supports multiple voices and output formats (mp3, ogg_opus, wav, pcm).
openclaw skills install coze-ttsConvert text to natural-sounding speech using Coze API.
1. Get your API Key: Get a key from Coze Platform
2. Set it in your environment:
export COZE_API_KEY="your-key-here"
Convert text to speech with default settings:
bash scripts/text_to_speech.sh "你好,这是测试语音"
bash scripts/text_to_speech.sh "你好世界" -o output.mp3
bash scripts/text_to_speech.sh "你好" -v 2
bash scripts/text_to_speech.sh "你好" -f ogg_opus
bash scripts/text_to_speech.sh "要转换的文本" -o output.mp3 -v 1 -f mp3
Parameters:
text (required): Text to convert to speech-o, --output (optional): Output file path (default: auto-generated)-v, --voice (optional): Voice ID (default: 1)-f, --format (optional): Output format - mp3/ogg_opus/wav/pcm (default: mp3)The script saves the audio file and outputs:
Example output:
✓ Audio saved: coze_tts_20260324_235030_a1b2c3d4.mp3
Size: 25.3 KB
Duration: ~3 seconds
bash scripts/text_to_speech.sh "您有一条新消息" -o notification.mp3
bash scripts/text_to_speech.sh "欢迎使用 Coze 语音服务" -v 2 -o greeting.mp3
bash scripts/text_to_speech.sh "你好" -f ogg_opus -o message.ogg
for text in "你好" "谢谢" "再见"; do
bash scripts/text_to_speech.sh "$text" -o "${text}.mp3"
done
Combine with coze-asr for voice conversation:
# 1. User speaks -> ASR converts to text
bash coze-asr/scripts/speech_to_text.sh input.ogg
# 2. Process text with AI...
# 3. AI response -> TTS converts to speech
bash coze-tts/scripts/text_to_speech.sh "AI的回复" -o response.mp3
Authentication Error:
Invalid Voice ID:
File Not Created:
POST https://api.coze.cn/v1/audio/speech| Variable | Description | Required |
|---|---|---|
COZE_API_KEY | Coze API authentication key | Yes |
| Tool | Purpose | Required |
|---|---|---|
jq | JSON processing | Yes |
ffprobe | Audio duration detection | Optional |
MIT