本文档记录了 stt-demo 项目的当前状态,包括技术债务、工作变通方案和实际使用模式。它作为AI代理进行增强开发的参考文档。
全面记录整个系统的文档化
| 日期 | 版本 | 描述 | 作者 |
|---|---|---|---|
| 2025-09-25 | 1.0 | 初始现有系统分析 | Winston |
src/main.tsx - React应用启动文件src/App.tsx - 根组件src/router/index.tsx - 路由定义src/store/index.ts - Redux store配置src/store/reducers/global.ts - 全局状态管理src/manager/ - RTC、RTM、STT管理器src/pages/ - 主要页面组件src/common/ - 工具函数和hookssrc/types/index.ts - TypeScript类型定义这是一个基于Agora RTC/RTM的实时语音转文字Web应用,支持多语言实时转录和翻译功能。
| 类别 | 技术 | 版本 | 备注 |
|---|---|---|---|
| 运行时 | Node.js | 18+ | 开发环境要求 |
| 前端框架 | React | 18.2.0 | 函数式组件 + Hooks |
| 状态管理 | Redux Toolkit | 1.6.2 | 简化Redux使用 |
| 构建工具 | Vite | 5.0.8 | 快速开发构建 |
| UI组件库 | Ant Design | 5.15.3 | 企业级UI组件 |
| 实时通信 | Agora RTC SDK | 4.20.0 | 音视频通信 |
| 实时消息 | Agora RTM | 2.1.9 | 实时消息传递 |
| 国际化 | i18next | 23.8.2 | 多语言支持 |
| 路由 | React Router DOM | 6.21.3 | 单页面应用路由 |
| 类型系统 | TypeScript | 5.2.2 | 类型安全 |
stt-demo/
├── src/
│ ├── components/ # 可复用UI组件
│ │ ├── avatar/ # 用户头像组件
│ │ ├── caption/ # 字幕显示组件
│ │ ├── center-area/ # 主视频区域
│ │ ├── dialog/ # 对话框组件
│ │ ├── footer/ # 底部控制栏
│ │ ├── header/ # 顶部导航栏
│ │ ├── icons/ # 图标组件
│ │ ├── menu/ # 侧边菜单
│ │ ├── stream-player/ # 视频流播放器
│ │ └── user-list/ # 用户列表
│ ├── pages/ # 页面组件
│ │ ├── 404/ # 404页面
│ │ ├── home/ # 主页面(音视频通话)
│ │ └── login/ # 登录页面
│ ├── manager/ # 核心业务逻辑管理器
│ │ ├── events.ts # 事件系统
│ │ ├── parser/ # 数据解析器
│ │ ├── rtc/ # RTC音视频管理
│ │ ├── rtm/ # RTM实时消息管理
│ │ └── stt/ # 语音转文字管理
│ ├── store/ # 状态管理
│ │ └── reducers/ # Redux reducers
│ ├── common/ # 通用工具
│ │ ├── hooks.ts # 自定义React Hooks
│ │ ├── request.ts # API请求封装
│ │ ├── utils.ts # 工具函数
│ │ └── storage.ts # 本地存储
│ ├── i18n/ # 国际化配置
│ ├── router/ # 路由配置
│ ├── types/ # TypeScript类型定义
│ ├── protobuf/ # Protobuf定义
│ └── styles/ # 样式文件
├── public/ # 静态资源
├── docs/ # 文档目录(新创建)
└── 配置文件...
src/manager/rtc/rtc.ts - 处理音视频通话连接、发布/订阅流src/manager/rtm/rtm.ts - 处理实时消息、用户状态同步src/manager/stt/stt.ts - 语音转文字任务管理src/store/reducers/global.ts - 管理用户信息、UI状态、STT数据src/pages/home/index.tsx - 音视频通话主界面,集成所有管理器src/pages/login/index.tsx - 用户登录和频道加入参考实际类型定义文件:
src/types/index.ts 中的 IUserInfo 接口src/types/index.ts 中的 ISttData 接口src/types/index.ts 中的 ITextItem 接口src/types/index.ts 中的 IOptions 接口项目使用Agora的REST API进行语音转文字服务:
apiGetAgoraToken() - 获取Agora RTC tokenapiSTTStartTranscription() - 启动语音转文字任务apiSTTStopTranscription() - 停止语音转文字任务apiSTTQueryTranscription() - 查询任务状态apiSTTUpdateTranscription() - 更新任务配置src/store/reducers/global.ts 包含过多状态,可能需要拆分| 服务 | 用途 | 集成类型 | 关键文件 |
|---|---|---|---|
| Agora RTC | 音视频通信 | SDK | src/manager/rtc/ |
| Agora RTM | 实时消息 | SDK | src/manager/rtm/ |
| Agora STT | 语音转文字 | REST API | src/common/request.ts |
npm install 或 yarn install.env 文件并配置Agora App ID和Certificatenpm run dev 或 yarn devnpm run build (Vite构建配置在 vite.config.ts)npm run build:testnpm run previewnpm run lintnpm run prettiernpm run lint # 代码检查
# 需要添加测试脚本
npm run dev # 启动开发服务器
npm run build # 生产构建
npm run preview # 预览生产构建
npm run lint # 代码检查
npm run lint:fix # 自动修复代码问题
npm run prettier # 代码格式化
console.log