@tencent-rtc/mcp 1.3.4 → 1.3.6
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/index.js +4 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/resource/doc/chatuikit/android/features/theme.md +363 -0
- package/resource/doc/chatuikit/{android/client_api_Android.md → faq/android_sdk/client-api.md} +0 -2
- package/resource/doc/chatuikit/faq/common/product.md +8 -0
- package/resource/doc/chatuikit/faq/flutter_sdk/faq.md +53 -0
- package/resource/doc/chatuikit/{iOS/client_api_iOS.md → faq/ios_sdk/client-api.md} +0 -2
- package/resource/doc/chatuikit/flutter/features/theme.md +379 -0
- package/resource/doc/chatuikit/flutter/integration.md +413 -0
- package/resource/doc/chatuikit/flutter/workflow.md +941 -0
- package/resource/doc/chatuikit/iOS/features/theme.md +416 -0
- package/resource/doc/chatuikit/react/components/chat-setting.md +86 -0
- package/resource/doc/chatuikit/react/components/contact-list.md +1093 -0
- package/resource/doc/chatuikit/react/components/search.md +745 -0
- package/resource/doc/chatuikit/vue/components/chat-setting.md +64 -0
- package/resource/doc/chatuikit/vue/components/contact-list.md +679 -0
- package/resource/doc/chatuikit/vue/components/search.md +1384 -0
- package/resource/doc/livekit/live/android/workflow.md +137 -6
- package/resource/doc/livekit/live/ios/live-audience-list.md +339 -0
- package/resource/doc/livekit/live/ios/live-audio-effect.md +370 -0
- package/resource/doc/livekit/live/ios/live-barrage.md +517 -0
- package/resource/doc/livekit/live/ios/live-base-beauty.md +247 -0
- package/resource/doc/livekit/live/ios/live-co-guest-interaction.md +518 -0
- package/resource/doc/livekit/live/ios/live-gift.md +783 -0
- package/resource/doc/livekit/live/ios/live-host-interaction.md +815 -0
- package/resource/doc/livekit/live/ios/live-integration.md +931 -0
- package/resource/doc/livekit/live/ios/live-live-list.md +485 -0
- package/resource/doc/livekit/live/ios/workflow.md +454 -0
- package/resource/doc/rtcengine/web/plugin/20-advanced-customized-capture-rendering.md +87 -0
- package/resource/doc/rtcengine/web/plugin/21-advanced-auto-play-policy.md +87 -0
- package/resource/doc/rtcengine/web/plugin/22-advanced-audio-mixer.md +175 -0
- package/resource/doc/rtcengine/web/plugin/23-advanced-support-detection.md +221 -0
- package/resource/doc/rtcengine/web/plugin/24-advanced-network-quality.md +140 -0
- package/resource/doc/rtcengine/web/plugin/25-advanced-device-change.md +99 -0
- package/resource/doc/rtcengine/web/plugin/26-advanced-publish-cdn-stream.md +451 -0
- package/resource/doc/rtcengine/web/plugin/27-advanced-small-stream.md +151 -0
- package/resource/doc/rtcengine/web/plugin/28-advanced-beauty.md +322 -0
- package/resource/doc/rtcengine/web/plugin/29-advanced-water-mark.md +149 -0
- package/resource/doc/rtcengine/web/plugin/30-advanced-cross-room-link.md +96 -0
- package/resource/doc/rtcengine/web/plugin/31-advanced-plugins-overview.md +330 -0
- package/resource/doc/rtcengine/web/plugin/34-advanced-proxy.md +248 -0
- package/resource/doc/rtcengine/web/plugin/35-advanced-ai-denoiser.md +81 -0
- package/resource/doc/rtcengine/web/plugin/36-advanced-virtual-background.md +242 -0
- package/resource/doc/rtcengine/web/plugin/37-advanced-voice-changer.md +99 -0
- package/resource/doc/rtcengine/web/plugin/39-advanced-video-decoder.md +33 -0
- package/resource/doc/rtcengine/web/plugin/40-advanced-video-mixer.md +379 -0
- package/resource/doc/rtcengine/web/plugin/41-advanced-small-stream-auto-switcher.md +91 -0
- package/resource/doc/rtcengine/web/plugin/42-advanced-realtime-transcriber.md +315 -0
- package/resource/doc/rtcengine/web/plugin/43-advanced-face-detection.md +180 -0
- package/resource/doc/tuicallkit/android/workflow.md +0 -0
- package/resource/doc/tuicallkit/flutter/workflow.md +331 -0
- package/tools/call/get-native-call-integration.js +27 -11
- package/tools/call/get-native-call-integration.js.map +1 -1
- package/tools/chat/get-native-chat-feature-detail.js +30 -0
- package/tools/chat/get-native-chat-feature-detail.js.map +1 -0
- package/tools/chat/get-native-chat-integration.js +30 -12
- package/tools/chat/get-native-chat-integration.js.map +1 -1
- package/tools/common/get-faq.js +2 -4
- package/tools/common/get-faq.js.map +1 -1
- package/tools/definitions/get_native_call_uikit_integration_def.js +17 -7
- package/tools/definitions/get_native_call_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_native_chat_feature_detail_def.js +32 -0
- package/tools/definitions/get_native_chat_feature_detail_def.js.map +1 -0
- package/tools/definitions/get_native_chat_uikit_integration_def.js +19 -7
- package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/{get_native_live_extra_features_def.js → get_native_live_uikit_extra_features_def.js} +3 -3
- package/tools/definitions/get_native_live_uikit_extra_features_def.js.map +1 -0
- package/tools/definitions/{get_native_live_interaction_def.js → get_native_live_uikit_interaction_def.js} +3 -3
- package/tools/definitions/get_native_live_uikit_interaction_def.js.map +1 -0
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js +49 -10
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js.map +1 -1
- package/tools/index.js +6 -4
- package/tools/index.js.map +1 -1
- package/tools/live/{get_native_live_extra_features.js → get_native_live_uikit_extra_features.js} +4 -4
- package/tools/live/get_native_live_uikit_extra_features.js.map +1 -0
- package/tools/live/{get_native_live_interaction.js → get_native_live_uikit_interaction.js} +4 -4
- package/tools/live/get_native_live_uikit_interaction.js.map +1 -0
- package/tools/rtcengine/get-rtcengine-web-sdk-integration.js.map +1 -1
- package/tools/rtcengine/get-trtc-sdk-faq.js +32 -0
- package/tools/rtcengine/get-trtc-sdk-faq.js.map +1 -0
- package/tools/rtcengine/get-trtc-web-sdk-faq.js +1 -1
- package/tools/rtcengine/get-trtc-web-sdk-integration.js.map +1 -1
- package/tools/rtcengine/get-trtc-web-sdk-plugin.js +45 -0
- package/tools/rtcengine/get-trtc-web-sdk-plugin.js.map +1 -0
- package/utils/handle-component-name.js +0 -16
- package/utils/handle-component-name.js.map +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
- package/resource/doc/chatuikit/android/generate_UserSig.md +0 -306
- package/resource/doc/chatuikit/android/integrarte_only_tuichat_Android.md +0 -290
- package/resource/doc/chatuikit/android/quick_start_Android.md +0 -138
- package/resource/doc/chatuikit/android/show_typing_Android.md +0 -43
- package/resource/doc/chatuikit/flutter/generate_UserSig.md +0 -306
- package/resource/doc/chatuikit/flutter/integrate_tuikit_Flutter.md +0 -133
- package/resource/doc/chatuikit/iOS/generate_UserSig.md +0 -306
- package/resource/doc/chatuikit/iOS/integrate_only_tuichat_iOS.md +0 -748
- package/resource/doc/chatuikit/iOS/quick_start_iOS.md +0 -163
- package/resource/doc/chatuikit/iOS/show_typing_iOS.md +0 -52
- package/resource/doc/tuicallkit/flutter/how_to_run_flutter_callkit_demo.md +0 -101
- package/resource/doc/tuicallkit/iOS/how_to_run_iOS_callkit_demo.md +0 -98
- package/tools/definitions/get_native_live_extra_features_def.js.map +0 -1
- package/tools/definitions/get_native_live_interaction_def.js.map +0 -1
- package/tools/live/get_native_live_extra_features.js.map +0 -1
- package/tools/live/get_native_live_interaction.js.map +0 -1
- /package/resource/doc/chatuikit/android/{integrate_tuikit_Android.md → integration.md} +0 -0
- /package/resource/doc/chatuikit/{faq/native_sdk/faq.md → android/workflow.md} +0 -0
- /package/resource/doc/chatuikit/{flutter/client_api_Flutter.md → faq/flutter_sdk/client-api.md} +0 -0
- /package/resource/doc/chatuikit/iOS/{integrate_tuikit_iOS.md → integration.md} +0 -0
- /package/resource/doc/{tuicallkit/android/.gitkeep → chatuikit/iOS/workflow.md} +0 -0
- /package/resource/doc/chatuikit/react/components/{chatheader.md → chat-header.md} +0 -0
- /package/resource/doc/chatuikit/vue/components/{chatheader.md → chat-header.md} +0 -0
- /package/resource/doc/tuicallkit/android/{how_to_integrated_android_callkit.md → integration.md} +0 -0
- /package/resource/doc/tuicallkit/{android/api_TUICallObserver.md → faq/android_sdk/call-observer-api.md} +0 -0
- /package/resource/doc/tuicallkit/{android/api_TUICallKit.md → faq/android_sdk/callkit-api.md} +0 -0
- /package/resource/doc/tuicallkit/{flutter/api_TUICallDefine.md → faq/flutter_sdk/call-define-api.md} +0 -0
- /package/resource/doc/tuicallkit/{flutter/api_TUICallObserver.md → faq/flutter_sdk/call-observer-api.md} +0 -0
- /package/resource/doc/tuicallkit/{flutter/api_TUICallKit.md → faq/flutter_sdk/callkit-api.md} +0 -0
- /package/resource/doc/tuicallkit/{iOS/api_TUICallObserver.md → faq/ios_sdk/call-observer-api.md} +0 -0
- /package/resource/doc/tuicallkit/{iOS/api_TUICallKit.md → faq/ios_sdk/callkit-api.md} +0 -0
- /package/resource/doc/tuicallkit/flutter/{how_to_integrated_flutter_callkit.md → integration.md} +0 -0
- /package/resource/doc/tuicallkit/iOS/{how_to_integrated_iOS_callkit.md → integration.md} +0 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
This document describes how to use the Realtime Transcriber plugin to enable real-time speech-to-text (ASR) and translation capabilities. This plugin can convert users' speech in a room to text in real-time and supports translation into multiple languages.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- TRTC Web SDK version >= 5.15.0
|
|
8
|
+
|
|
9
|
+
## Implementation
|
|
10
|
+
|
|
11
|
+
### Import and Register Plugin
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import TRTC from 'trtc-sdk-v5';
|
|
15
|
+
import RealtimeTranscriber from 'trtc-sdk-v5/plugins/realtime-transcriber';
|
|
16
|
+
|
|
17
|
+
const trtc = TRTC.create({ plugins: [RealtimeTranscriber] });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Start Plugin
|
|
21
|
+
|
|
22
|
+
Starting the plugin returns a `transcriberRobotId`, which is used to stop the transcription task later.
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
const transcriberRobotId = await trtc.startPlugin('RealtimeTranscriber', {
|
|
26
|
+
sourceLanguage: 'zh',
|
|
27
|
+
translationLanguages: ['en', 'ja'],
|
|
28
|
+
userIdsToTranscribe: 'all',
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Listen for Transcription Messages
|
|
33
|
+
|
|
34
|
+
Listen to the `REALTIME_TRANSCRIBER_MESSAGE` event to receive transcription results.
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE, (event) => {
|
|
38
|
+
console.log(`${event.speakerUserId}: ${event.sourceText}`);
|
|
39
|
+
if (event.translationTexts) {
|
|
40
|
+
Object.entries(event.translationTexts).forEach(([lang, text]) => {
|
|
41
|
+
console.log(` ${lang}: ${text}`);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Listen for State Changes
|
|
48
|
+
|
|
49
|
+
Listen to the `REALTIME_TRANSCRIBER_STATE_CHANGED` event to receive transcription task state changes.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_STATE_CHANGED, (event) => {
|
|
53
|
+
console.log(`Transcription state: ${event.state}, robotId: ${event.transcriberRobotId}`);
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Stop Plugin
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
await trtc.stopPlugin('RealtimeTranscriber', { transcriberRobotId });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage Examples
|
|
64
|
+
|
|
65
|
+
### ASR Scenario: Transcribe Audio to Text
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
// Start transcription task
|
|
69
|
+
const robotId = await trtc.startPlugin('RealtimeTranscriber', {
|
|
70
|
+
sourceLanguage: 'zh'
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Listen for transcription messages
|
|
74
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE, (data) => {
|
|
75
|
+
console.log(data.speakerUserId + ' says: ' + data.sourceText);
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Translation Scenario: Translate Specific User's Speech into Multiple Languages
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
// Start transcription task, transcribe userA's speech and translate to French and English
|
|
83
|
+
const robotId = await trtc.startPlugin('RealtimeTranscriber', {
|
|
84
|
+
sourceLanguage: 'zh',
|
|
85
|
+
translationLanguages: ['fr', 'en'],
|
|
86
|
+
userIdsToTranscribe: 'userA'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Listen for transcription messages
|
|
90
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE, (data) => {
|
|
91
|
+
console.log(`👤 ${data.speakerUserId}:`);
|
|
92
|
+
console.log(` Original: ${data.sourceText}`);
|
|
93
|
+
|
|
94
|
+
if (data.translationTexts) {
|
|
95
|
+
Object.entries(data.translationTexts).forEach(([lang, text]) => {
|
|
96
|
+
console.log(` ${lang.toUpperCase()}: ${text}`);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Transcribe Multiple Specific Users
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
const robotId = await trtc.startPlugin('RealtimeTranscriber', {
|
|
106
|
+
sourceLanguage: 'en',
|
|
107
|
+
translationLanguages: ['zh', 'ja'],
|
|
108
|
+
userIdsToTranscribe: ['userA', 'userB', 'userC']
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## API Reference
|
|
113
|
+
|
|
114
|
+
### trtc.startPlugin('RealtimeTranscriber', options)
|
|
115
|
+
|
|
116
|
+
Starts a real-time transcription task.
|
|
117
|
+
|
|
118
|
+
**options: RealtimeTranscriberStartOptions**
|
|
119
|
+
|
|
120
|
+
| Name | Type | Required | Description |
|
|
121
|
+
|------|------|----------|-------------|
|
|
122
|
+
| sourceLanguage | `string` | Required | Source language code, currently supports only `'zh'` and `'en'` |
|
|
123
|
+
| translationLanguages | `string` \| `string[]` | Optional | Target translation language(s), supports single language or array, e.g., `'en'` or `['en', 'ja']` |
|
|
124
|
+
| userIdsToTranscribe | `string` \| `string[]` | Optional | User ID(s) to transcribe, defaults to `'all'` for all users, can also specify single or multiple user IDs |
|
|
125
|
+
| transcriberRobotId | `string` | Optional | Custom transcriber robot ID, auto-generated if not provided |
|
|
126
|
+
|
|
127
|
+
**Returns: Promise\<string\>**
|
|
128
|
+
|
|
129
|
+
Returns the `transcriberRobotId` for the transcription task, used to stop the task later.
|
|
130
|
+
|
|
131
|
+
**Example:**
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
const robotId = await trtc.startPlugin('RealtimeTranscriber', {
|
|
135
|
+
sourceLanguage: 'zh',
|
|
136
|
+
translationLanguages: ['en', 'ja'],
|
|
137
|
+
userIdsToTranscribe: 'all',
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### trtc.stopPlugin('RealtimeTranscriber', options)
|
|
142
|
+
|
|
143
|
+
Stops a real-time transcription task.
|
|
144
|
+
|
|
145
|
+
**options**
|
|
146
|
+
|
|
147
|
+
| Name | Type | Required | Description |
|
|
148
|
+
|------|------|----------|-------------|
|
|
149
|
+
| transcriberRobotId | `string` | Required | The transcriber robot ID returned when starting |
|
|
150
|
+
|
|
151
|
+
**Example:**
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
await trtc.stopPlugin('RealtimeTranscriber', { transcriberRobotId: robotId });
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Event Reference
|
|
158
|
+
|
|
159
|
+
### TRTC.EVENT.REALTIME_TRANSCRIBER_STATE_CHANGED
|
|
160
|
+
|
|
161
|
+
Transcription task state change event.
|
|
162
|
+
|
|
163
|
+
**RealtimeTranscriberStateEvent**
|
|
164
|
+
|
|
165
|
+
| Name | Type | Description |
|
|
166
|
+
|------|------|-------------|
|
|
167
|
+
| state | `'started'` \| `'stopped'` | Transcription task state |
|
|
168
|
+
| roomId | `string` \| `number` | Room ID |
|
|
169
|
+
| transcriberRobotId | `string` | Transcriber robot ID |
|
|
170
|
+
| sourceLanguage | `string` | Source language (optional) |
|
|
171
|
+
| error | `number` | Error code (optional) |
|
|
172
|
+
| errorMessage | `string` | Error message (optional) |
|
|
173
|
+
|
|
174
|
+
**Example:**
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_STATE_CHANGED, (event) => {
|
|
178
|
+
if (event.state === 'started') {
|
|
179
|
+
console.log('Transcription task started');
|
|
180
|
+
} else if (event.state === 'stopped') {
|
|
181
|
+
console.log('Transcription task stopped');
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE
|
|
187
|
+
|
|
188
|
+
Transcription message event, triggered when new transcription results are available.
|
|
189
|
+
|
|
190
|
+
**RealtimeTranscriberMessageEvent**
|
|
191
|
+
|
|
192
|
+
| Name | Type | Description |
|
|
193
|
+
|------|------|-------------|
|
|
194
|
+
| segmentId | `string` | Speech segment ID, used to identify a continuous speech segment |
|
|
195
|
+
| speakerUserId | `string` | Speaker's user ID |
|
|
196
|
+
| sourceText | `string` | Transcribed source text |
|
|
197
|
+
| translationTexts | `Array<{ language: string, text: string }>` | Translation texts array, e.g., `[{ language: 'en', text: 'hello' }, { language: 'ja', text: 'こんにちは' }]` |
|
|
198
|
+
| timestamp | `number` | Timestamp |
|
|
199
|
+
| isCompleted | `boolean` | Whether the speech segment is completed. `false` indicates intermediate result (real-time update), `true` indicates final result |
|
|
200
|
+
| robotId | `string` | Transcriber robot ID |
|
|
201
|
+
|
|
202
|
+
**Example:**
|
|
203
|
+
|
|
204
|
+
```javascript
|
|
205
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE, (event) => {
|
|
206
|
+
const { speakerUserId, sourceText, translationTexts, isCompleted } = event;
|
|
207
|
+
|
|
208
|
+
// Display real-time transcription result
|
|
209
|
+
console.log(`[${isCompleted ? 'Completed' : 'In Progress'}] ${speakerUserId}: ${sourceText}`);
|
|
210
|
+
|
|
211
|
+
// Display translation results
|
|
212
|
+
if (translationTexts) {
|
|
213
|
+
translationTexts.forEach(({ language, text }) => {
|
|
214
|
+
console.log(` ${language}: ${text}`);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Remove listener
|
|
220
|
+
trtc.off(TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE, handler);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Supported Languages
|
|
224
|
+
|
|
225
|
+
### ASR Source Languages
|
|
226
|
+
|
|
227
|
+
| Language | Code |
|
|
228
|
+
|----------|------|
|
|
229
|
+
| Chinese | `zh` |
|
|
230
|
+
| English | `en` |
|
|
231
|
+
|
|
232
|
+
<!--
|
|
233
|
+
| Traditional Chinese | `zh-tw` |
|
|
234
|
+
| Chinese Dialects | `zh-dialect` |
|
|
235
|
+
| Cantonese | `zh-yue` |
|
|
236
|
+
| Vietnamese | `vi` |
|
|
237
|
+
| Japanese | `ja` |
|
|
238
|
+
| Korean | `ko` |
|
|
239
|
+
| Indonesian | `id` |
|
|
240
|
+
| Thai | `th` |
|
|
241
|
+
| Portuguese | `pt` |
|
|
242
|
+
| Turkish | `tr` |
|
|
243
|
+
| Arabic | `ar` |
|
|
244
|
+
| Spanish | `es` |
|
|
245
|
+
| Hindi | `hi` |
|
|
246
|
+
| French | `fr` |
|
|
247
|
+
| Malay | `ms` |
|
|
248
|
+
| Filipino | `fil` |
|
|
249
|
+
| German | `de` |
|
|
250
|
+
| Italian | `it` |
|
|
251
|
+
| Russian | `ru` |
|
|
252
|
+
| Swedish | `sv` |
|
|
253
|
+
| Danish | `da` |
|
|
254
|
+
| Norwegian | `no` |
|
|
255
|
+
-->
|
|
256
|
+
|
|
257
|
+
### Translation Target Languages
|
|
258
|
+
|
|
259
|
+
| Language | Code |
|
|
260
|
+
|----------|------|
|
|
261
|
+
| Chinese | `zh` |
|
|
262
|
+
| English | `en` |
|
|
263
|
+
| Vietnamese | `vi` |
|
|
264
|
+
| Japanese | `ja` |
|
|
265
|
+
| Korean | `ko` |
|
|
266
|
+
| Indonesian | `id` |
|
|
267
|
+
| Thai | `th` |
|
|
268
|
+
| Portuguese | `pt` |
|
|
269
|
+
| Arabic | `ar` |
|
|
270
|
+
| Spanish | `es` |
|
|
271
|
+
| French | `fr` |
|
|
272
|
+
| Malay | `ms` |
|
|
273
|
+
| German | `de` |
|
|
274
|
+
| Italian | `it` |
|
|
275
|
+
| Russian | `ru` |
|
|
276
|
+
|
|
277
|
+
## FAQ
|
|
278
|
+
|
|
279
|
+
**1. How to distinguish between intermediate and final results?**
|
|
280
|
+
|
|
281
|
+
Use the `isCompleted` field in the `REALTIME_TRANSCRIBER_MESSAGE` event. When `isCompleted` is `false`, it indicates an intermediate result (real-time update); when `isCompleted` is `true`, it indicates the speech segment is completed with the final result.
|
|
282
|
+
|
|
283
|
+
```javascript
|
|
284
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE, (event) => {
|
|
285
|
+
if (event.isCompleted) {
|
|
286
|
+
// Final result, can be stored or displayed
|
|
287
|
+
saveSubtitle(event);
|
|
288
|
+
} else {
|
|
289
|
+
// Intermediate result, can update UI in real-time
|
|
290
|
+
updateLiveCaption(event);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**2. How to merge subtitles by segmentId?**
|
|
296
|
+
|
|
297
|
+
Each continuous speech segment has the same `segmentId`, which can be used to update and merge subtitles:
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
const subtitleMap = new Map();
|
|
301
|
+
|
|
302
|
+
trtc.on(TRTC.EVENT.REALTIME_TRANSCRIBER_MESSAGE, (event) => {
|
|
303
|
+
subtitleMap.set(event.segmentId, event);
|
|
304
|
+
|
|
305
|
+
if (event.isCompleted) {
|
|
306
|
+
// Speech segment completed, can be archived
|
|
307
|
+
archiveSubtitle(subtitleMap.get(event.segmentId));
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**3. How to save bandwidth?**
|
|
313
|
+
|
|
314
|
+
When you don't need to receive transcription messages, remove all listeners for the `REALTIME_TRANSCRIBER_MESSAGE` event, and the plugin will automatically pause receiving messages to save bandwidth. When listeners are added again, message receiving will automatically resume.
|
|
315
|
+
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
## Function Description
|
|
2
|
+
|
|
3
|
+
This document details how to use the TRTC Web SDK's Face Detection plugin to monitor real-time face presence changes in camera video streams. The plugin employs intelligent debounce logic, triggering callbacks only when face appearance/disappearance states genuinely change, preventing false positives caused by lighting variations or brief obstructions.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- TRTC Web SDK version >= 5.15.0
|
|
8
|
+
- Camera video stream must be enabled first.
|
|
9
|
+
|
|
10
|
+
### Platform Compatibility
|
|
11
|
+
|
|
12
|
+
| Platform | Operating System | Browser Version | Notes |
|
|
13
|
+
| :--- | :--- | :--- | :--- |
|
|
14
|
+
| Web | Windows | Chrome 90+, Firefox 90+, Edge 97+ | Recommended: Latest Chrome browser (with hardware acceleration enabled) |
|
|
15
|
+
| Web | Mac | Chrome 98+, Firefox 96+, Safari 15+ | 2019 or newer MacBook recommended |
|
|
16
|
+
| Web | Android | Chrome、Firefox| Use of Chrome or Firefox is recommended |
|
|
17
|
+
| Web | iOS | Chrome、Safari、Firefox | Use of Chrome or Safari is recommended |
|
|
18
|
+
|
|
19
|
+
## Implementation Steps
|
|
20
|
+
|
|
21
|
+
### Deploying Static Resources
|
|
22
|
+
|
|
23
|
+
The plugin relies on static resource files. To ensure the browser can load and run these files correctly, you need to complete the following steps:
|
|
24
|
+
|
|
25
|
+
1. Publish the `node_modules/trtc-sdk-v5/assets` directory to your CDN or static resource server.
|
|
26
|
+
2. Pass your CDN address to the `assetsPath` parameter when creating the TRTC instance, e.g., `TRTC.create({ assetsPath: 'https://xxxx/assets' })`. The SDK will load the necessary resource files on demand.
|
|
27
|
+
|
|
28
|
+
> - If your SDK version is lower than `v5.10.0`, you need to download and extract https://web.sdk.qcloud.com/trtc/webrtc/v5/assets/assets.zip, then publish it to your CDN or static resource server.
|
|
29
|
+
> - If the Host URL of the files differs from your web application's Host URL, you need to enable CORS policy for the file domain.
|
|
30
|
+
> - Do not host the directory files under an HTTP service, as loading HTTP resources under an HTTPS domain will be blocked by the browser's security policy.
|
|
31
|
+
|
|
32
|
+
### Registering the Plugin
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { FaceDetection } from 'trtc-sdk-v5/plugins/video-effect/face-detection';
|
|
36
|
+
|
|
37
|
+
const trtc = TRTC.create({
|
|
38
|
+
plugins: [FaceDetection],
|
|
39
|
+
assetsPath: 'https://xxxx/assets' // Replace with your static resource address
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Starting the Local Camera
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
await trtc.startLocalVideo();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Enabling the Face Detection Plugin
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
await trtc.startPlugin('FaceDetection', {
|
|
53
|
+
onFaceDetectionStateChanged: (hasFace) => {
|
|
54
|
+
if (hasFace) {
|
|
55
|
+
console.log('Face detected');
|
|
56
|
+
// Execute business logic for face appearance
|
|
57
|
+
} else {
|
|
58
|
+
console.log('Face disappeared');
|
|
59
|
+
// Execute business logic for face disappearance
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
detectionInterval: 300, // Detection interval in ms (Optional, default: 300)
|
|
63
|
+
minConfidence: 0.8, // Minimum confidence threshold (Optional, default: 0.8)
|
|
64
|
+
missingTimeout: 1000 // Disappearance confirmation time in ms (Optional, default: 1000)
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Updating Parameters as Needed
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// Update detection parameters - increase sensitivity
|
|
72
|
+
await trtc.updatePlugin('FaceDetection', {
|
|
73
|
+
onFaceDetectionStateChanged: (hasFace) => {
|
|
74
|
+
console.log('Updated detection state:', hasFace);
|
|
75
|
+
},
|
|
76
|
+
detectionInterval: 200, // Shorter interval for higher real-time performance
|
|
77
|
+
minConfidence: 0.7, // Lower threshold for higher sensitivity
|
|
78
|
+
missingTimeout: 1500 // Longer timeout to reduce false negatives
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Disabling Face Detection
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
await trtc.stopPlugin('FaceDetection');
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Core Features
|
|
89
|
+
|
|
90
|
+
### Intelligent Debounce Logic
|
|
91
|
+
|
|
92
|
+
The plugin uses an **asymmetric debounce mechanism** to ensure state change accuracy:
|
|
93
|
+
|
|
94
|
+
- **Face appears (true)**: Triggered immediately for real-time response.
|
|
95
|
+
- **Face disappears (false)**: Triggered after a delay, requiring the `missingTimeout` condition to be met for confirmation.
|
|
96
|
+
|
|
97
|
+
This design effectively prevents false positives caused by:
|
|
98
|
+
- Brief head turns or looking down
|
|
99
|
+
- Sudden lighting changes
|
|
100
|
+
- Temporary obstructions
|
|
101
|
+
|
|
102
|
+
### Video Stream State Synchronization
|
|
103
|
+
|
|
104
|
+
The plugin automatically handles local video stream state changes:
|
|
105
|
+
|
|
106
|
+
| Scenario | Plugin Behavior | Callback Trigger |
|
|
107
|
+
| :--- | :--- | :--- |
|
|
108
|
+
| Video muted (Mute) | Pauses detection | Triggers once with `hasFace: false` |
|
|
109
|
+
| Video resumed (Unmute) | Resumes detection | Triggers callback based on actual state |
|
|
110
|
+
|
|
111
|
+
## API Documentation
|
|
112
|
+
|
|
113
|
+
### trtc.startPlugin('FaceDetection', options)
|
|
114
|
+
|
|
115
|
+
Used to start the Face Detection plugin.
|
|
116
|
+
|
|
117
|
+
#### options
|
|
118
|
+
|
|
119
|
+
| Name | Type | Attributes | Description |
|
|
120
|
+
| :--- | :--- | :--- | :--- |
|
|
121
|
+
| `onFaceDetectionStateChanged` | `(hasFace: boolean) => void` | **Required** | Callback function for face state changes (triggered only on genuine state change) |
|
|
122
|
+
| `detectionInterval` | number | Optional | Detection interval time (ms), range: 100-5000, default: 300 |
|
|
123
|
+
| `minConfidence` | number | Optional | Minimum face confidence threshold, range: 0-1, default: 0.8 |
|
|
124
|
+
| `missingTimeout` | number | Optional | Face disappearance confirmation time (ms), range: 0-5000, default: 1000 |
|
|
125
|
+
|
|
126
|
+
**Example:**
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
await trtc.startPlugin('FaceDetection', {
|
|
130
|
+
onFaceDetectionStateChanged: (hasFace) => {
|
|
131
|
+
if (hasFace) {
|
|
132
|
+
console.log('Face appeared');
|
|
133
|
+
} else {
|
|
134
|
+
console.log('Face disappeared');
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
detectionInterval: 300,
|
|
138
|
+
minConfidence: 0.8,
|
|
139
|
+
missingTimeout: 1000
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### trtc.updatePlugin('FaceDetection', options)
|
|
144
|
+
|
|
145
|
+
Used to modify face detection parameters.
|
|
146
|
+
|
|
147
|
+
#### options
|
|
148
|
+
|
|
149
|
+
| Name | Type | Attributes | Description |
|
|
150
|
+
| :--- | :--- | :--- | :--- |
|
|
151
|
+
| `onFaceDetectionStateChanged` | `(hasFace: boolean) => void` | Optional | Callback function for face state changes |
|
|
152
|
+
| `detectionInterval` | number | Optional | Detection interval time (ms), range: 100-5000 |
|
|
153
|
+
| `minConfidence` | number | Optional | Minimum face confidence threshold, range: 0-1 |
|
|
154
|
+
| `missingTimeout` | number | Optional | Face disappearance confirmation time (ms), range: 0-5000 |
|
|
155
|
+
|
|
156
|
+
**Example:**
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
await trtc.updatePlugin('FaceDetection', {
|
|
160
|
+
detectionInterval: 200,
|
|
161
|
+
minConfidence: 0.7,
|
|
162
|
+
missingTimeout: 1500
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### trtc.stopPlugin('FaceDetection')
|
|
167
|
+
|
|
168
|
+
Stops the Face Detection plugin.
|
|
169
|
+
|
|
170
|
+
## FAQs
|
|
171
|
+
|
|
172
|
+
**1. How to adjust detection sensitivity?**
|
|
173
|
+
|
|
174
|
+
Adjust sensitivity by combining these parameters:
|
|
175
|
+
- **Increase sensitivity**: Lower `minConfidence`, shorten `detectionInterval`
|
|
176
|
+
- **Decrease sensitivity**: Raise `minConfidence`, lengthen `missingTimeout`
|
|
177
|
+
|
|
178
|
+
**2. Do I need to restart detection after the video stream recovers?**
|
|
179
|
+
|
|
180
|
+
No. The plugin automatically handles video stream state changes and resumes detection upon recovery.
|
|
File without changes
|