ShreyasTembhare
服务介绍
MCP 音频转录器
一个使用 AssemblyAI API 实现模型上下文协议 (MCP) 的 Docker 化 Python 工具。上传或指向一个音频文件,并接收结构化的 JSON 转录结果。
功能
-
AssemblyMCP: 一个使用 AssemblyAI REST API 的具体 MCP 实现
-
命令行界面 (
app.py):
bash
python app.py <input_audio> <output_json> -
Streamlit 网页界面 (
streamlit_app.py):- 上传本地文件或粘贴 URL
- 点击转录
- 预览转录文本并下载 JSON
-
Docker 支持 以确保环境一致性和可移植性
前提条件
- Python 3.10+
- 一个 AssemblyAI API 密钥
- ffmpeg(如果使用本地文件进行本地解码)
- (可选)Docker Desktop / Engine
- (可选)Streamlit (
pip install streamlit)
🔧 安装
-
克隆仓库
bash
git clone https://github.com/ShreyasTembhare/MCP---Audio-Transcriber.git
cd MCP---Audio-Transcriber -
创建
.env文件ASSEMBLYAI_API_KEY=your_assemblyai_api_key_here
-
确保
.gitignore包含:
gitignore
.env -
安装 Python 依赖
bash
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 中
- Ubuntu/Debian:
使用方法
1. 命令行转录
bash
python app.py <input_audio> <output_json>
<input_audio>: 任何 AssemblyAI 支持的文件或 URL<output_json>: 生成的 JSON 文件路径
示例:
bash
python app.py data/input.ogg data/output.json
cat data/output.json
2. Streamlit 网页界面
bash
streamlit run streamlit_app.py
- 打开 http://localhost:8501
- 上传或输入音频 URL
- 点击转录
- 下载 JSON 结果
3. Docker
构建镜像:
bash
docker build -t mcp-transcriber .
运行它(挂载你的 data/ 文件夹):
bash
docker run --rm
-e ASSEMBLYAI_API_KEY="$ASSEMBLYAI_API_KEY"
-v "$(pwd)/data:/data"
mcp-transcriber:latest
/data/input.ogg /data/output.json
然后检查:
bash
ls data/output.json
cat data/output.json
Windows PowerShell:
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 入口点 (仅 AssemblyMCP)
├── mcp.py # ModelContextProtocol + AssemblyMCP
├── streamlit_app.py # Streamlit 界面
├── requirements.txt # assemblyai, python-dotenv, streamlit 等
├── Dockerfile # 构建容器
├── .gitignore # 忽略 .env, pycache 等
├── LICENSE # MIT 许可证
└── data/ # 示例输入和输出
├── input.ogg
└── output.json