Files

39 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 中文录音转写服务
该服务使用 FunASR 的中文 Paraformer、FSMN-VAD 和标点模型,为 Rust API 提供本地录音转写。模型首次启动时会下载约 2.1 GB 到持久化缓存,完成后 `/health` 才会可用。
## Docker 启动
在项目根目录执行:
```bash
docker compose -f compose.asr.yml up --build -d
curl http://127.0.0.1:10095/health
```
默认使用 CPU 且只允许一个并发推理任务。可通过 `ASR_DEVICE``ASR_MAX_CONCURRENCY``ASR_MODEL``ASR_VAD_MODEL``ASR_PUNC_MODEL` 调整。GPU 部署需要使用带 CUDA 的 PyTorch 基础环境,不能只把 CPU 镜像中的 `ASR_DEVICE` 改为 `cuda`
## 本机 Python 启动
支持 Python 3.9 及以上版本,推荐 Python 3.10
```bash
cd asr-service
python3.10 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
MODELSCOPE_CACHE=.models uvicorn app:app --host 127.0.0.1 --port 10095 --no-access-log
```
## 接口
Rust API 调用 `POST /v1/transcriptions`,以 multipart 上传 `file``language``duration_ms`,响应格式为:
```json
{
"text": "识别后的中文课堂内容。",
"duration_ms": 480000,
"request_id": "b2f6fc1c-62c1-4a99-8ab4-6f933f1bd252"
}
```