@tencent-rtc/trtc-agent-skills 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +172 -0
- package/README.zh.md +173 -0
- package/bin/cli.js +434 -0
- package/knowledge-base/index.yaml +454 -0
- package/knowledge-base/platform-slice-template.md +233 -0
- package/knowledge-base/scenario-spec.md +350 -0
- package/knowledge-base/scenarios/conference/base/general-conference.md +365 -0
- package/knowledge-base/scenarios/conference/base/webinar-conference.md +130 -0
- package/knowledge-base/scenarios/conference/medical/1v1-video-consultation.md +145 -0
- package/knowledge-base/scenarios/conference/medical/medical-multidoctor-consultation.md +113 -0
- package/knowledge-base/scenarios/live/entertainment-live-room.md +118 -0
- package/knowledge-base/slice-spec.md +546 -0
- package/knowledge-base/slices/conference/web/ai-tools.md +225 -0
- package/knowledge-base/slices/conference/web/beauty-effects.md +188 -0
- package/knowledge-base/slices/conference/web/device-control.md +338 -0
- package/knowledge-base/slices/conference/web/login-auth.md +261 -0
- package/knowledge-base/slices/conference/web/network-quality.md +190 -0
- package/knowledge-base/slices/conference/web/official-roomkit-api.md +298 -0
- package/knowledge-base/slices/conference/web/official-roomkit-login-ui.md +246 -0
- package/knowledge-base/slices/conference/web/participant-list.md +238 -0
- package/knowledge-base/slices/conference/web/participant-management.md +718 -0
- package/knowledge-base/slices/conference/web/prejoin-check.md +293 -0
- package/knowledge-base/slices/conference/web/room-call.md +213 -0
- package/knowledge-base/slices/conference/web/room-chat.md +426 -0
- package/knowledge-base/slices/conference/web/room-lifecycle.md +534 -0
- package/knowledge-base/slices/conference/web/room-schedule.md +281 -0
- package/knowledge-base/slices/conference/web/screen-share.md +211 -0
- package/knowledge-base/slices/conference/web/video-layout.md +675 -0
- package/knowledge-base/slices/conference/web/virtual-background.md +197 -0
- package/knowledge-base/slices/conference/web/webinar-interaction.md +206 -0
- package/knowledge-base/slices/live/anchor-lifecycle.md +122 -0
- package/knowledge-base/slices/live/anchor-preview.md +90 -0
- package/knowledge-base/slices/live/anchor-room-config.md +104 -0
- package/knowledge-base/slices/live/audience-list.md +86 -0
- package/knowledge-base/slices/live/audience-manage.md +92 -0
- package/knowledge-base/slices/live/audience-watch.md +85 -0
- package/knowledge-base/slices/live/audio.md +116 -0
- package/knowledge-base/slices/live/barrage.md +88 -0
- package/knowledge-base/slices/live/beauty.md +99 -0
- package/knowledge-base/slices/live/coguest-apply.md +105 -0
- package/knowledge-base/slices/live/device-control.md +91 -0
- package/knowledge-base/slices/live/error-codes.md +167 -0
- package/knowledge-base/slices/live/gift.md +84 -0
- package/knowledge-base/slices/live/ios/.gitkeep +0 -0
- package/knowledge-base/slices/live/ios/anchor-lifecycle.md +313 -0
- package/knowledge-base/slices/live/ios/anchor-preview.md +228 -0
- package/knowledge-base/slices/live/ios/anchor-room-config.md +257 -0
- package/knowledge-base/slices/live/ios/audience-list.md +353 -0
- package/knowledge-base/slices/live/ios/audience-manage.md +381 -0
- package/knowledge-base/slices/live/ios/audience-watch.md +286 -0
- package/knowledge-base/slices/live/ios/audio.md +373 -0
- package/knowledge-base/slices/live/ios/barrage.md +285 -0
- package/knowledge-base/slices/live/ios/beauty.md +323 -0
- package/knowledge-base/slices/live/ios/coguest-apply.md +506 -0
- package/knowledge-base/slices/live/ios/device-control.md +286 -0
- package/knowledge-base/slices/live/ios/error-codes.md +270 -0
- package/knowledge-base/slices/live/ios/gift.md +315 -0
- package/knowledge-base/slices/live/ios/live-list.md +269 -0
- package/knowledge-base/slices/live/ios/login-auth.md +247 -0
- package/knowledge-base/slices/live/live-list.md +82 -0
- package/knowledge-base/slices/live/login-auth.md +78 -0
- package/package.json +34 -0
- package/skills/trtc/SKILL.md +326 -0
- package/skills/trtc/room-builder/SKILL.md +138 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/README.md +108 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/docs/backend-contract.zh-CN.md +162 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/docs/integration.zh-CN.md +154 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/docs/theme.zh-CN.md +78 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/index.html +12 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/package.json +28 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/postcss.config.js +5 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/App.vue +25 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/ConsultationManagePanel.vue +838 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/LanguageSwitch.vue +102 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/LoadingSpinner.vue +6 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/MedicalAlert.vue +34 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/MedicalBusinessPanel.vue +148 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/MedicalButton.vue +49 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/MedicalConfirmDialog.vue +68 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/MedicalDataPanel.vue +196 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/MedicalRecordPanel.vue +270 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/components/PrescriptionPanel.vue +363 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/config/basic-info-config.ts +29 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/config/lib-generate-test-usersig-es.min.d.ts +4 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/config/lib-generate-test-usersig-es.min.js +2 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/config/runtime-config.ts +12 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/env.d.ts +32 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/components/ConsultationChatPanel.vue +123 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/components/ConsultationMembersPanel.vue +230 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/components/ConsultationTranscriptionPanel.vue +135 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/components/ConsultationVideoStage.vue +113 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/components/InviteDoctorDialog.vue +132 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/components/KickMemberConfirmDialog.vue +50 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/types.ts +77 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/useConsultationChat.ts +97 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/useConsultationDevices.ts +48 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/useConsultationParticipants.ts +121 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/useConsultationPermissions.ts +25 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/features/consultation/utils.ts +70 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/i18n/en-US/index.ts +553 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/i18n/index.ts +25 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/i18n/medicalTranslate.ts +85 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/i18n/state.ts +49 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/i18n/zh-CN/index.ts +463 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/main.ts +12 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/mock/appointments.ts +96 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/mock/users.ts +79 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/router/index.ts +63 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/index.ts +25 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/integration/appointmentService.ts +77 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/integration/authService.ts +38 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/integration/launchContext.ts +31 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/integration/userService.ts +35 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/mock/appointmentService.ts +43 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/mock/authService.ts +33 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/mock/userService.ts +43 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/services/adapters/types.ts +135 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/shared/icons.ts +53 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/styles/index.css +106 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/styles/tailwind.css +3 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/styles/theme.css +209 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/utils/auth.ts +50 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/utils/format.ts +24 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/utils/navigation.ts +12 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/utils/session.ts +28 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/views/DoctorConsultationView.vue +777 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/views/DoctorDashboardView.vue +678 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/views/LoginView.vue +441 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/views/PatientConsultationFinishedView.vue +185 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/views/PatientConsultationView.vue +1003 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/views/PatientSelectDoctorView.vue +317 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/src/views/PatientWaitingView.vue +454 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/tsconfig.json +21 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/tsconfig.node.json +8 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/vite.config.ts +17 -0
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation//346/216/245/345/205/245/350/257/264/346/230/216.md +6 -0
- package/skills/trtc/room-builder/tools/render_ai_instructions.py +226 -0
- package/skills/trtc-apply/SKILL.md +97 -0
- package/skills/trtc-apply/guardrails/apply_lib/__init__.py +0 -0
- package/skills/trtc-apply/guardrails/apply_lib/__pycache__/__init__.cpython-313.pyc +0 -0
- package/skills/trtc-apply/guardrails/apply_lib/__pycache__/rule_parser.cpython-313.pyc +0 -0
- package/skills/trtc-apply/guardrails/apply_lib/rule_parser.py +268 -0
- package/skills/trtc-docs/SKILL.md +207 -0
- package/skills/trtc-onboarding/SKILL.md +839 -0
- package/skills/trtc-onboarding/reference/path-a1-demo.md +103 -0
- package/skills/trtc-onboarding/reference/path-a2-integrate.md +693 -0
- package/skills/trtc-onboarding/reference/path-b-troubleshoot.md +115 -0
- package/skills/trtc-onboarding/reference/path-c-expand.md +43 -0
- package/skills/trtc-onboarding/reference/reporting-protocol.md +174 -0
- package/skills/trtc-onboarding/reference/supported-matrix.md +100 -0
- package/skills/trtc-onboarding/reference/usersig-handling.md +140 -0
- package/skills/trtc-search/SKILL.md +221 -0
- package/skills/trtc-topic/SKILL.md +638 -0
- package/skills/trtc-topic/guardrails/__pycache__/gate_slice_read.cpython-313.pyc +0 -0
- package/skills/trtc-topic/guardrails/__pycache__/gate_slice_write.cpython-313.pyc +0 -0
- package/skills/trtc-topic/guardrails/__pycache__/stop_require_apply_evidence.cpython-313.pyc +0 -0
- package/skills/trtc-topic/guardrails/gate_slice_read.py +133 -0
- package/skills/trtc-topic/guardrails/gate_slice_write.py +169 -0
- package/skills/trtc-topic/guardrails/stop_require_apply_evidence.py +97 -0
- package/skills/trtc-topic/references/execution-units.yaml +58 -0
- package/skills/trtc-topic/runtime/README.md +50 -0
- package/skills/trtc-topic/runtime/RUNTIME.md +128 -0
- package/skills/trtc-topic/runtime/lib/__init__.py +0 -0
- package/skills/trtc-topic/runtime/lib/platforms.py +194 -0
- package/skills/trtc-topic/runtime/package-lock.json +1211 -0
- package/skills/trtc-topic/runtime/package.json +13 -0
- package/skills/trtc-topic/runtime/telemetry-bridge.mjs +339 -0
- package/skills/trtc-topic/runtime/telemetry_collector.py +293 -0
- package/skills/trtc-topic/scripts/STATE-MACHINE-GUIDE.md +186 -0
- package/skills/trtc-topic/scripts/__pycache__/apply.cpython-313.pyc +0 -0
- package/skills/trtc-topic/scripts/apply.py +581 -0
- package/skills/trtc-topic/scripts/finalize_session.py +113 -0
- package/skills/trtc-topic/scripts/init_slice_queue.py +96 -0
- package/skills/trtc-topic/scripts/lib/__pycache__/state_machine.cpython-313.pyc +0 -0
- package/skills/trtc-topic/scripts/lib/state_machine.py +328 -0
- package/skills/trtc-topic/scripts/next_slice.py +137 -0
- package/skills/trtc-topic/tests/README.md +70 -0
- package/skills/trtc-topic/tests/__pycache__/conftest.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_apply_cli.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_apply_cli.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_end_to_end.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_end_to_end.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_finalize_session.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_finalize_session.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_gates.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_gates.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_session_resolver.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_session_resolver.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_state_machine.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_state_machine.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_stop_require_apply.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_stop_require_apply.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_topic_skill_invariants.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-topic/tests/__pycache__/test_topic_skill_invariants.cpython-313-pytest-9.0.3.pyc +0 -0
- package/skills/trtc-topic/tests/conftest.py +72 -0
- package/skills/trtc-topic/tests/test_apply_cli.py +480 -0
- package/skills/trtc-topic/tests/test_end_to_end.py +305 -0
- package/skills/trtc-topic/tests/test_finalize_session.py +51 -0
- package/skills/trtc-topic/tests/test_gates.py +316 -0
- package/skills/trtc-topic/tests/test_session_resolver.py +260 -0
- package/skills/trtc-topic/tests/test_state_machine.py +414 -0
- package/skills/trtc-topic/tests/test_stop_require_apply.py +99 -0
- package/skills/trtc-topic/tests/test_topic_skill_invariants.py +130 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: conference/ai-tools
|
|
3
|
+
name: AI 实时转写与字幕
|
|
4
|
+
product: conference
|
|
5
|
+
platform: web
|
|
6
|
+
tags: [ai, asr, transcription, subtitle, translation, realtime]
|
|
7
|
+
platforms: [web]
|
|
8
|
+
related: [conference/room-lifecycle, conference/participant-management]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# AI 实时转写与字幕
|
|
12
|
+
|
|
13
|
+
## 功能说明
|
|
14
|
+
|
|
15
|
+
AI 实时转写与字幕负责会议中的实时语音转文字、字幕展示、翻译语言设置和转写消息列表。业务 UI 可以把它做成工具栏入口、侧栏面板或浮层字幕;房主负责启动和更新转写配置,其他成员主要消费字幕和消息结果。
|
|
16
|
+
|
|
17
|
+
## 核心概念
|
|
18
|
+
|
|
19
|
+
| 能力 | 说明 |
|
|
20
|
+
|------|------|
|
|
21
|
+
| `useAITranscriberState()` | 启停和更新实时转写配置 |
|
|
22
|
+
| `startRealtimeTranscriber()` | 启动实时转写,传入源语言和翻译目标语言 |
|
|
23
|
+
| `stopRealtimeTranscriber()` | 停止实时转写,离房或角色变化时需要收口 |
|
|
24
|
+
| `updateRealTimeTranscriber()` | 转写运行中更新语言配置 |
|
|
25
|
+
| `RealtimeTranscriberEvent` | 监听转写启动、停止等状态 |
|
|
26
|
+
| `Subtitle` | 字幕展示组件 |
|
|
27
|
+
| `RealtimeMessageList` | 实时转写消息列表组件 |
|
|
28
|
+
| `SubtitleDisplayMode` | 字幕展示模式,当前是 `'bilingual'` / `'translation'` 这类字符串类型 |
|
|
29
|
+
|
|
30
|
+
## 前置条件
|
|
31
|
+
|
|
32
|
+
**通用依赖**:见 [login-auth 平台 slice](login-auth.md)。
|
|
33
|
+
|
|
34
|
+
**额外依赖**:
|
|
35
|
+
- 已安装 `tuikit-atomicx-vue3@latest`
|
|
36
|
+
- 已完成会议 UI 入口设计,例如工具栏按钮、侧栏面板或字幕浮层。
|
|
37
|
+
|
|
38
|
+
## 最佳实践
|
|
39
|
+
|
|
40
|
+
### ✅ ALWAYS
|
|
41
|
+
|
|
42
|
+
1. **AI 工具入口应由业务 UI 显式控制** —— 只有在当前会议和用户权限满足条件时才展示入口。
|
|
43
|
+
2. **只让房主启动或更新实时转写** —— 推荐用 `currentRoom.roomOwner.userId === localParticipant.userId` 判断管理权。
|
|
44
|
+
3. **打开字幕或转写面板前先确保 ASR 已启动** —— 面板消费的是实时转写状态,不应空开。
|
|
45
|
+
4. **监听转写停止事件并关闭相关 UI** —— ASR 停止后字幕和实时消息面板应同步收口。
|
|
46
|
+
5. **房间切换时重置语言、字幕模式和启动状态** —— 防止跨房间继承旧配置。
|
|
47
|
+
6. **处理套餐或权限类错误** —— 启动失败时要给出可理解提示,而不是只打印日志。
|
|
48
|
+
|
|
49
|
+
### ❌ NEVER
|
|
50
|
+
|
|
51
|
+
1. **不要让每个成员都尝试启动转写** —— 会造成重复请求、权限失败或状态混乱。
|
|
52
|
+
2. **不要在离房后保留字幕浮层** —— 旧房间的实时内容不应残留到下一场会议。
|
|
53
|
+
3. **不要只切 UI 语言而不调用 `updateRealTimeTranscriber()`** —— 运行中的转写配置不会自动变化。
|
|
54
|
+
|
|
55
|
+
## 代码示例
|
|
56
|
+
|
|
57
|
+
### 启动、停止和更新实时转写
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { ref, watch } from 'vue';
|
|
61
|
+
import {
|
|
62
|
+
RealtimeTranscriberEvent,
|
|
63
|
+
useAITranscriberState,
|
|
64
|
+
useRoomParticipantState,
|
|
65
|
+
useRoomState,
|
|
66
|
+
} from 'tuikit-atomicx-vue3/room';
|
|
67
|
+
import type { SubtitleDisplayMode } from 'tuikit-atomicx-vue3/room';
|
|
68
|
+
|
|
69
|
+
const sourceLanguage = ref('auto');
|
|
70
|
+
const targetLanguage = ref('');
|
|
71
|
+
const subtitleDisplayMode = ref<SubtitleDisplayMode>('translation');
|
|
72
|
+
const hasStartedASR = ref(false);
|
|
73
|
+
|
|
74
|
+
const {
|
|
75
|
+
startRealtimeTranscriber,
|
|
76
|
+
stopRealtimeTranscriber,
|
|
77
|
+
updateRealTimeTranscriber,
|
|
78
|
+
subscribeEvent,
|
|
79
|
+
} = useAITranscriberState();
|
|
80
|
+
|
|
81
|
+
const { currentRoom } = useRoomState();
|
|
82
|
+
const { localParticipant } = useRoomParticipantState();
|
|
83
|
+
|
|
84
|
+
const canManageTranscriber = () =>
|
|
85
|
+
currentRoom.value?.roomOwner?.userId === localParticipant.value?.userId;
|
|
86
|
+
|
|
87
|
+
subscribeEvent(RealtimeTranscriberEvent.onRealtimeTranscriberStarted, () => {
|
|
88
|
+
hasStartedASR.value = true;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
subscribeEvent(RealtimeTranscriberEvent.onRealtimeTranscriberStopped, () => {
|
|
92
|
+
hasStartedASR.value = false;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export async function ensureASRStarted() {
|
|
96
|
+
if (!canManageTranscriber() || hasStartedASR.value) return;
|
|
97
|
+
|
|
98
|
+
await startRealtimeTranscriber({
|
|
99
|
+
sourceLanguage: sourceLanguage.value || 'auto',
|
|
100
|
+
translationLanguages: targetLanguage.value ? [targetLanguage.value] : [],
|
|
101
|
+
});
|
|
102
|
+
hasStartedASR.value = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function saveASRSettings(options: {
|
|
106
|
+
sourceLanguage?: string;
|
|
107
|
+
targetLanguage?: string;
|
|
108
|
+
subtitleDisplayMode?: SubtitleDisplayMode;
|
|
109
|
+
}) {
|
|
110
|
+
const nextSourceLanguage = options.sourceLanguage ?? sourceLanguage.value;
|
|
111
|
+
const nextTargetLanguage = options.targetLanguage ?? targetLanguage.value;
|
|
112
|
+
|
|
113
|
+
sourceLanguage.value = nextSourceLanguage;
|
|
114
|
+
targetLanguage.value = nextTargetLanguage;
|
|
115
|
+
subtitleDisplayMode.value = options.subtitleDisplayMode ?? subtitleDisplayMode.value;
|
|
116
|
+
|
|
117
|
+
if (canManageTranscriber() && hasStartedASR.value) {
|
|
118
|
+
await updateRealTimeTranscriber({
|
|
119
|
+
sourceLanguage: sourceLanguage.value || 'auto',
|
|
120
|
+
translationLanguages: targetLanguage.value ? [targetLanguage.value] : [],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function stopASR() {
|
|
126
|
+
if (!hasStartedASR.value) return;
|
|
127
|
+
await stopRealtimeTranscriber();
|
|
128
|
+
hasStartedASR.value = false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
watch(() => currentRoom.value?.roomId, () => {
|
|
132
|
+
sourceLanguage.value = 'auto';
|
|
133
|
+
targetLanguage.value = '';
|
|
134
|
+
hasStartedASR.value = false;
|
|
135
|
+
}, { immediate: true });
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 字幕浮层与实时转写消息列表
|
|
139
|
+
|
|
140
|
+
```vue
|
|
141
|
+
<template>
|
|
142
|
+
<Subtitle
|
|
143
|
+
v-if="isSubtitlesVisible"
|
|
144
|
+
:target-language="targetLanguage"
|
|
145
|
+
:display-mode="subtitleDisplayMode"
|
|
146
|
+
/>
|
|
147
|
+
|
|
148
|
+
<RealtimeMessageList
|
|
149
|
+
v-if="isRealtimeMessageListVisible"
|
|
150
|
+
:target-language="targetLanguage"
|
|
151
|
+
:display-mode="subtitleDisplayMode"
|
|
152
|
+
/>
|
|
153
|
+
</template>
|
|
154
|
+
|
|
155
|
+
<script setup lang="ts">
|
|
156
|
+
import { ref } from 'vue';
|
|
157
|
+
import {
|
|
158
|
+
RealtimeMessageList,
|
|
159
|
+
Subtitle,
|
|
160
|
+
} from 'tuikit-atomicx-vue3/room';
|
|
161
|
+
import type { SubtitleDisplayMode } from 'tuikit-atomicx-vue3/room';
|
|
162
|
+
|
|
163
|
+
const isSubtitlesVisible = ref(false);
|
|
164
|
+
const isRealtimeMessageListVisible = ref(false);
|
|
165
|
+
const targetLanguage = ref('');
|
|
166
|
+
const subtitleDisplayMode = ref<SubtitleDisplayMode>('translation');
|
|
167
|
+
</script>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 平台特有注意事项
|
|
171
|
+
|
|
172
|
+
### 1. 管理权以房主为准
|
|
173
|
+
推荐只让房主启动或更新 ASR 配置。如果业务要放开给管理员,需要明确权限规则,并处理多人同时更新配置的冲突。
|
|
174
|
+
|
|
175
|
+
### 2. 打开 UI 前先启动 ASR
|
|
176
|
+
字幕浮层和转写消息列表只是展示层。点击入口时应先调用 `ensureASRStarted()`,成功后再打开字幕或侧栏。
|
|
177
|
+
|
|
178
|
+
### 3. 停止后同步关闭 UI
|
|
179
|
+
监听 `RealtimeTranscriberEvent.onRealtimeTranscriberStopped`,转写停止后关闭字幕、实时消息面板和设置弹层,避免残留。
|
|
180
|
+
|
|
181
|
+
### 4. 套餐错误要显式提示
|
|
182
|
+
启动实时转写可能返回套餐未开通、权限不足或频控类错误。遇到 `ERR_REQUIRE_PAYMENT` 时应提示需要开通对应套餐。
|
|
183
|
+
|
|
184
|
+
## 代码生成约束
|
|
185
|
+
|
|
186
|
+
### MUST
|
|
187
|
+
|
|
188
|
+
1. **通过 `useAITranscriberState()` 启停和更新转写**。
|
|
189
|
+
**Verify**: 检查是否存在 `startRealtimeTranscriber()` / `stopRealtimeTranscriber()`。
|
|
190
|
+
2. **打开字幕或转写面板前确保 ASR 已启动**。
|
|
191
|
+
**Verify**: 检查入口点击前是否调用 `ensureASRStarted()` 或等价逻辑。
|
|
192
|
+
3. **房间切换或转写停止时清理 UI 状态**。
|
|
193
|
+
**Verify**: 检查 `currentRoom.roomId` watch 或 `onRealtimeTranscriberStopped` 监听。
|
|
194
|
+
4. **运行中改语言时调用 `updateRealTimeTranscriber()`**。
|
|
195
|
+
**Verify**: 检查保存设置逻辑中是否调用更新接口。
|
|
196
|
+
|
|
197
|
+
### MUST NOT
|
|
198
|
+
|
|
199
|
+
1. **不要让每个参会人都启动 ASR**。
|
|
200
|
+
**Verify**: 检查是否有房主或业务权限判断。
|
|
201
|
+
2. **不要只渲染 `Subtitle` 而没有转写启动链路**。
|
|
202
|
+
**Verify**: 检查字幕入口是否能触发启动。
|
|
203
|
+
|
|
204
|
+
## 验证矩阵
|
|
205
|
+
|
|
206
|
+
| 层级 | 检查项 | 验证手段 | 预期结果 |
|
|
207
|
+
|------|--------|----------|---------|
|
|
208
|
+
| 1. 编译级 | AI 转写 API 可解析 | 检查 `useAITranscriberState`、`Subtitle` 导入 | 类型可解析 |
|
|
209
|
+
| 2. 静态规则级 | 启动、更新、停止链路完整 | 搜索 `startRealtimeTranscriber` / `updateRealTimeTranscriber` / `stopRealtimeTranscriber` | 三段链路存在 |
|
|
210
|
+
| 3. 运行时级 | 房主可打开字幕和转写列表 | 房主账号点击 AI 工具 | ASR 启动并展示内容 |
|
|
211
|
+
| 4. 业务行为级 | 切房间或停止后 UI 收口 | 离房或停止 ASR | 字幕和转写面板关闭 |
|
|
212
|
+
|
|
213
|
+
## 排障指南
|
|
214
|
+
|
|
215
|
+
| 问题 | 表现 | 处理建议 |
|
|
216
|
+
|------|------|----------|
|
|
217
|
+
| 点击字幕后没有内容 | 字幕浮层打开但无文本 | 检查是否已调用 `startRealtimeTranscriber()` |
|
|
218
|
+
| 非房主启动失败 | 普通成员打开 AI 工具报错 | 只允许房主启动,其他成员消费已有转写结果 |
|
|
219
|
+
| 切换语言不生效 | 设置面板保存后字幕仍旧语言 | 转写已启动时调用 `updateRealTimeTranscriber()` |
|
|
220
|
+
| 离房后字幕残留 | 下一场会议仍显示旧字幕 | 监听 roomId 变化和 stopped 事件,清理 UI 状态 |
|
|
221
|
+
|
|
222
|
+
## 关联知识
|
|
223
|
+
|
|
224
|
+
- **[conference/room-lifecycle](room-lifecycle.md)** —— 进退房决定 AI 状态的初始化与清理时机。
|
|
225
|
+
- **[conference/participant-management](participant-management.md)** —— 房主身份和角色变化会影响 AI 管理权。
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: conference/beauty-effects
|
|
3
|
+
name: 美颜效果
|
|
4
|
+
product: conference
|
|
5
|
+
platform: web
|
|
6
|
+
tags: [beauty, FreeBeautyPanel, useFreeBeautyState, preview]
|
|
7
|
+
platforms: [web]
|
|
8
|
+
related: [conference/device-control, conference/video-layout, conference/virtual-background]
|
|
9
|
+
api_docs:
|
|
10
|
+
- title: 基础美颜
|
|
11
|
+
url: https://cloud.tencent.com/document/product/647/126937
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# 美颜效果
|
|
15
|
+
|
|
16
|
+
## 功能说明
|
|
17
|
+
|
|
18
|
+
美颜效果负责会议中本地视频的人像基础增强,包括磨皮、美白、红润等参数调节,以及从实时预览到正式保存生效的两阶段体验。它处理的是本地视频前处理效果,不负责摄像头开关、房间主链路或背景替换。
|
|
19
|
+
|
|
20
|
+
## 核心概念
|
|
21
|
+
|
|
22
|
+
### 角色与操作
|
|
23
|
+
|
|
24
|
+
| 角色 | 关键操作 | 说明 |
|
|
25
|
+
|------|----------|------|
|
|
26
|
+
| 当前参会人 | 调节美颜参数 | 根据个人偏好调整磨皮、美白、红润等基础效果 |
|
|
27
|
+
| 美颜面板 | 提供预览与确认 | 承载参数调整、重置与保存入口 |
|
|
28
|
+
| 本地视频处理链 | 应用美颜结果 | 把保存后的参数真正作用到本地视频流 |
|
|
29
|
+
| 相邻能力模块 | 与设备 / 背景 / 布局联动 | 摄像头状态影响预览前提,虚拟背景与美颜共同作用于本地视频 |
|
|
30
|
+
|
|
31
|
+
### 事件流
|
|
32
|
+
|
|
33
|
+
| 阶段 | 参与方 | 关键动作 |
|
|
34
|
+
|------|--------|----------|
|
|
35
|
+
| 打开面板 | 当前参会人 | 进入本地美颜设置界面 |
|
|
36
|
+
| 实时预览 | 当前参会人 / 本地视频处理链 | 调整参数并即时预览效果 |
|
|
37
|
+
| 确认保存 | 当前参会人 | 将当前预览值正式保存到视频效果设置中 |
|
|
38
|
+
| 会中生效 | 本地视频流 | 远端开始看到保存后的美颜效果 |
|
|
39
|
+
| 重置或关闭 | 当前参会人 | 清空或恢复默认效果,退出当前设置流程 |
|
|
40
|
+
|
|
41
|
+
### 状态与数据
|
|
42
|
+
|
|
43
|
+
| 数据 / 状态 | 说明 |
|
|
44
|
+
|-------------|------|
|
|
45
|
+
| 美颜参数集合 | 磨皮、美白、红润等基础美颜值 |
|
|
46
|
+
| 预览态参数 | 当前面板内临时调整、尚未正式保存的参数 |
|
|
47
|
+
| 已保存参数 | 真正对视频流生效的美颜设置 |
|
|
48
|
+
| 面板开关状态 | 标识当前是否处于美颜设置流程 |
|
|
49
|
+
| 本地视频可用态 | 决定当前是否具备可感知的实时预览前提 |
|
|
50
|
+
|
|
51
|
+
### 状态机
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
off
|
|
55
|
+
→ panel-opened
|
|
56
|
+
→ previewing
|
|
57
|
+
→ saved
|
|
58
|
+
→ active
|
|
59
|
+
→ reset
|
|
60
|
+
→ off
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 前置条件
|
|
64
|
+
**通用依赖**:见 [login-auth 平台 slice](login-auth.md)。
|
|
65
|
+
|
|
66
|
+
**额外依赖**:
|
|
67
|
+
- 已安装 `tuikit-atomicx-vue3@latest`
|
|
68
|
+
|
|
69
|
+
**前置状态**:
|
|
70
|
+
- 已阅读 `conference/beauty-effects`,明确当前能力的产品边界。
|
|
71
|
+
- 已完成 `conference/login-auth`,确保当前页面具备稳定登录态。
|
|
72
|
+
- 已根据业务流程接入会议上下文;需要房间状态时,优先通过 `conference/room-lifecycle` 统一承接。
|
|
73
|
+
- 当前能力涉及媒体采集、渲染或浏览器权限时,请在 `HTTPS` 或 `localhost` 安全上下文下调试。
|
|
74
|
+
|
|
75
|
+
## 最佳实践
|
|
76
|
+
|
|
77
|
+
### ✅ ALWAYS
|
|
78
|
+
|
|
79
|
+
1. **把实时预览和正式保存拆成两段** —— 让用户先试效果,再决定是否真正作用到会中画面。
|
|
80
|
+
2. **在摄像头已准备好的前提下再强调预览体验** —— 没有本地视频输入时,很难判断美颜调整是否真实生效。
|
|
81
|
+
3. **把美颜参数集中维护** —— 面板、预览区和最终保存动作应围绕同一份参数模型工作。
|
|
82
|
+
4. **和虚拟背景等本地视频特效能力明确编排关系** —— 都属于本地视频前处理,但初始化与兼容性要求不同。
|
|
83
|
+
|
|
84
|
+
### ❌ NEVER
|
|
85
|
+
|
|
86
|
+
1. **不要把美颜效果写成摄像头控制能力** —— 摄像头开关属于 `device-control`,美颜只处理视频前处理效果。
|
|
87
|
+
2. **不要在用户拖动滑杆时无条件永久保存** —— 如果产品设计要求确认保存,应保留预览态和提交态分层。
|
|
88
|
+
3. **不要忽略重置和退出流程的状态收口** —— 否则面板关闭后,用户很难理解当前到底应用了哪组参数。
|
|
89
|
+
|
|
90
|
+
## 代码示例
|
|
91
|
+
### 基础接入:实时预览并显式保存美颜设置
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { useFreeBeautyState } from 'tuikit-atomicx-vue3/room';
|
|
95
|
+
|
|
96
|
+
const { setFreeBeauty, saveBeautySetting } = useFreeBeautyState();
|
|
97
|
+
|
|
98
|
+
await setFreeBeauty({ beautyLevel: 60, whitenessLevel: 40, ruddinessLevel: 20 });
|
|
99
|
+
await saveBeautySetting();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 调用时序
|
|
103
|
+
```
|
|
104
|
+
完成 login-auth 并打开本地视频
|
|
105
|
+
│
|
|
106
|
+
▼
|
|
107
|
+
进入美颜设置面板
|
|
108
|
+
│
|
|
109
|
+
▼
|
|
110
|
+
调用 setFreeBeauty(...) 做本地预览
|
|
111
|
+
│
|
|
112
|
+
├─ 用户继续调节 → 重复预览
|
|
113
|
+
├─ 用户取消 → 回退未保存的本地预览
|
|
114
|
+
└─ 用户确认 → saveBeautySetting()
|
|
115
|
+
│
|
|
116
|
+
▼
|
|
117
|
+
远端看到最终保存后的美颜效果
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 平台特有注意事项
|
|
121
|
+
### 1. `setFreeBeauty()` 主要作用于本地预览
|
|
122
|
+
只有在调用 `saveBeautySetting()` 后,当前选择才会作为最终效果稳定生效;不要把两者当成同一步。
|
|
123
|
+
|
|
124
|
+
### 2. 无摄像头或摄像头关闭时应禁用入口
|
|
125
|
+
美颜直接依赖本地视频流,若摄像头未开启,则继续暴露调节入口会产生无效操作体验。
|
|
126
|
+
|
|
127
|
+
### 3. 低性能设备要预留降级路径
|
|
128
|
+
美颜会增加本地渲染负担,低性能终端可能出现掉帧、发热或风扇噪声上升,业务层应允许快速关闭。
|
|
129
|
+
|
|
130
|
+
## 代码生成约束
|
|
131
|
+
### 编译必要条件
|
|
132
|
+
- **通用条件**:见 [login-auth 平台 slice](login-auth.md)。
|
|
133
|
+
- **额外导入**:至少需要从 `tuikit-atomicx-vue3/room` 导入 `useFreeBeautyState`。
|
|
134
|
+
- **运行前提**:本地摄像头可用,且页面已处于安全上下文。
|
|
135
|
+
|
|
136
|
+
### 生成规则
|
|
137
|
+
#### MUST(生成时必须包含)
|
|
138
|
+
|
|
139
|
+
1. **使用 `useFreeBeautyState` 承接美颜状态与保存动作** — 这样 UI 预览与最终生效状态才一致。
|
|
140
|
+
**Verify**: 检查是否存在 `useFreeBeautyState()`。
|
|
141
|
+
2. **将预览与保存拆成两段链路** — 否则用户每次调节参数都可能直接影响最终效果。
|
|
142
|
+
**Verify**: 检查是否同时存在 `setFreeBeauty(` 与 `saveBeautySetting(`。
|
|
143
|
+
|
|
144
|
+
#### MUST NOT(生成时绝不能出现)
|
|
145
|
+
|
|
146
|
+
1. **不要在无本地视频的前提下强行启用美颜操作** — 会造成空操作或异常体验。
|
|
147
|
+
**Verify**: 检查入口是否与摄像头状态联动。
|
|
148
|
+
2. **不要把滑杆变化直接等价为永久保存** — 会破坏“先预览、再确认”的交互预期。
|
|
149
|
+
**Verify**: 检查参数变化处理是否无条件调用 `saveBeautySetting()`。
|
|
150
|
+
|
|
151
|
+
### 集成检查点
|
|
152
|
+
- 当前 slice 常与 `conference/device-control`、`conference/video-layout` 联动。
|
|
153
|
+
- 通常只需要新增一个设置面板或弹层,不应修改视频渲染底层实现。
|
|
154
|
+
- 若业务还接入了 `conference/virtual-background`,需明确二者在 UI 上的优先级和入口关系。
|
|
155
|
+
|
|
156
|
+
## 验证矩阵
|
|
157
|
+
| 层级 | 检查项 | 验证手段 | 预期结果 |
|
|
158
|
+
|------|--------|----------|---------|
|
|
159
|
+
| 1. 编译级 | 已导入 `useFreeBeautyState` | 检查 `import` 语句 | 美颜 Hook 可解析 |
|
|
160
|
+
| 2. 静态规则级 | 预览与保存动作分离 | 搜索 `setFreeBeauty` 与 `saveBeautySetting` | 两段链路同时存在 |
|
|
161
|
+
| 3. 运行时级 | 参数调整后可看到本地效果变化 | 开启摄像头并调节美颜参数 | 本地预览立即变化 |
|
|
162
|
+
| 4. 业务行为级 | 用户确认后效果稳定生效 | 调整参数并点击保存 | 最终效果符合保存结果 |
|
|
163
|
+
|
|
164
|
+
## 排障指南
|
|
165
|
+
|
|
166
|
+
### 常见问题
|
|
167
|
+
|
|
168
|
+
| 问题 | 表现 | 处理建议 |
|
|
169
|
+
|------|------|----------|
|
|
170
|
+
| 调整后看不到效果 | 面板参数变化了,但本地或远端画面没有明显变化 | 检查本地视频是否已开启,以及是否完成了保存动作 |
|
|
171
|
+
| 预览有效但重新打开面板丢失 | 刚调整好的效果下一次打开又恢复默认 | 检查预览态和已保存参数是否被分开维护并正确持久化 |
|
|
172
|
+
| 与虚拟背景联动异常 | 开启背景替换后美颜表现不稳定或理解混乱 | 检查本地视频特效链路是否明确区分美颜与背景处理责任 |
|
|
173
|
+
|
|
174
|
+
### 排障流程
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
发现 美颜效果 相关问题
|
|
178
|
+
├── 第 1 步:确认问题属于本地视频前处理效果,而不是摄像头开关或背景替换能力
|
|
179
|
+
├── 第 2 步:检查本地视频是否可用,以及当前调整是否仍停留在预览态
|
|
180
|
+
├── 第 3 步:确认预览参数、已保存参数和重置逻辑是否围绕同一份状态管理
|
|
181
|
+
└── 第 4 步:若仍异常,再回查 device-control / video-layout / virtual-background 的衔接是否正确
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 关联知识
|
|
185
|
+
|
|
186
|
+
- **[conference/device-control](device-control.md)** —— 摄像头是否可用决定美颜预览链路是否成立。
|
|
187
|
+
- **[conference/video-layout](video-layout.md)** —— 美颜最终作用在本地画面单元上,会影响用户对布局中的自我画面感知。
|
|
188
|
+
- **[conference/virtual-background](virtual-background.md)** —— 与美颜同属本地视频前处理,但有更强的初始化和兼容性约束。
|