article
README
🚀 MS-Lucidia-Voice-Gateway-MCP
MS-Lucidia-Voice-Gateway-MCP 是一个借助 Windows 内置语音服务的模型上下文协议 (MCP) 服务器,它提供了文本到语音 (TTS) 和语音到文本 (STT) 功能。该服务器通过 PowerShell 命令调用 Windows 的本机语音 API (SAPI),无需依赖外部 API 或服务,使用起来更加便捷。
✨ 主要特性
- 🗣️ 使用 Windows SAPI 音色的文本到语音 (TTS)
- 👂 使用 Windows 语音识别的语音到文本 (STT)
- 💻 简单的网络界面用于测试
- 🚫 无外部 API 依赖
- 🖥️ 调用本机 Windows 功能
📦 安装指南
先决条件
- 已启用语音识别功能的 Windows 10/11 操作系统
- Node.js 16+
- PowerShell
安装步骤
- 克隆仓库:
git clone https://github.com/ExpressionsBot/MS-Lucidia-Voice-Gateway-MCP.git
cd MS-Lucidia-Voice-Gateway-MCP
- 安装依赖项:
npm install
- 构建项目:
npm run build
💻 使用示例
测试界面
- 启动测试服务器:
npm run test
- 打开浏览器访问
http://localhost:3000 - 使用网络界面测试 TTS 和 STT 功能
可用工具
text_to_speech
使用 Windows SAPI 音色将文本转换为语音。
参数:
text(必需):要转换为语音的文本voice(可选):使用的音色名称(例如,“Microsoft David Desktop”)speed(可选):语音速度,范围从 0.5 到 2.0(默认值:1.0)
示例:
fetch('http://localhost:3000/tts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: "Hello, this is a test",
voice: "Microsoft David Desktop",
speed: 1.0
})
});
speech_to_text
录音并使用 Windows 语音识别将其转换为文本。
参数:
duration(可选):录音持续时间,单位为秒(默认值:5,最大值:60)
示例:
fetch('http://localhost:3000/stt', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
duration: 5
})
}).then(response => response.json())
.then(data => console.log(data.text));
📚 详细文档
故障排除
-
确保 Windows 语音识别功能已启用:
- 打开 Windows 设置
- 进入时间和语言 > 语音
- 启用语音识别
-
检查可用音色:
- 打开 PowerShell 并运行:
Add-Type -AssemblyName System.Speech (New-Object System.Speech.Synthesis.SpeechSynthesizer).GetInstalledVoices().VoiceInfo.Name -
测试语音识别:
- 打开 Windows 设置中的语音识别
- 如果尚未完成,运行安装向导进行设置
- 测试 Windows 是否能识别您的语音
贡献
- 叉克隆仓库
- 创建功能分支
- 提交更改
- 推送到远程仓库
- 提交拉取请求
📄 许可证
[在此处添加许可证信息]
微信扫一扫