MS-Lucidia-Voice-Gateway-MCP 是一个借助 Windows 内置语音服务的模型上下文协议 (MCP) 服务器,它提供了文本到语音 (TTS) 和语音到文本 (STT) 功能。该服务器通过 PowerShell 命令调用 Windows 的本机语音 API (SAPI),无需依赖外部 API 或服务,使用起来更加便捷。
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使用 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
})
});
录音并使用 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 语音识别功能已启用:
检查可用音色:
Add-Type -AssemblyName System.Speech
(New-Object System.Speech.Synthesis.SpeechSynthesizer).GetInstalledVoices().VoiceInfo.Name
测试语音识别:
[在此处添加许可证信息]