MCP音频收发器
一个Dockered Python工具,通过AssemblyAI的API实现模型上下文协议(MCP)。上传或指向音频文件,并接收结构化的JSON转录。
特性
- 组装MCP:使用AssemblyAI的REST API的具体MCP实现
- 命令行界面 (
app.py):
python app.py - 流线型web UI (
streamlit_app.py):
- 上传本地文件或粘贴URL - 单击转录 - 预览成绩单并下载JSON
- Docker支持 实现环境一致性和可移植性
先决条件
- Python 3.10+
- AssemblyAI API密钥
- ffmpeg(用于本地解码,如果使用本地文件)
- (可选)Docker桌面/引擎
- (可选)流光灯(
pip install streamlit)
🔧 安装
- 克隆仓库
git clone https://github.com/ShreyasTembhare/MCP---Audio-Transcriber.git
cd MCP---Audio-Transcriber- 创建一个
.env
ASSEMBLYAI_API_KEY=your_assemblyai_api_key_here- 确保
.gitignore包含:
.env- 安装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/ 到你的路径
用法
1.CLI转录
python app.py - ``:AssemblyAI支持的任何文件或URL
- ``:生成JSON的路径
例子:
python app.py data/input.ogg data/output.json
cat data/output.json2.流线型Web UI
streamlit run streamlit_app.py- 打开http://localhost:8501
- 上传或输入音频URL
- 单击转录
- 下载JSON结果
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.jsonWindows 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