rtc-voice-chat/backend/README.md
2026-03-28 18:14:20 +08:00

50 lines
1.2 KiB
Markdown
Raw 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.

# AIGC Backend (Python FastAPI)
原 Node.js + Koa 服务的 Python 重写版本,使用 FastAPI 框架。
## 环境要求
- Python 3.9+
## 安装依赖
```shell
uv sync
```
## 场景配置
编辑 `scenes/*.json`,填写以下字段:
| 字段 | 说明 |
|------|------|
| `AccountConfig.accessKeyId` | 火山引擎 AK从 https://console.volcengine.com/iam/keymanage/ 获取 |
| `AccountConfig.secretKey` | 火山引擎 SK |
| `RTCConfig.AppId` | RTC 应用 ID |
| `RTCConfig.AppKey` | RTC 应用 Key用于自动生成 Token |
| `VoiceChat.*` | AIGC 相关配置,参考 https://www.volcengine.com/docs/6348/1558163 |
## 启动服务
```shell
uvicorn main:app --host 0.0.0.0 --port 3001 --reload
```
服务启动后监听 `http://localhost:3001`
## 接口说明
### POST /getScenes
返回所有场景列表,自动生成 RoomId/UserId/Token若未在 JSON 中配置)。
### POST /proxy?Action={Action}&Version={Version}
代理转发至火山引擎 RTC OpenAPI。
支持的 Action
- `StartVoiceChat` — 启动语音对话
- `StopVoiceChat` — 停止语音对话
请求体需包含 `SceneID` 字段,对应 `scenes/` 目录下的 JSON 文件名(不含扩展名)。