通过小米 MiMo V2 TTS API 将文字转为自然流畅的语音。
bash
pip install requests
编辑 ~/.openclaw/openclaw.json,在 skills.entries 下添加:
json
{
"skills": {
"entries": {
"xiaomi-mimo-voice": {
"enabled": true,
"env": {
"MIMO_API_KEY": "your-api-key"
}
}
}
}
}
💡 也可以使用环境变量
export MIMO_API_KEY=xxx,但推荐用 Skill 级别配置,更整洁且仅对该 Skill 生效。
bash
python3 <skill_dir>/scripts/tts.py --text "要合成的文字" --output audio.wav
参数说明默认值--text要合成的文字(必填,可含风格标签)—--output输出音频文件路径output.wav``--voice音色mimo_default``--style语音风格—--format输出格式: wav / pcm16``wav``--user-text用户侧消息(辅助上下文)—
音色说明mimo_default默认音色default_zh中文优化default_en英文优化
类别风格情感Happy · Sad · Angry · Surprised · Fearful · Disgusted · Calm语速Speed up · Slow down角色Sun Wukong · Lin Daiyu · Zhang Fei · Guan Yu · Zhuge Liang风格Whisper · Clamped voice · Taiwanese accent方言Northeastern dialect · Sichuan dialect · Cantonese · Henan dialect其他唱歌 · Narration · Storytelling
bash
# 基础合成
python3 scripts/tts.py --text "你好,世界!" --output hello.wav
# 情感风格
python3 scripts/tts.py --text "太开心了!" --style Happy --output happy.wav
# 角色扮演
python3 scripts/tts.py --text "俺老孙来也!" --style "Sun Wukong" --output wukong.wav
# 英文
python3 scripts/tts.py --text "Hello world!" --voice default_en --output hello_en.wav
# 方言
python3 scripts/tts.py --text "干啥呢老铁" --style "Northeastern dialect" --output dongbei.wav
# 播报
python3 scripts/tts.py --text "以下是今天的新闻摘要" --style Narration --output news.wav
json
{
"status": "success",
"file": "output.wav",
"size_kb": 128.5,
"duration_sec": 5.2,
"voice": "mimo_default",
"style": "Happy",
"text": "太开心了!"
}
问题原因解决方案未设置 MIMO_API_KEY未配置 API Key在 skills.entries.xiaomi-mimo-voice.env 中配置API 返回异常Key 无效或过期检查 Key 是否正确未获取到音频数据文本被拒绝检查文本内容requests 超时网络问题检查网络连接ImportError: requests缺少依赖pip install requests
mimo-v2-ttshttps://api.xiaomimimo.com/v1/chat/completions<style>风格</style> 放在文字开头