跳到正文

WSL /data/ai-voice 部署与运行手册

该目录保存 AI Voice 平台在 WSL Ubuntu 宿主机 /data/ai-voice 目录下的 ONNX 语音服务、三个应用服务端(callflow-servercallout-servercallai-server)、基础数据服务及 FRPC 反向穿透的完整部署与运行说明。

1. 架构定位与目录布局

在 WSL + 阿里云双主机混合部署架构中:

  • WSL 本地部署目录/data/ai-voice
    • ONNX 语音计算域sherpa-asr-online-server (或 fanasr-asr-online-server,端口 20096 / 10096)、sherpa-tts-server (端口 29080 / 9080)、emotion-analysis-server (端口 29090 / 9090) 及 models/ 运行时模型库。
    • 三个应用服务端callflow-server (端口 29913 / 9913)、callout-server (端口 29920 / 9920)、callai-server (统一 AI 决策中台,端口 29930 / 9930)。
    • 数据基础底座:Docker 容器运行 PostgreSQL 15 (5432)、Redis 7.2 (6379)、MySQL 8.0 (3306)、MinIO (1280/1281)。
    • FRP 客户端 (frpc):建立至阿里云公网服务器 (123.57.205.60:7000) 的加密隧道,将本地服务映射到阿里云本地回环 12000~12013 端口。
  • 阿里云公网主机 (ssh aliyun):托管 Web 前端静态站点 (callflow-webpagecallout-webpage),运行 callflow-esl 业务编排服务、Nginx (HTTPS/WSS 终结与反代)、coTURN (3478) 及已有的 FreeSWITCH 软交换中心。

目录结构 (/data/ai-voice)

text
/data/ai-voice/
├── Dockerfile                      # 基础运行环境镜像定义 (ai-voice-runtime:latest)
├── build-image.sh                  # 镜像构建脚本
├── docker-compose.yml              # 6 个业务与语音容器 + 1 个 FRPC 容器编排
├── frpc.toml                       # FRP 穿透客户端配置
├── run-frpc.sh                     # FRP 启动与网络守护脚本
├── models/                         # 运行时模型资产挂载目录
│   ├── sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/
│   ├── matcha-icefall-zh-baker/
│   ├── silero_vad/
│   ├── emotion-text/
│   └── emotion-audio/
├── callflow-server/                # callflow-server 二进制与 config.json
├── callout-server/                 # callout-server 二进制与 config.json
├── callai-server/                  # callai-server 二进制与 config.json
├── sherpa-asr-online-server/       # sherpa-asr-online-server 二进制与 config.json
├── sherpa-tts-server/              # sherpa-tts-server 二进制与 config.json
└── emotion-analysis-server/        # emotion-analysis-server 二进制与 config.json

2. 构建与部署产物分发

2.1 构建 Linux x64 二进制产物

从代码仓库根目录分别构建应用与 ONNX 服务:

bash
# 1. 构建三个 Bun 服务端独立可执行文件
bun run --cwd apps/callflow-server build
bun run --cwd apps/callout-server build
bun run --cwd apps/callai-server build

# 2. 在 Docker 工具链中构建三个 ONNX C++ 服务 (Debian 12 / Linux x64)
docker build -f onnx-platform/Dockerfile.debian12 -t ai-voice-builder onnx-platform
docker run --rm -v "$PWD:/workspace/ai-voice-platform" -w /workspace/ai-voice-platform/onnx-platform ai-voice-builder bash -c "
  bash sherpa-asr-online-server/build.sh
  bash sherpa-tts-server/build.sh
  bash emotion-analysis-server/build.sh
"

2.2 同步产物与配置至 /data/ai-voice

bash
# 创建目录层级
mkdir -p /data/ai-voice/{callflow-server,callout-server,callai-server,sherpa-asr-online-server,sherpa-tts-server,emotion-analysis-server,models}

# 复制服务端可执行文件与配置
cp apps/callflow-server/dist/callflow-server /data/ai-voice/callflow-server/
cp deploy/wsl-docker/configs/callflow-server.json /data/ai-voice/callflow-server/config.json

