ElevenLabs Text-to-Speech MCP

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Integrates ElevenLabs Text-to-Speech capabilities, allowing text to be converted to speech via the ElevenLabs API with voice selection and management features

杰西卡项目(ElevenLabs TTS MCP)

该项目通过模型上下文协议 (MCP) 将 ElevenLabs 的文本转语音功能与 Cursor 集成。它由一个 FastAPI 后端服务和一个 React 前端应用程序组成。

特征

  • 使用 ElevenLabs API 进行文本到语音的转换
  • 语音选择和管理
  • Cursor 的 MCP 集成
  • 现代 React 前端界面
  • WebSocket实时通信
  • 代码质量的预提交钩子
  • 自动代码格式化和 linting

项目结构

jessica/ ├── src/ │ ├── backend/ # FastAPI backend service │ └── frontend/ # React frontend application ├── terraform/ # Infrastructure as Code ├── tests/ # Test suites └── docs/ # Documentation

要求

  • Python 3.11+
  • Poetry(用于后端依赖管理)
  • Node.js 18+(用于前端)
  • 光标(用于 MCP 集成)

本地开发设置

后端设置

# Clone the repository git clone https://github.com/georgi-io/jessica.git cd jessica # Create Python virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install backend dependencies poetry install # Configure environment cp .env.example .env # Edit .env with your ElevenLabs API key # Install pre-commit hooks poetry run pre-commit install

前端设置

# Navigate to frontend directory cd src/frontend # Install dependencies npm install

开发服务器

启动后端

# Activate virtual environment if not active source .venv/bin/activate # On Windows: .venv\Scripts\activate # Start the backend python -m src.backend

后端提供:

启动前端

# In src/frontend directory npm run dev

前端开发服务器:

环境配置

后端(.env)

# ElevenLabs API ELEVENLABS_API_KEY=your-api-key # Server Configuration HOST=127.0.0.1 PORT=9020 # Development Settings DEBUG=false RELOAD=true

前端(.env)

VITE_API_URL=http://localhost:9020 VITE_WS_URL=ws://localhost:9020/ws

代码质量工具

后端

# Run all pre-commit hooks poetry run pre-commit run --all-files # Run specific tools poetry run ruff check . poetry run ruff format . poetry run pytest

前端

# Lint npm run lint # Type check npm run type-check # Test npm run test

生产部署

AWS ECR 和 GitHub Actions 设置

要启用自动构建并将 Docker 镜像推送到 Amazon ECR:

  1. 应用 Terraform 配置来创建所需的 AWS 资源:
    cd terraform terraform init terraform apply
  2. GitHub Actions 工作流程将自动:
    • 从 S3 中的 Terraform 状态读取必要的配置
    • 在推送到maindevelop分支时构建 Docker 镜像
    • 将镜像推送到 ECR,并标记latest和特定提交 SHA
  3. 无需额外的存储库变量!工作流从 Terraform 状态中获取所有必需的配置。

工作原理

GitHub Actions 工作流程配置为:

  1. 首先假设一个具有 S3 读取权限的预定义 IAM 角色
  2. 从 S3 中的 Terraform 状态文件中获取并提取配置值
  3. 使用状态文件中的实际部署角色重新进行身份验证
  4. 构建 Docker 镜像并将其推送到状态中定义的 ECR 存储库

这种方法无需手动配置 GitHub 存储库变量,并确保 CI/CD 流程始终使用当前基础设施配置。

快速概览

  • 前端:通过 jessica.georgi.io 上的 CloudFront 由 S3 提供服务
  • 后端 API:api.georgi.io/jessica
  • WebSocket:连接到 api.georgi.io/jessica/ws
  • Docker 镜像:存储在 AWS ECR 中,可以部署到 ECS/EKS
  • 基础设施:通过此存储库中的 Terraform 进行管理

MCP 与 Cursor 集成

  1. 启动后端服务器
  2. 在 Cursor 设置中,添加新的 MCP 服务器:

故障排除

常见问题

  1. API 密钥问题
    • 错误:“无效的 API 密钥”
    • 解决方案:检查.env文件
  2. 连接问题
    • 错误:“无法连接到 MCP 服务器”
    • 解决方案:验证后端是否正在运行并且端口是否正确
  3. 端口冲突
    • 错误:“地址已被使用”
    • 解决方案:更改.env中的端口
  4. WebSocket 连接失败
    • 错误:“WebSocket 连接失败”
    • 解决方案:确保后端正在运行并且 WebSocket URL 正确

如需更多帮助,请在 GitHub 上提出问题。

执照

麻省理工学院

ID: athmpgbkuh