Moss 语音合成 (TTS)
v1.0.0 · 办公自动化 · 官方
简介
Moss 语音合成 (TTS) 插件,让 AI 员工能把文字读出来。使用微软 edge-tts 在线语音,中文发音自然流畅。
内置 Python,解压即用。 首次使用需安装两个依赖(edge-tts、pygame),需要联网。
包含能力
| 功能 | 技能名 | 能做什么 |
|---|---|---|
| 朗读文本 | tts_speak | 把文字读出来(主要功能) |
| 保存 mp3 | tts_save_mp3 | 文字转音频文件 |
| 列出语音 | tts_list_voices | 查看可用中文语音 |
安装步骤
1. 下载解压
解压到固定目录,例如:
D:\moss-plugins\tts\
解压后应包含:tts_plugin.py、run.bat、python/ 文件夹。
2. 安装依赖(首次必做)
在插件目录打开命令行:
python\python.exe -m pip install edge-tts pygame
3. 测试
run.bat --action speak --text "你好,Moss 语音插件配置成功"
听到朗读且输出 "success": true 即表示成功。
常用中文语音
| 语音 ID | 说明 |
|---|---|
| zh-CN-XiaoxiaoNeural | 晓晓(女声)— 默认 |
| zh-CN-YunxiNeural | 云希(男声) |
| zh-CN-YunyangNeural | 云扬(男声) |
| zh-CN-XiaoyiNeural | 小艺(女声) |
注册技能
打开 Moss 工作台 → 技能 → 添加技能。
脚本路径(所有技能共用,改成你的实际路径):
D:\moss-plugins\tts\run.bat
技能 1:tts_speak(必注册)
技能名称: tts_speak
技能描述: 将文本转换为语音并朗读,使用微软 edge-tts。当用户要求朗读、读出来、语音播报时使用。
脚本路径: D:\moss-plugins\tts\run.bat
参数 JSON:
{
"type": "object",
"properties": {
"action": {
"type": "string",
"description": "操作类型,固定为 speak",
"enum": ["speak"]
},
"text": {
"type": "string",
"description": "要朗读的文本内容"
},
"voice": {
"type": "string",
"description": "语音名称,可选。常用:zh-CN-XiaoxiaoNeural(女声)、zh-CN-YunxiNeural(男声)"
},
"rate": {
"type": "integer",
"description": "语速调整,范围 -50 到 +50,默认 0"
}
},
"required": ["action", "text"]
}
技能 2:tts_save_mp3(可选)
技能名称: tts_save_mp3
技能描述: 将文本转换为 mp3 音频文件并保存到指定路径。
脚本路径: D:\moss-plugins\tts\run.bat
参数 JSON:
{
"type": "object",
"properties": {
"action": {
"type": "string",
"description": "操作类型,固定为 savemp3",
"enum": ["savemp3"]
},
"text": {
"type": "string",
"description": "要转换的文本内容"
},
"output": {
"type": "string",
"description": "输出 mp3 文件完整路径,如 D:\\audio\\hello.mp3"
},
"voice": {
"type": "string",
"description": "语音名称,可选"
},
"rate": {
"type": "integer",
"description": "语速调整,-50 到 +50,默认 0"
}
},
"required": ["action", "text", "output"]
}
技能 3:tts_list_voices(可选)
技能名称: tts_list_voices
技能描述: 列出 edge-tts 可用的中文语音列表。
脚本路径: D:\moss-plugins\tts\run.bat
参数 JSON:
{
"type": "object",
"properties": {
"action": {
"type": "string",
"description": "操作类型,固定为 listvoices",
"enum": ["listvoices"]
}
},
"required": ["action"]
}
使用示例
- 朗读:你好世界
- 把这篇文章读给我听
- 用男声朗读这段话
- 把「欢迎光临」保存为 D:\audio\welcome.mp3
注意事项
- 需要联网:edge-tts 是在线服务
- 首次需装依赖:
pip install edge-tts pygame - pygame 不可用时,会自动用系统播放器播放(Windows 可能弹出播放器窗口)
- 与系统基础、邮件、推送等插件独立,需分别安装
常见问题
| 现象 | 处理 |
|---|---|
| 请先安装 edge-tts | 执行 pip install edge-tts pygame |
| 没有听到声音 | 检查 pygame 是否安装、系统音量是否开启 |
| 网络错误 | 检查网络连接 |
| 技能运行失败 | 检查 run.bat 路径是否正确 |