MCP 音频转录器
一个 Dockerized Python 工具,通过 AssemblyAI 的 API 实现模型上下文协议 (MCP)。上传或指向音频文件,即可接收结构化的 JSON 转录。
特征
- AssemblyMCP :使用 AssemblyAI 的 REST API 的具体 MCP 实现
- 命令行界面(
app.py
):python app.py <input_audio> <output_json>
- Streamlit 网页用户界面(
streamlit_app.py
):- 上传本地文件或粘贴 URL
- 点击转录
- 预览成绩单并下载 JSON
- Docker 对环境一致性和可移植性的支持
先决条件
- Python 3.10+
- AssemblyAI API 密钥
- ffmpeg(用于本地解码,如果使用本地文件)
- (可选)Docker 桌面/引擎
- (可选)Streamlit(
pip install streamlit
)
🔧 安装
- 克隆 repo
git clone https://github.com/ShreyasTembhare/MCP---Audio-Transcriber.git
cd MCP---Audio-Transcriber
- 创建
.env
ASSEMBLYAI_API_KEY=your_assemblyai_api_key_here
- 确保
.gitignore
包含: - 安装 Python 依赖项
pip install --upgrade pip
pip install -r requirements.txt
- 安装 ffmpeg
- Ubuntu/Debian:
sudo apt update && sudo apt install ffmpeg -y
- Windows:从https://ffmpeg.org下载并将其
bin/
添加到您的 PATH
用法
1. CLI 转录
python app.py <input_audio> <output_json>
<input_audio>
:AssemblyAI 支持的任何文件或 URL<output_json>
:生成的 JSON 的路径
例子:
python app.py data/input.ogg data/output.json
cat data/output.json
2. Streamlit Web UI
streamlit run streamlit_app.py
3. Docker
构建图像:
docker build -t mcp-transcriber .
运行它(挂载你的数据/文件夹):
docker run --rm \
-e ASSEMBLYAI_API_KEY="$ASSEMBLYAI_API_KEY" \
-v "$(pwd)/data:/data" \
mcp-transcriber:latest \
/data/input.ogg /data/output.json
然后检查:
ls data/output.json
cat data/output.json
Windows PowerShell:
docker run --rm `
-e ASSEMBLYAI_API_KEY=$env:ASSEMBLYAI_API_KEY `
-v "${PWD}\data:/data" `
mcp-transcriber:latest `
/data/input.ogg /data/output.json
项目结构
MCP-Audio-Transcriber/
├── app.py # CLI entrypoint (AssemblyMCP only)
├── mcp.py # ModelContextProtocol + AssemblyMCP
├── streamlit_app.py # Streamlit interface
├── requirements.txt # assemblyai, python-dotenv, streamlit, etc.
├── Dockerfile # builds the container
├── .gitignore # ignores .env, __pycache__, etc.
├── LICENSE # MIT license
└── data/ # sample input and output
├── input.ogg
└── output.json