cp apps/callout-server/dist/callout-server /data/ai-voice/callout-server/
cp deploy/wsl-docker/configs/callout-server.json /data/ai-voice/callout-server/config.json

cp apps/callai-server/dist/callai-server /data/ai-voice/callai-server/
cp deploy/wsl-docker/configs/callai-server.json /data/ai-voice/callai-server/config.json

# 复制 ONNX 服务可执行文件、依赖库与配置
cp onnx-platform/sherpa-asr-online-server/target/linux_x64/sherpa_asr_online_server /data/ai-voice/sherpa-asr-online-server/
cp onnx-platform/sherpa-asr-online-server/target/linux_x64/*.so* /data/ai-voice/sherpa-asr-online-server/ 2>/dev/null || true
cp deploy/wsl-docker/configs/sherpa-asr-online-server.json /data/ai-voice/sherpa-asr-online-server/config.json

cp onnx-platform/sherpa-tts-server/target/linux_x64/sherpa_tts_server /data/ai-voice/sherpa-tts-server/
cp onnx-platform/sherpa-tts-server/target/linux_x64/*.so* /data/ai-voice/sherpa-tts-server/ 2>/dev/null || true
cp deploy/wsl-docker/configs/sherpa-tts-server.json /data/ai-voice/sherpa-tts-server/config.json

cp onnx-platform/emotion-analysis-server/target/linux_x64/emotion_analysis_server /data/ai-voice/emotion-analysis-server/
cp onnx-platform/emotion-analysis-server/target/linux_x64/*.so* /data/ai-voice/emotion-analysis-server/ 2>/dev/null || true
cp deploy/wsl-docker/configs/emotion-analysis-server.json /data/ai-voice/emotion-analysis-server/config.json

# 同步模型资产
cp -r onnx-platform/models/* /data/ai-voice/models/

# 部署 Dockerfile、Compose 与 FRPC 配置
cp deploy/wsl-docker/Dockerfile /data/ai-voice/
cp deploy/wsl-docker/build-image.sh /data/ai-voice/
cp deploy/wsl-docker/docker-compose.yml /data/ai-voice/
cp deploy/wsl-docker/frpc/frpc.toml /data/ai-voice/
cp deploy/wsl-docker/frpc/run-frpc.sh /data/ai-voice/

3. 运行与验证

3.1 构建基础镜像并启动集群

bash
cd /data/ai-voice

# 首次或 Dockerfile 变更时构建镜像
chmod +x build-image.sh run-frpc.sh
./build-image.sh

# 启动微服务集群与 FRPC
docker compose up -d

# 检查容器运行状态
docker compose ps

3.2 FRP 穿透隧道映射清单 (WSL ➔ 阿里云)

隧道名称本地端口阿里云回环端口目标服务说明
mysql127.0.0.1:330612000MySQL 数据库
redis127.0.0.1:637912001Redis 缓存与分布式锁
minio-api127.0.0.1:128012002MinIO 对象存储 API
minio-console127.0.0.1:128112003MinIO 管理控制台
postgres127.0.0.1:543212004PostgreSQL 核心数据库
tts127.0.0.1:2908012008Sherpa TTS 语音合成服务
emotion127.0.0.1:2909012009情绪分析 API
asr127.0.0.1:2009612010Sherpa ASR 流式识别 WebSocket
callflow-api127.0.0.1:2991312011callflow-server 业务 API
callout-api127.0.0.1:2992012012callout-server 业务 API
callai127.0.0.1:2993012013callai-server 统一决策中台 (NLU / Chat)

3.3 健康状态验证

bash
# 验证 FRPC 穿透日志
docker logs aivoice-frpc --tail 20

# 本地服务探测
curl http://127.0.0.1:20096/health  # ASR
curl http://127.0.0.1:29080/health  # TTS
curl http://127.0.0.1:29090/health  # Emotion
curl http://127.0.0.1:29913/health  # callflow-server
curl http://127.0.0.1:29920/health  # callout-server
curl http://127.0.0.1:29930/health  # callai-server

文档与代码在同一仓库维护,现有 Markdown 是唯一内容源。