从零搭建 FunASR 视频/音频文案提取服务所需的全部软硬件信息
| 软件 | 版本 | 用途 | 下载地址 |
|---|---|---|---|
| Python | 3.8 ~ 3.10 | 运行环境 | python.org/downloads |
| FFmpeg Win/Linux | 4.0+ | 音视频处理 |
Windows 下载
|
apt install ffmpeg
|
| Git Win/Linux | 2.0+ | 代码管理 |
Windows 下载
|
apt install git
|
| 软件 | 版本 | 用途 | 下载地址 |
|---|---|---|---|
| NVIDIA 驱动 | ≥ 525.x | GPU 支持 | nvidia.com/Download |
| CUDA Toolkit | ≥ 11.8 | GPU 加速 | developer.nvidia.com/cuda-toolkit |
| cuDNN | ≥ 8.7 | 深度学习 | developer.nvidia.com/cudnn (需注册) |
| 软件 | 版本 | 用途 | 下载地址 |
|---|---|---|---|
| NSSM Windows | 最新 | Windows 服务 | nssm.cc/download |
| Nginx Win/Linux | 1.20+ | 反向代理 |
nginx.org
|
apt install nginx
|
| Certbot Linux | 最新 | HTTPS 证书 | apt install certbot python3-certbot-nginx |
| Redis Win/Linux | 6.0+ | 任务队列 (可选) |
Windows Redis
|
apt install redis-server
|
| 域名 | 用途 | 端口 |
|---|---|---|
www.modelscope.cn | 首次自动下载 ASR 模型 (~2-3 GB) | 443 |
api.deepseek.com | LLM 语义纠错 (可选) | 443 |
| 端口 | 用途 | 说明 |
|---|---|---|
8000 | FunASR API 服务 | 可在启动参数修改 |
80 / 443 | Nginx 反向代理 | 对外提供 HTTP/HTTPS |
| 目录 | 用途 | 默认大小 |
|---|---|---|
uploads/ | 用户上传文件 | 按需 |
results/ | 转写结果 | 按需 |
logs/ | 应用日志 | ~100MB |
models/ | ASR 模型缓存 | 2 ~ 3 GB |
在项目根目录创建 .env 文件:
# ---- 服务配置 ----
PRELOAD_MODELS=true
# ---- 模型缓存 ----
MODELSCOPE_CACHE=/opt/FunASR-Service/models
# ---- DeepSeek LLM 纠错 (可选) ----
DEEPSEEK_API_KEY=sk-your-api-key-here
DEEPSEEK_BASE_URL=https://api.deepseek.com
DEEPSEEK_MODEL=deepseek-chat
ENABLE_LLM_CORRECT=true
LLM_CORRECT_TIMEOUT=15
LLM_CORRECT_MAX_CHARS=2000
🔑 DeepSeek API Key 获取: platform.deepseek.com
# 创建必要目录
mkdir -p uploads results logs models
# 设置权限 (假设以 www-data 用户运行)
sudo chown -R www-data:www-data /opt/FunASR-Service
sudo chmod 755 /opt/FunASR-Service/{uploads,results,logs,models}
配置 /etc/nginx/sites-available/funasr:
server {
listen 80;
server_name your-domain.com;
# 上传文件大小限制
client_max_body_size 100M;
client_body_timeout 300s;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket 支持
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 超时设置
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
}
# 启用配置
sudo ln -s /etc/nginx/sites-available/funasr /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
创建 /etc/systemd/system/funasr.service:
[Unit]
Description=FunASR Speech Recognition Service
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/FunASR-Service
EnvironmentFile=/opt/FunASR-Service/.env
ExecStart=/opt/FunASR-Service/venv/bin/uvicorn api.main:app \
--host 127.0.0.1 --port 8000 --workers 4
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable funasr
sudo systemctl start funasr
sudo systemctl status funasr # 状态
sudo journalctl -u funasr -f # 实时日志
下载 NSSM: nssm.cc/download
REM 安装为 Windows 服务
nssm install FunASR
REM 配置:
REM Application: D:\FunASR-Service\venv\Scripts\uvicorn.exe
REM Arguments: api.main:app --host 0.0.0.0 --port 8000 --workers 2
REM Start directory: D:\FunASR-Service
nssm start FunASR
# 1. 安装系统依赖
sudo apt update
sudo apt install -y python3.10 python3.10-venv python3.10-dev ffmpeg git nginx
# 2. 克隆项目
cd /opt
git clone https://github.com/your/FunASR-Service.git
cd FunASR-Service
# 3. 创建虚拟环境并安装依赖
python3.10 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 4. 创建必要目录
mkdir -p uploads results logs models
# 5. 配置环境变量
cp .env.example .env
nano .env # 编辑配置
# 6. 配置 Nginx (粘贴上面的 Nginx 配置)
sudo nano /etc/nginx/sites-available/funasr
sudo ln -s /etc/nginx/sites-available/funasr /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
# 7. 配置 Systemd 服务 (粘贴上面的 Systemd 配置)
sudo nano /etc/systemd/system/funasr.service
sudo systemctl daemon-reload
sudo systemctl enable --now funasr
# 8. 配置 HTTPS (可选)
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com
# 9. 验证
curl http://localhost:8000/health