返回市场
明声语音网关_mCP

明声语音网关_mCP

作者:ExpressionsBot5 星标更新:2025-01-17

项目介绍

MS-Lucidia-Voice-Gateway-MCP

这是一个使用Windows内置语音服务提供文本转语音(TTS)和语音转文本(STT)功能的模型上下文协议(MCP)服务器。该服务器通过PowerShell命令利用Windows语音API(SAPI),无需依赖外部API或服务。

功能

  • 使用Windows SAPI语音进行文本转语音(TTS)
  • 使用Windows语音识别进行语音转文本(STT)
  • 简单的Web界面用于测试
  • 没有外部API依赖
  • 利用原生Windows功能

预备条件

  • 启用了语音识别的Windows 10/11
  • Node.js 16+
  • PowerShell

安装

  1. 克隆仓库:
git clone https://github.com/ExpressionsBot/MS-Lucidia-Voice-Gateway-MCP.git
cd MS-Lucidia-Voice-Gateway-MCP
  1. 安装依赖项:
npm install
  1. 构建项目:
npm run build

使用方法

测试接口

  1. 启动测试服务器:
npm run test
  1. 在浏览器中打开http://localhost:3000
  2. 使用Web界面测试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));

故障排除

  1. 确保启用了Windows语音识别:

    • 打开Windows设置
    • 转到时间和语言 > 语音
    • 启用语音识别
  2. 检查可用语音:

    • 打开PowerShell并运行:
    Add-Type -AssemblyName System.Speech
    (New-Object System.Speech.Synthesis.SpeechSynthesizer).GetInstalledVoices().VoiceInfo.Name
    
  3. 测试语音识别:

    • 在Windows设置中打开语音识别
    • 如果尚未完成,请运行设置向导
    • 测试Windows是否能识别您的声音

贡献

  1. 分叉仓库
  2. 创建您的功能分支
  3. 提交更改
  4. 推送到分支
  5. 创建新的拉取请求

许可证

MIT