asr-mcp

asr-mcp

MCP server for local speech-to-text using Whisper Large V3 (MLX), enabling audio transcription with text/timestamps/SRT output and LLM-based correction, all running offline on Apple Silicon.

Category
Visit Server

README

asr-mcp

基于本地 Whisper Large V3 (MLX) 模型的语音转文本 MCP 服务(stdio 传输)。转写全程本地运行,不联网、不上传音频。

功能

对外暴露两个 MCP 工具:

工具 说明
transcribe_audio 将音频转写为文本,支持三种输出:text 纯文本含标点(默认)/ timestamps 带时间轴 / srt 字幕
correct_transcription 调用当前会话的 LLM 对转写结果纠错,支持 semantic(语义/术语纠错,默认)和 reference(对照标准文稿纠错,适合字幕制作)两种模式

设计要点:

  • 工具调用与重任务解耦:转写在独立子进程(worker.py)中执行,server 以事件驱动方式等待并每 15 秒上报心跳进度,不轮询进程状态。
  • 超时语义诚实:默认超时 10 分钟;超时后不杀子进程,任务继续在后台跑完并自行落盘,工具如实返回「未完成」而非「出错」,并提示稍后检查输出文件。
  • 中文标点修复:该模型转写中文时默认不输出任何标点,本服务按语言注入 initial_prompt 引导生成规范标点。
  • Sampling 优雅回退:纠错优先走 MCP Sampling;客户端不支持时(多数客户端的现状),工具返回一份现成的纠错提示词,由当前会话的 LLM 直接完成纠错。

环境要求

  • macOS + Apple Silicon(MLX 仅支持 Apple 芯片)
  • Python ≥ 3.12
  • uv 包管理器
  • 本地模型目录(见下节)

安装

git clone https://github.com/fengredrum/asr-mcp.git
cd asr-mcp
uv sync

本项目默认 PyPI 索引为阿里云镜像(见 pyproject.toml),海外网络可在 [tool.uv] 中删除或替换该配置。

准备模型

下载模型到本地任意目录,例如:

huggingface-cli download mlx-community/whisper-large-v3-mlx --local-dir ~/models/whisper-large-v3-mlx

通过环境变量 ASR_MCP_MODEL_PATH 指定模型目录(也支持直接填 Hugging Face 仓库 ID,mlx_whisper 会自动下载):

export ASR_MCP_MODEL_PATH=~/models/whisper-large-v3-mlx

接入 MCP 客户端

以 Claude Code 为例:

claude mcp add asr-mcp \
  --env ASR_MCP_MODEL_PATH=$HOME/models/whisper-large-v3-mlx \
  -- uv --directory /绝对路径/asr-mcp run server.py

或在客户端的 MCP 配置中手动添加:

{
  "mcpServers": {
    "asr-mcp": {
      "command": "uv",
      "args": ["--directory", "/绝对路径/asr-mcp", "run", "server.py"],
      "env": {
        "ASR_MCP_MODEL_PATH": "/你的模型目录/whisper-large-v3-mlx"
      }
    }
  }
}

接入后直接让 LLM「转写这个音频文件」即可,它会调用 transcribe_audio 并在完成后询问是否需要纠错。

调试转写链路

可绕过 MCP 直接运行 worker:

.venv/bin/python worker.py <音频路径> <text|timestamps|srt> <输出文件> [语言]

输出文件命名约定

类型 文件名
纯文本 {音频名}.txt
时间轴 {音频名}_timestamps.txt
字幕 {音频名}.srt
纠错结果(约定) {音频名}_corrected.txt

输出默认与音频文件同目录,也可由调用方指定输出目录。

项目结构

server.py        # MCP server:工具定义、子进程调度、心跳进度、Sampling 回退
worker.py        # 一次性转写工作进程,stdout 最后一行 JSON 为状态协议
transcriber.py   # mlx_whisper.transcribe 薄封装(含中文标点 workaround)
formatter.py     # text / timestamps / srt 三种格式化输出

许可证

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured