语音转换网关

一个利用Windows内置语音服务提供文本转语音和语音转文本功能的模型上下文协议服务器。

  • by Megaprompting
  • JavaScript
  • 本地部署
  • 6 星标
  • 更新于
在 GitHub 查看 ExpressionsBot/MS-Lucidia-Voice-Gateway-MCP

使用说明

MS Lucidia语音网关MCP

一种模型上下文协议(MCP)服务器,使用Windows的内置语音服务提供文本到语音和语音到文本功能。此服务器通过PowerShell命令利用本机Windows Speech 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功能

可用工具

文本到语音

使用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. 创建新的Pull请求

许可证

麻省理工学院