@crh-fe/oava-customer-sdk 1.0.58 → 1.0.60
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/README.md +1 -1
- package/dist/customerComponent.js +554 -336
- package/dist/customerComponent.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
/*
|
|
3
|
-
* Version: 1.0.
|
|
4
|
-
* Build Time: 2026/
|
|
3
|
+
* Version: 1.0.60
|
|
4
|
+
* Build Time: 2026/12/01 10:02:48
|
|
5
5
|
*/
|
|
6
6
|
var commonjsGlobal = 'undefined' != typeof globalThis ? globalThis : 'undefined' != typeof window ? window : 'undefined' != typeof global ? global : 'undefined' != typeof self ? self : {};
|
|
7
7
|
|
|
@@ -20901,9 +20901,10 @@ class IRtcClient extends EventTarget {
|
|
|
20901
20901
|
}, this.serverReconnectedImplementation = () => {
|
|
20902
20902
|
console.info('widget:irtc server reconnected', (new Date).toISOString());
|
|
20903
20903
|
}, this.messageReceivedImplementation = eve => {
|
|
20904
|
-
if (
|
|
20905
|
-
return
|
|
20904
|
+
if (eve.origin === this.self.id) {
|
|
20905
|
+
return;
|
|
20906
20906
|
}
|
|
20907
|
+
console.info('widget:receive message', eve, (new Date).toISOString());
|
|
20907
20908
|
let customEvent = new CustomEvent(IRTC_CUSTOMEREVENT.MESSAGE, {
|
|
20908
20909
|
detail: {
|
|
20909
20910
|
message: eve.message,
|
|
@@ -22031,6 +22032,355 @@ styleInject(css_248z);
|
|
|
22031
22032
|
|
|
22032
22033
|
var kefu = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQMAAADACAYAAAAA2gZlAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAB5uSURBVHgB7Z3rctzGlcdPDymRFClSFMWLKMoiLZlxJOu2trOu3drE/rC1ldoPyRvYeQPnCWI/Qp4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xiYoMMYjmvffe8z2CwtixY3TwYPXNtR9++KEMJnQtEU8lPThYXRGdP+Q+mIbuRuwntM+Y66xWjmPfTtSIwEe5NnEqnn4tbK5XuZhOY8dB/Y/Fz372s0C3gkJPTw+dPHWK+Nvjgw8+oF/+8pfUjaiRbr3yq6MOvbzlFWS8Af3ZlSOOoS57gUc9b2ifFkKBQH8hmBYK+lGwBUBtTdC30Y8RqLyWder5qi0MchsvrqDHGYQ5BiCHhzmO8fj+uTqwCKJgl4CFgOOEKj0Tk5Mf8dt2Dvb10ZrSE/F3v/udvKAcR+hmTIFBW0VWl21WQVRlD7RemI4nwmJl+wTKop4Dmb8DLQCaOKnb6sfQK6ZfToqwILQWAnWd+q2WSc3vi5hD0ecKQQjBLsGPf/xjWb91/NaE4eHhkIXw0Ucf0dzcXHe7DRVq3Vimp5RowF41Rdb1dfUSaxiz6XgxKpPtvBsNxMZtEUClrw+2BrjVgIOFth7H4tz584G/2u7uLj1YWJDfKrOzs/TTn/6U3n//fbp06RIBAPINCwBXfO5DxC5BrQGJ/w+MiQFWh1rnOgAAAABJRU5ErkJggg==';
|
|
22033
22034
|
|
|
22035
|
+
function asrDebug(event, detail = {}) {
|
|
22036
|
+
console.log(`[ASR DEBUG] ${event}`, _objectSpread2({
|
|
22037
|
+
at: (new Date).toISOString()
|
|
22038
|
+
}, detail));
|
|
22039
|
+
}
|
|
22040
|
+
|
|
22041
|
+
function describeAsrUrl(value) {
|
|
22042
|
+
try {
|
|
22043
|
+
const url = new URL(value), signedAt = url.searchParams.get('date'), signedTime = Date.parse(signedAt);
|
|
22044
|
+
return {
|
|
22045
|
+
endpoint: `${url.origin}${url.pathname}`,
|
|
22046
|
+
queryKeys: [ ...url.searchParams.keys() ],
|
|
22047
|
+
signedHost: url.searchParams.get('host'),
|
|
22048
|
+
signedAt,
|
|
22049
|
+
signatureAgeSeconds: Number.isFinite(signedTime) ? Math.round((Date.now() - signedTime) / 1e3) : null,
|
|
22050
|
+
authorizationLength: (url.searchParams.get('authorization') || '').length
|
|
22051
|
+
};
|
|
22052
|
+
} catch (_) {
|
|
22053
|
+
return {
|
|
22054
|
+
validUrl: !1
|
|
22055
|
+
};
|
|
22056
|
+
}
|
|
22057
|
+
}
|
|
22058
|
+
|
|
22059
|
+
const isJsonString = str => {
|
|
22060
|
+
try {
|
|
22061
|
+
const toObj = JSON.parse(str);
|
|
22062
|
+
if (toObj && 'object' == typeof toObj) {
|
|
22063
|
+
return !0;
|
|
22064
|
+
}
|
|
22065
|
+
} catch (_unused) {
|
|
22066
|
+
return !1;
|
|
22067
|
+
}
|
|
22068
|
+
return !1;
|
|
22069
|
+
};
|
|
22070
|
+
|
|
22071
|
+
class Request {
|
|
22072
|
+
constructor() {}
|
|
22073
|
+
get(url, config) {
|
|
22074
|
+
const configs = config || {
|
|
22075
|
+
headers: {}
|
|
22076
|
+
};
|
|
22077
|
+
return new Promise(((resolve, reject) => {
|
|
22078
|
+
const xhr = new XMLHttpRequest;
|
|
22079
|
+
xhr.onload = response => {
|
|
22080
|
+
resolve({
|
|
22081
|
+
data: JSON.parse(xhr.responseText),
|
|
22082
|
+
status: xhr.status,
|
|
22083
|
+
statusText: xhr.statusText
|
|
22084
|
+
});
|
|
22085
|
+
}, xhr.open('get', url, !0);
|
|
22086
|
+
for (const key in configs.headers) {
|
|
22087
|
+
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22088
|
+
}
|
|
22089
|
+
xhr.onerror = e => {
|
|
22090
|
+
reject(e);
|
|
22091
|
+
}, xhr.ontimeout = e => {
|
|
22092
|
+
reject(e);
|
|
22093
|
+
}, xhr.onabort = e => {}, xhr.send();
|
|
22094
|
+
}));
|
|
22095
|
+
}
|
|
22096
|
+
post(url, data, config, timeout) {
|
|
22097
|
+
const configs = config || {
|
|
22098
|
+
headers: {}
|
|
22099
|
+
};
|
|
22100
|
+
return new Promise(((resolve, reject) => {
|
|
22101
|
+
const xhr = new XMLHttpRequest;
|
|
22102
|
+
xhr.timeout = timeout || 6e4, xhr.onload = response => {
|
|
22103
|
+
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22104
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22105
|
+
status: xhr.status,
|
|
22106
|
+
statusText: xhr.statusText
|
|
22107
|
+
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22108
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22109
|
+
status: xhr.status,
|
|
22110
|
+
statusText: xhr.statusText
|
|
22111
|
+
});
|
|
22112
|
+
}, xhr.onreadystatechange = () => {
|
|
22113
|
+
xhr.readyState;
|
|
22114
|
+
}, xhr.open('post', url, !0);
|
|
22115
|
+
for (const key in configs.headers) {
|
|
22116
|
+
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22117
|
+
}
|
|
22118
|
+
xhr.onerror = e => {
|
|
22119
|
+
reject(e);
|
|
22120
|
+
}, xhr.ontimeout = e => {
|
|
22121
|
+
reject(e);
|
|
22122
|
+
}, xhr.onabort = e => {
|
|
22123
|
+
reject(e);
|
|
22124
|
+
}, xhr.upload.onprogress = function(event) {}, xhr.send(isJsonString(data) ? JSON.stringify(data) : data);
|
|
22125
|
+
}));
|
|
22126
|
+
}
|
|
22127
|
+
delete(url, config) {
|
|
22128
|
+
const configs = config || {
|
|
22129
|
+
headers: {}
|
|
22130
|
+
};
|
|
22131
|
+
return new Promise(((resolve, reject) => {
|
|
22132
|
+
const xhr = new XMLHttpRequest;
|
|
22133
|
+
xhr.onload = response => {
|
|
22134
|
+
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22135
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22136
|
+
status: xhr.status,
|
|
22137
|
+
statusText: xhr.statusText
|
|
22138
|
+
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22139
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22140
|
+
status: xhr.status,
|
|
22141
|
+
statusText: xhr.statusText
|
|
22142
|
+
});
|
|
22143
|
+
}, xhr.open('delete', url, !0), xhr.onreadystatechange = () => {
|
|
22144
|
+
xhr.readyState;
|
|
22145
|
+
};
|
|
22146
|
+
for (const key in configs.headers) {
|
|
22147
|
+
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22148
|
+
}
|
|
22149
|
+
xhr.onerror = e => {
|
|
22150
|
+
reject(e);
|
|
22151
|
+
}, xhr.ontimeout = e => {
|
|
22152
|
+
reject(e);
|
|
22153
|
+
}, xhr.onabort = e => {
|
|
22154
|
+
reject(e);
|
|
22155
|
+
}, xhr.send();
|
|
22156
|
+
}));
|
|
22157
|
+
}
|
|
22158
|
+
patch(url, data, config) {
|
|
22159
|
+
const configs = config || {
|
|
22160
|
+
headers: {}
|
|
22161
|
+
};
|
|
22162
|
+
return new Promise(((resolve, reject) => {
|
|
22163
|
+
const xhr = new XMLHttpRequest;
|
|
22164
|
+
xhr.onload = response => {
|
|
22165
|
+
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22166
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22167
|
+
status: xhr.status,
|
|
22168
|
+
statusText: xhr.statusText
|
|
22169
|
+
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22170
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22171
|
+
status: xhr.status,
|
|
22172
|
+
statusText: xhr.statusText
|
|
22173
|
+
});
|
|
22174
|
+
}, xhr.open('PATCH', url, !0), xhr.onreadystatechange = () => {
|
|
22175
|
+
xhr.readyState;
|
|
22176
|
+
};
|
|
22177
|
+
for (const key in configs.headers) {
|
|
22178
|
+
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22179
|
+
}
|
|
22180
|
+
xhr.onerror = e => {
|
|
22181
|
+
reject(e);
|
|
22182
|
+
}, xhr.ontimeout = e => {
|
|
22183
|
+
reject(e);
|
|
22184
|
+
}, xhr.onabort = e => {
|
|
22185
|
+
reject(e);
|
|
22186
|
+
}, console.log('data', JSON.stringify(data)), xhr.send(JSON.stringify(data));
|
|
22187
|
+
}));
|
|
22188
|
+
}
|
|
22189
|
+
post2(url, data, config, timeout = 5e3) {
|
|
22190
|
+
const configs = config || {
|
|
22191
|
+
headers: {}
|
|
22192
|
+
};
|
|
22193
|
+
return new Promise(((resolve, reject) => {
|
|
22194
|
+
const xhr = new XMLHttpRequest;
|
|
22195
|
+
xhr.onload = response => {
|
|
22196
|
+
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22197
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22198
|
+
status: xhr.status,
|
|
22199
|
+
statusText: xhr.statusText
|
|
22200
|
+
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22201
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22202
|
+
status: xhr.status,
|
|
22203
|
+
statusText: xhr.statusText
|
|
22204
|
+
});
|
|
22205
|
+
}, xhr.open('POST', url, !0), xhr.onreadystatechange = () => {
|
|
22206
|
+
xhr.readyState;
|
|
22207
|
+
};
|
|
22208
|
+
for (const key in configs.headers) {
|
|
22209
|
+
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22210
|
+
}
|
|
22211
|
+
xhr.onerror = e => {
|
|
22212
|
+
reject(e);
|
|
22213
|
+
}, xhr.ontimeout = e => {
|
|
22214
|
+
reject(e);
|
|
22215
|
+
}, xhr.onabort = e => {
|
|
22216
|
+
reject(e);
|
|
22217
|
+
}, xhr.timeout = timeout, xhr.send(JSON.stringify(data));
|
|
22218
|
+
}));
|
|
22219
|
+
}
|
|
22220
|
+
put(url, data, config) {
|
|
22221
|
+
const configs = config || {
|
|
22222
|
+
headers: {}
|
|
22223
|
+
};
|
|
22224
|
+
return new Promise(((resolve, reject) => {
|
|
22225
|
+
const xhr = new XMLHttpRequest;
|
|
22226
|
+
xhr.onload = response => {
|
|
22227
|
+
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22228
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22229
|
+
status: xhr.status,
|
|
22230
|
+
statusText: xhr.statusText
|
|
22231
|
+
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22232
|
+
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22233
|
+
status: xhr.status,
|
|
22234
|
+
statusText: xhr.statusText
|
|
22235
|
+
});
|
|
22236
|
+
}, xhr.open('PUT', url, !0), xhr.onreadystatechange = () => {
|
|
22237
|
+
xhr.readyState;
|
|
22238
|
+
};
|
|
22239
|
+
for (const key in configs.headers) {
|
|
22240
|
+
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22241
|
+
}
|
|
22242
|
+
xhr.onerror = e => {
|
|
22243
|
+
reject(e);
|
|
22244
|
+
}, xhr.ontimeout = e => {
|
|
22245
|
+
reject(e);
|
|
22246
|
+
}, xhr.onabort = e => {
|
|
22247
|
+
reject(e);
|
|
22248
|
+
}, console.log('data', JSON.stringify(data)), xhr.send(JSON.stringify(data));
|
|
22249
|
+
}));
|
|
22250
|
+
}
|
|
22251
|
+
}
|
|
22252
|
+
|
|
22253
|
+
const XFYUN_IAT_BUSINESS = Object.freeze({
|
|
22254
|
+
language: 'zh_cn',
|
|
22255
|
+
domain: 'iat',
|
|
22256
|
+
ltc: 2,
|
|
22257
|
+
ptt: 0,
|
|
22258
|
+
pcm: 0,
|
|
22259
|
+
accent: 'mandarin',
|
|
22260
|
+
vad_eos: 5e3,
|
|
22261
|
+
dwa: 'wpgs'
|
|
22262
|
+
});
|
|
22263
|
+
|
|
22264
|
+
function getRealtimeAsrDuration(seconds) {
|
|
22265
|
+
const value = Number(seconds);
|
|
22266
|
+
return !Number.isFinite(value) || value <= 0 ? 5 : Math.max(1, Math.round(1e3 * Math.min(value, 10))) / 1e3;
|
|
22267
|
+
}
|
|
22268
|
+
|
|
22269
|
+
function getAsrConfig(config, requireLicenseCode = !1) {
|
|
22270
|
+
if (null == config) {
|
|
22271
|
+
return {
|
|
22272
|
+
type: 0
|
|
22273
|
+
};
|
|
22274
|
+
}
|
|
22275
|
+
if ('object' != typeof config || Array.isArray(config)) {
|
|
22276
|
+
throw new Error('asrConfig 必须是配置对象');
|
|
22277
|
+
}
|
|
22278
|
+
if (0 !== config.type && 1 !== config.type) {
|
|
22279
|
+
throw new Error('asrConfig.type 必须为 0(离线)或 1(实时)');
|
|
22280
|
+
}
|
|
22281
|
+
if (1 === config.type && requireLicenseCode) {
|
|
22282
|
+
if ('string' != typeof config.licenseCode || !config.licenseCode.trim()) {
|
|
22283
|
+
throw new Error('asrConfig.licenseCode 不能为空');
|
|
22284
|
+
}
|
|
22285
|
+
return {
|
|
22286
|
+
type: 1,
|
|
22287
|
+
licenseCode: config.licenseCode.trim()
|
|
22288
|
+
};
|
|
22289
|
+
}
|
|
22290
|
+
return {
|
|
22291
|
+
type: config.type
|
|
22292
|
+
};
|
|
22293
|
+
}
|
|
22294
|
+
|
|
22295
|
+
function normalizeRealtimeAsrCredentials(config) {
|
|
22296
|
+
const wsUrl = 'string' == typeof (null == config ? void 0 : config.ws_url) ? config.ws_url.trim() : '', appId = 'string' == typeof (null == config ? void 0 : config.token) ? config.token.trim() : '';
|
|
22297
|
+
let validUrl = !1;
|
|
22298
|
+
try {
|
|
22299
|
+
const url = new URL(wsUrl);
|
|
22300
|
+
validUrl = [ 'wss:', 'ws:' ].includes(url.protocol) && Boolean(url.hostname);
|
|
22301
|
+
} catch (_) {}
|
|
22302
|
+
if (!validUrl) {
|
|
22303
|
+
throw new Error('实时 ASR 接口返回的 ws_url 必须是完整 WebSocket 地址');
|
|
22304
|
+
}
|
|
22305
|
+
if (!appId) {
|
|
22306
|
+
throw new Error('实时 ASR 接口返回的 token 不能为空');
|
|
22307
|
+
}
|
|
22308
|
+
return {
|
|
22309
|
+
wsUrl,
|
|
22310
|
+
appId
|
|
22311
|
+
};
|
|
22312
|
+
}
|
|
22313
|
+
|
|
22314
|
+
function getRealtimeAsrBusiness(_config, seconds) {
|
|
22315
|
+
return _objectSpread2(_objectSpread2({}, XFYUN_IAT_BUSINESS), {}, {
|
|
22316
|
+
vad_eos: 1e3 * getRealtimeAsrDuration(seconds)
|
|
22317
|
+
});
|
|
22318
|
+
}
|
|
22319
|
+
|
|
22320
|
+
function redactRealtimeAsrOptions(options) {
|
|
22321
|
+
return null != options && options.asrConfig ? _objectSpread2(_objectSpread2({}, options), {}, {
|
|
22322
|
+
asrConfig: _objectSpread2(_objectSpread2({}, options.asrConfig), null != options.asrConfig.licenseCode ? {
|
|
22323
|
+
licenseCode: '[redacted]'
|
|
22324
|
+
} : {})
|
|
22325
|
+
}) : options;
|
|
22326
|
+
}
|
|
22327
|
+
|
|
22328
|
+
function queryRealtimeAsrConfig(_x, _x2) {
|
|
22329
|
+
return _queryRealtimeAsrConfig.apply(this, arguments);
|
|
22330
|
+
}
|
|
22331
|
+
|
|
22332
|
+
function _queryRealtimeAsrConfig() {
|
|
22333
|
+
return (_queryRealtimeAsrConfig = _asyncToGenerator((function*(aiServerUrl, asrConfig) {
|
|
22334
|
+
var _response$data$data, _response$data;
|
|
22335
|
+
const config = getAsrConfig(asrConfig, !0);
|
|
22336
|
+
if (0 === config.type) {
|
|
22337
|
+
return null;
|
|
22338
|
+
}
|
|
22339
|
+
if ('string' != typeof aiServerUrl || !aiServerUrl.trim()) {
|
|
22340
|
+
throw new Error('实时 ASR 需要配置 aiServerUrl');
|
|
22341
|
+
}
|
|
22342
|
+
const url = `${aiServerUrl.trim().replace(/\/+$/, '')}/witness/queryRealAsrConfig`;
|
|
22343
|
+
let response;
|
|
22344
|
+
asrDebug('config.request', {
|
|
22345
|
+
url,
|
|
22346
|
+
method: 'POST',
|
|
22347
|
+
hasBody: !1,
|
|
22348
|
+
hasLicenseCode: Boolean(config.licenseCode)
|
|
22349
|
+
});
|
|
22350
|
+
try {
|
|
22351
|
+
response = yield (new Request).post(url, null, {
|
|
22352
|
+
headers: {
|
|
22353
|
+
'license-code': config.licenseCode
|
|
22354
|
+
}
|
|
22355
|
+
}, 5e3);
|
|
22356
|
+
} catch (error) {
|
|
22357
|
+
throw asrDebug('config.request.failed', {
|
|
22358
|
+
status: null == error ? void 0 : error.status,
|
|
22359
|
+
errorType: (null == error ? void 0 : error.name) || (null == error ? void 0 : error.type) || 'request-error'
|
|
22360
|
+
}), error;
|
|
22361
|
+
}
|
|
22362
|
+
const body = null !== (_response$data$data = null === (_response$data = response.data) || void 0 === _response$data ? void 0 : _response$data.data) && void 0 !== _response$data$data ? _response$data$data : response.data;
|
|
22363
|
+
asrDebug('config.response', {
|
|
22364
|
+
status: response.status,
|
|
22365
|
+
responseKeys: Object.keys(response.data || {}),
|
|
22366
|
+
credentialKeys: Object.keys(body || {}),
|
|
22367
|
+
token: null == body ? void 0 : body.token,
|
|
22368
|
+
url: describeAsrUrl(null == body ? void 0 : body.ws_url)
|
|
22369
|
+
});
|
|
22370
|
+
try {
|
|
22371
|
+
const credentials = normalizeRealtimeAsrCredentials(body);
|
|
22372
|
+
return asrDebug('config.ready', {
|
|
22373
|
+
appId: credentials.appId,
|
|
22374
|
+
url: describeAsrUrl(credentials.wsUrl)
|
|
22375
|
+
}), credentials;
|
|
22376
|
+
} catch (error) {
|
|
22377
|
+
throw asrDebug('config.invalid', {
|
|
22378
|
+
message: error.message
|
|
22379
|
+
}), error;
|
|
22380
|
+
}
|
|
22381
|
+
}))).apply(this, arguments);
|
|
22382
|
+
}
|
|
22383
|
+
|
|
22034
22384
|
class Pcm16Encoder {
|
|
22035
22385
|
constructor(inputRate, outputRate = 16e3) {
|
|
22036
22386
|
if (!(inputRate > 0 && outputRate > 0)) {
|
|
@@ -22135,72 +22485,7 @@ class Transcript {
|
|
|
22135
22485
|
}
|
|
22136
22486
|
}
|
|
22137
22487
|
|
|
22138
|
-
const pcmWorkletSource = '\nclass PcmCaptureProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.pending = [];\n this.size = 0;\n this.active = true;\n this.port.onmessage = ({ data }) => {\n if (data === \'stop\') {\n this.active = false;\n this.flush();\n this.port.postMessage({ type: \'stopped\' });\n }\n };\n }\n flush() {\n if (!this.size) return;\n const samples = new Float32Array(this.size);\n let offset = 0;\n for (const chunk of this.pending) { samples.set(chunk, offset); offset += chunk.length; }\n this.pending = [];\n this.size = 0;\n this.port.postMessage({ type: \'samples\', samples }, [samples.buffer]);\n }\n process(inputs) {\n const channels = inputs[0];\n if (this.active && channels && channels.length && channels[0].length) {\n const mono = new Float32Array(channels[0].length);\n for (const channel of channels) {\n for (let i = 0; i < mono.length; i++) mono[i] += channel[i] / channels.length;\n }\n this.pending.push(mono);\n this.size += mono.length;\n if (this.size >= 1024) this.flush();\n }\n return true;\n }\n}\nregisterProcessor(\'sdk-iat-pcm-capture\', PcmCaptureProcessor);\n',
|
|
22139
|
-
language: 'zh_cn',
|
|
22140
|
-
domain: 'iat',
|
|
22141
|
-
ltc: 2,
|
|
22142
|
-
ptt: 0,
|
|
22143
|
-
pcm: 0,
|
|
22144
|
-
accent: 'mandarin',
|
|
22145
|
-
vad_eos: 5e3,
|
|
22146
|
-
dwa: 'wpgs'
|
|
22147
|
-
});
|
|
22148
|
-
|
|
22149
|
-
function getRealtimeAsrDuration(seconds) {
|
|
22150
|
-
const value = Number(seconds);
|
|
22151
|
-
return !Number.isFinite(value) || value <= 0 ? 5 : Math.max(1, Math.round(1e3 * Math.min(value, 10))) / 1e3;
|
|
22152
|
-
}
|
|
22153
|
-
|
|
22154
|
-
function getRealtimeAsrConfig(config) {
|
|
22155
|
-
if (null == config || !1 === config) {
|
|
22156
|
-
return null;
|
|
22157
|
-
}
|
|
22158
|
-
if ('object' != typeof config || Array.isArray(config)) {
|
|
22159
|
-
throw new Error('realtimeAsrConfig 必须是配置对象');
|
|
22160
|
-
}
|
|
22161
|
-
const type = String(config.type || '').toLowerCase();
|
|
22162
|
-
if ('xfyun' !== type) {
|
|
22163
|
-
throw new Error('realtimeAsrConfig.type 目前仅支持 xfyun');
|
|
22164
|
-
}
|
|
22165
|
-
const wsUrl = String(config.ws_url || config.wsUrl || '').trim(), appId = String(config.token || config.appId || '').trim();
|
|
22166
|
-
let validUrl = !1;
|
|
22167
|
-
try {
|
|
22168
|
-
const url = new URL(wsUrl);
|
|
22169
|
-
validUrl = [ 'wss:', 'ws:' ].includes(url.protocol) && Boolean(url.hostname);
|
|
22170
|
-
} catch (_) {}
|
|
22171
|
-
if (!validUrl) {
|
|
22172
|
-
throw new Error('realtimeAsrConfig.ws_url 必须是完整 WebSocket 地址');
|
|
22173
|
-
}
|
|
22174
|
-
if (!appId) {
|
|
22175
|
-
throw new Error('realtimeAsrConfig.token 必须填写讯飞 APPID');
|
|
22176
|
-
}
|
|
22177
|
-
return {
|
|
22178
|
-
type,
|
|
22179
|
-
wsUrl,
|
|
22180
|
-
appId
|
|
22181
|
-
};
|
|
22182
|
-
}
|
|
22183
|
-
|
|
22184
|
-
function getRealtimeAsrBusiness(_config, seconds) {
|
|
22185
|
-
return _objectSpread2(_objectSpread2({}, XFYUN_IAT_BUSINESS), {}, {
|
|
22186
|
-
vad_eos: 1e3 * getRealtimeAsrDuration(seconds)
|
|
22187
|
-
});
|
|
22188
|
-
}
|
|
22189
|
-
|
|
22190
|
-
function redactRealtimeAsrOptions(options) {
|
|
22191
|
-
return null != options && options.realtimeAsrConfig ? _objectSpread2(_objectSpread2({}, options), {}, {
|
|
22192
|
-
realtimeAsrConfig: _objectSpread2(_objectSpread2(_objectSpread2({}, options.realtimeAsrConfig), {}, {
|
|
22193
|
-
ws_url: '[redacted]',
|
|
22194
|
-
token: '[redacted]'
|
|
22195
|
-
}, options.realtimeAsrConfig.wsUrl ? {
|
|
22196
|
-
wsUrl: '[redacted]'
|
|
22197
|
-
} : {}), options.realtimeAsrConfig.appId ? {
|
|
22198
|
-
appId: '[redacted]'
|
|
22199
|
-
} : {})
|
|
22200
|
-
}) : options;
|
|
22201
|
-
}
|
|
22202
|
-
|
|
22203
|
-
const FRAME_BYTES = 1280, MAX_QUEUE_BYTES = 16e4, aborted = () => Object.assign(new Error('已取消语音识别'), {
|
|
22488
|
+
const pcmWorkletSource = '\nclass PcmCaptureProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.pending = [];\n this.size = 0;\n this.active = true;\n this.port.onmessage = ({ data }) => {\n if (data === \'stop\') {\n this.active = false;\n this.flush();\n this.port.postMessage({ type: \'stopped\' });\n }\n };\n }\n flush() {\n if (!this.size) return;\n const samples = new Float32Array(this.size);\n let offset = 0;\n for (const chunk of this.pending) { samples.set(chunk, offset); offset += chunk.length; }\n this.pending = [];\n this.size = 0;\n this.port.postMessage({ type: \'samples\', samples }, [samples.buffer]);\n }\n process(inputs) {\n const channels = inputs[0];\n if (this.active && channels && channels.length && channels[0].length) {\n const mono = new Float32Array(channels[0].length);\n for (const channel of channels) {\n for (let i = 0; i < mono.length; i++) mono[i] += channel[i] / channels.length;\n }\n this.pending.push(mono);\n this.size += mono.length;\n if (this.size >= 1024) this.flush();\n }\n return true;\n }\n}\nregisterProcessor(\'sdk-iat-pcm-capture\', PcmCaptureProcessor);\n', FRAME_BYTES = 1280, MAX_QUEUE_BYTES = 16e4, aborted = () => Object.assign(new Error('已取消语音识别'), {
|
|
22204
22489
|
name: 'AbortError'
|
|
22205
22490
|
});
|
|
22206
22491
|
|
|
@@ -22246,7 +22531,9 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22246
22531
|
}), this.dispatchEvent(event);
|
|
22247
22532
|
}
|
|
22248
22533
|
_state(state) {
|
|
22249
|
-
this.state = state,
|
|
22534
|
+
this.state = state, asrDebug('client.state', {
|
|
22535
|
+
state
|
|
22536
|
+
}), this._emit('statechange', {
|
|
22250
22537
|
state
|
|
22251
22538
|
});
|
|
22252
22539
|
}
|
|
@@ -22321,9 +22608,20 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22321
22608
|
}
|
|
22322
22609
|
return session.onTrackEnded = () => _this._fail(session, new Error('麦克风音轨已断开')),
|
|
22323
22610
|
tracks.forEach((track => track.addEventListener('ended', session.onTrackEnded))),
|
|
22324
|
-
|
|
22325
|
-
|
|
22326
|
-
|
|
22611
|
+
asrDebug('audio.ready', {
|
|
22612
|
+
contextState: session.context.state,
|
|
22613
|
+
sampleRate: session.context.sampleRate,
|
|
22614
|
+
trackCount: tracks.length,
|
|
22615
|
+
tracks: tracks.map((track => ({
|
|
22616
|
+
readyState: track.readyState,
|
|
22617
|
+
enabled: track.enabled,
|
|
22618
|
+
muted: track.muted
|
|
22619
|
+
})))
|
|
22620
|
+
}), session.encoder = new Pcm16Encoder(session.context.sampleRate), yield _this._prepareCapture(session),
|
|
22621
|
+
_this._check(session), asrDebug('audio.capture.prepared', {
|
|
22622
|
+
processor: session.worklet ? 'AudioWorklet' : 'ScriptProcessor'
|
|
22623
|
+
}), yield _this._connect(session, url.href, _this.appId.trim()), _this._check(session),
|
|
22624
|
+
session.capturing = !0, session.source = session.context.createMediaStreamSource(session.stream),
|
|
22327
22625
|
session.silentGain = session.context.createGain(), session.silentGain.gain.value = 0,
|
|
22328
22626
|
session.source.connect(session.processor), session.processor.connect(session.silentGain),
|
|
22329
22627
|
session.silentGain.connect(session.context.destination), session.context.onstatechange = () => {
|
|
@@ -22396,6 +22694,11 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22396
22694
|
const error = new Error('ASR WebSocket 连接超时');
|
|
22397
22695
|
settle(error), this._fail(session, error);
|
|
22398
22696
|
}), 1e4);
|
|
22697
|
+
let opened = !1;
|
|
22698
|
+
asrDebug('ws.connect', {
|
|
22699
|
+
appId,
|
|
22700
|
+
url: describeAsrUrl(url)
|
|
22701
|
+
});
|
|
22399
22702
|
try {
|
|
22400
22703
|
socket = new globalThis.WebSocket(url);
|
|
22401
22704
|
} catch (_unused2) {
|
|
@@ -22403,8 +22706,12 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22403
22706
|
}
|
|
22404
22707
|
session.socket = socket, socket.onopen = () => {
|
|
22405
22708
|
if (session.active) {
|
|
22709
|
+
opened = !0, asrDebug('ws.open', {
|
|
22710
|
+
readyState: socket.readyState,
|
|
22711
|
+
protocol: socket.protocol
|
|
22712
|
+
});
|
|
22406
22713
|
try {
|
|
22407
|
-
|
|
22714
|
+
const firstFrame = {
|
|
22408
22715
|
common: {
|
|
22409
22716
|
app_id: appId
|
|
22410
22717
|
},
|
|
@@ -22415,7 +22722,13 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22415
22722
|
encoding: 'raw',
|
|
22416
22723
|
audio: ''
|
|
22417
22724
|
}
|
|
22418
|
-
}
|
|
22725
|
+
};
|
|
22726
|
+
asrDebug('ws.first-frame.sending', {
|
|
22727
|
+
frame: firstFrame
|
|
22728
|
+
}), socket.send(JSON.stringify(firstFrame)), asrDebug('ws.first-frame.sent', {
|
|
22729
|
+
appId,
|
|
22730
|
+
readyState: socket.readyState
|
|
22731
|
+
}), settle();
|
|
22419
22732
|
} catch (_unused3) {
|
|
22420
22733
|
settle(new Error('ASR 参数帧发送失败'));
|
|
22421
22734
|
}
|
|
@@ -22425,7 +22738,9 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22425
22738
|
try {
|
|
22426
22739
|
var _message$data, _message$data2;
|
|
22427
22740
|
const message = JSON.parse(event.data);
|
|
22428
|
-
if (
|
|
22741
|
+
if (asrDebug('ws.message', {
|
|
22742
|
+
message
|
|
22743
|
+
}), message.sid && (session.sid = message.sid), null != message.code && '0' !== String(message.code)) {
|
|
22429
22744
|
const error = Object.assign(new Error(message.message || message.desc || 'ASR 服务返回错误'), {
|
|
22430
22745
|
code: message.code,
|
|
22431
22746
|
sid: message.sid
|
|
@@ -22441,12 +22756,32 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22441
22756
|
}
|
|
22442
22757
|
}
|
|
22443
22758
|
}, socket.onerror = () => {
|
|
22444
|
-
|
|
22759
|
+
let message = opened ? 'ASR WebSocket 传输异常,连接已建立后发生网络错误' : 'ASR WebSocket 握手失败,浏览器未提供 HTTP 状态;请查看 Network/WS 握手响应,检查签名、网络和服务授权';
|
|
22760
|
+
if (!opened) {
|
|
22761
|
+
const signedAt = Date.parse(new URL(url).searchParams.get('date'));
|
|
22762
|
+
if (Number.isFinite(signedAt)) {
|
|
22763
|
+
message += `;签名时间与本机时间相差 ${Math.round(Math.abs(Date.now() - signedAt) / 1e3)} 秒,请核对服务端时间及签名有效期`;
|
|
22764
|
+
}
|
|
22765
|
+
}
|
|
22766
|
+
asrDebug('ws.error', {
|
|
22767
|
+
opened,
|
|
22768
|
+
readyState: socket.readyState,
|
|
22769
|
+
message,
|
|
22770
|
+
url: describeAsrUrl(url)
|
|
22771
|
+
});
|
|
22772
|
+
const error = new Error(message);
|
|
22445
22773
|
settle(error), this._fail(session, error);
|
|
22446
22774
|
}, socket.onclose = event => {
|
|
22447
22775
|
if (!session.active) {
|
|
22448
22776
|
return;
|
|
22449
22777
|
}
|
|
22778
|
+
asrDebug('ws.close', {
|
|
22779
|
+
code: event.code,
|
|
22780
|
+
wasClean: event.wasClean,
|
|
22781
|
+
opened,
|
|
22782
|
+
sentFrames: session.sentFrames,
|
|
22783
|
+
sentBytes: session.sentBytes
|
|
22784
|
+
});
|
|
22450
22785
|
const error = new Error(`ASR WebSocket 已断开,未收到最终结果(${event.code})`);
|
|
22451
22786
|
settle(error), this._finish(session, 'closed', error);
|
|
22452
22787
|
};
|
|
@@ -22474,7 +22809,10 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22474
22809
|
encoding: 'raw',
|
|
22475
22810
|
audio: toBase64(bytes)
|
|
22476
22811
|
}
|
|
22477
|
-
})), session.sentFrames++, session.sentBytes += bytes.length
|
|
22812
|
+
})), session.sentFrames++, session.sentBytes += bytes.length, 1 === session.sentFrames && asrDebug('audio.first-frame.sent', {
|
|
22813
|
+
status: 1,
|
|
22814
|
+
bytes: bytes.length
|
|
22815
|
+
});
|
|
22478
22816
|
} else {
|
|
22479
22817
|
session.draining && (socket.send(JSON.stringify({
|
|
22480
22818
|
data: {
|
|
@@ -22483,7 +22821,11 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22483
22821
|
encoding: 'raw',
|
|
22484
22822
|
audio: ''
|
|
22485
22823
|
}
|
|
22486
|
-
})),
|
|
22824
|
+
})), asrDebug('audio.end-frame.sent', {
|
|
22825
|
+
status: 2,
|
|
22826
|
+
sentFrames: session.sentFrames,
|
|
22827
|
+
sentBytes: session.sentBytes
|
|
22828
|
+
}), session.endSent = !0, clearInterval(session.sendTimer), session.finalTimer = setTimeout((() => this._fail(session, new Error('等待 ASR 最终结果超时'))), 1e4));
|
|
22487
22829
|
}
|
|
22488
22830
|
} catch (_unused5) {
|
|
22489
22831
|
this._fail(session, new Error('ASR 音频发送失败'));
|
|
@@ -22568,7 +22910,12 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22568
22910
|
sid: error.sid || session.sid
|
|
22569
22911
|
};
|
|
22570
22912
|
}
|
|
22571
|
-
return
|
|
22913
|
+
return asrDebug('client.end', {
|
|
22914
|
+
reason,
|
|
22915
|
+
error: detail.error,
|
|
22916
|
+
sentFrames: session.sentFrames,
|
|
22917
|
+
sentBytes: session.sentBytes
|
|
22918
|
+
}), session.endDetail = detail, this._lastEnd = detail, this._state(error ? 'error' : 'idle'),
|
|
22572
22919
|
detail.error && this._emit('error', detail.error), this._emit('end', detail), null === (_session$resolveStop = session.resolveStop) || void 0 === _session$resolveStop || _session$resolveStop.call(session, detail),
|
|
22573
22920
|
detail;
|
|
22574
22921
|
}
|
|
@@ -22580,200 +22927,6 @@ class RealtimeAsrClient extends EventTargetBase {
|
|
|
22580
22927
|
}
|
|
22581
22928
|
}
|
|
22582
22929
|
|
|
22583
|
-
const isJsonString = str => {
|
|
22584
|
-
try {
|
|
22585
|
-
const toObj = JSON.parse(str);
|
|
22586
|
-
if (toObj && 'object' == typeof toObj) {
|
|
22587
|
-
return !0;
|
|
22588
|
-
}
|
|
22589
|
-
} catch (_unused) {
|
|
22590
|
-
return !1;
|
|
22591
|
-
}
|
|
22592
|
-
return !1;
|
|
22593
|
-
};
|
|
22594
|
-
|
|
22595
|
-
class Request {
|
|
22596
|
-
constructor() {}
|
|
22597
|
-
get(url, config) {
|
|
22598
|
-
const configs = config || {
|
|
22599
|
-
headers: {}
|
|
22600
|
-
};
|
|
22601
|
-
return new Promise(((resolve, reject) => {
|
|
22602
|
-
const xhr = new XMLHttpRequest;
|
|
22603
|
-
xhr.onload = response => {
|
|
22604
|
-
resolve({
|
|
22605
|
-
data: JSON.parse(xhr.responseText),
|
|
22606
|
-
status: xhr.status,
|
|
22607
|
-
statusText: xhr.statusText
|
|
22608
|
-
});
|
|
22609
|
-
}, xhr.open('get', url, !0);
|
|
22610
|
-
for (const key in configs.headers) {
|
|
22611
|
-
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22612
|
-
}
|
|
22613
|
-
xhr.onerror = e => {
|
|
22614
|
-
reject(e);
|
|
22615
|
-
}, xhr.ontimeout = e => {
|
|
22616
|
-
reject(e);
|
|
22617
|
-
}, xhr.onabort = e => {}, xhr.send();
|
|
22618
|
-
}));
|
|
22619
|
-
}
|
|
22620
|
-
post(url, data, config, timeout) {
|
|
22621
|
-
const configs = config || {
|
|
22622
|
-
headers: {}
|
|
22623
|
-
};
|
|
22624
|
-
return new Promise(((resolve, reject) => {
|
|
22625
|
-
const xhr = new XMLHttpRequest;
|
|
22626
|
-
xhr.timeout = timeout || 6e4, xhr.onload = response => {
|
|
22627
|
-
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22628
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22629
|
-
status: xhr.status,
|
|
22630
|
-
statusText: xhr.statusText
|
|
22631
|
-
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22632
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22633
|
-
status: xhr.status,
|
|
22634
|
-
statusText: xhr.statusText
|
|
22635
|
-
});
|
|
22636
|
-
}, xhr.onreadystatechange = () => {
|
|
22637
|
-
xhr.readyState;
|
|
22638
|
-
}, xhr.open('post', url, !0);
|
|
22639
|
-
for (const key in configs.headers) {
|
|
22640
|
-
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22641
|
-
}
|
|
22642
|
-
xhr.onerror = e => {
|
|
22643
|
-
reject(e);
|
|
22644
|
-
}, xhr.ontimeout = e => {
|
|
22645
|
-
reject(e);
|
|
22646
|
-
}, xhr.onabort = e => {
|
|
22647
|
-
reject(e);
|
|
22648
|
-
}, xhr.upload.onprogress = function(event) {}, xhr.send(isJsonString(data) ? JSON.stringify(data) : data);
|
|
22649
|
-
}));
|
|
22650
|
-
}
|
|
22651
|
-
delete(url, config) {
|
|
22652
|
-
const configs = config || {
|
|
22653
|
-
headers: {}
|
|
22654
|
-
};
|
|
22655
|
-
return new Promise(((resolve, reject) => {
|
|
22656
|
-
const xhr = new XMLHttpRequest;
|
|
22657
|
-
xhr.onload = response => {
|
|
22658
|
-
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22659
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22660
|
-
status: xhr.status,
|
|
22661
|
-
statusText: xhr.statusText
|
|
22662
|
-
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22663
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22664
|
-
status: xhr.status,
|
|
22665
|
-
statusText: xhr.statusText
|
|
22666
|
-
});
|
|
22667
|
-
}, xhr.open('delete', url, !0), xhr.onreadystatechange = () => {
|
|
22668
|
-
xhr.readyState;
|
|
22669
|
-
};
|
|
22670
|
-
for (const key in configs.headers) {
|
|
22671
|
-
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22672
|
-
}
|
|
22673
|
-
xhr.onerror = e => {
|
|
22674
|
-
reject(e);
|
|
22675
|
-
}, xhr.ontimeout = e => {
|
|
22676
|
-
reject(e);
|
|
22677
|
-
}, xhr.onabort = e => {
|
|
22678
|
-
reject(e);
|
|
22679
|
-
}, xhr.send();
|
|
22680
|
-
}));
|
|
22681
|
-
}
|
|
22682
|
-
patch(url, data, config) {
|
|
22683
|
-
const configs = config || {
|
|
22684
|
-
headers: {}
|
|
22685
|
-
};
|
|
22686
|
-
return new Promise(((resolve, reject) => {
|
|
22687
|
-
const xhr = new XMLHttpRequest;
|
|
22688
|
-
xhr.onload = response => {
|
|
22689
|
-
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22690
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22691
|
-
status: xhr.status,
|
|
22692
|
-
statusText: xhr.statusText
|
|
22693
|
-
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22694
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22695
|
-
status: xhr.status,
|
|
22696
|
-
statusText: xhr.statusText
|
|
22697
|
-
});
|
|
22698
|
-
}, xhr.open('PATCH', url, !0), xhr.onreadystatechange = () => {
|
|
22699
|
-
xhr.readyState;
|
|
22700
|
-
};
|
|
22701
|
-
for (const key in configs.headers) {
|
|
22702
|
-
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22703
|
-
}
|
|
22704
|
-
xhr.onerror = e => {
|
|
22705
|
-
reject(e);
|
|
22706
|
-
}, xhr.ontimeout = e => {
|
|
22707
|
-
reject(e);
|
|
22708
|
-
}, xhr.onabort = e => {
|
|
22709
|
-
reject(e);
|
|
22710
|
-
}, console.log('data', JSON.stringify(data)), xhr.send(JSON.stringify(data));
|
|
22711
|
-
}));
|
|
22712
|
-
}
|
|
22713
|
-
post2(url, data, config, timeout = 5e3) {
|
|
22714
|
-
const configs = config || {
|
|
22715
|
-
headers: {}
|
|
22716
|
-
};
|
|
22717
|
-
return console.log('configs', configs), new Promise(((resolve, reject) => {
|
|
22718
|
-
const xhr = new XMLHttpRequest;
|
|
22719
|
-
xhr.onload = response => {
|
|
22720
|
-
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22721
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22722
|
-
status: xhr.status,
|
|
22723
|
-
statusText: xhr.statusText
|
|
22724
|
-
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22725
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22726
|
-
status: xhr.status,
|
|
22727
|
-
statusText: xhr.statusText
|
|
22728
|
-
});
|
|
22729
|
-
}, xhr.open('POST', url, !0), xhr.onreadystatechange = () => {
|
|
22730
|
-
xhr.readyState;
|
|
22731
|
-
};
|
|
22732
|
-
for (const key in configs.headers) {
|
|
22733
|
-
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22734
|
-
}
|
|
22735
|
-
xhr.onerror = e => {
|
|
22736
|
-
reject(e);
|
|
22737
|
-
}, xhr.ontimeout = e => {
|
|
22738
|
-
reject(e);
|
|
22739
|
-
}, xhr.onabort = e => {
|
|
22740
|
-
reject(e);
|
|
22741
|
-
}, xhr.timeout = timeout, xhr.send(JSON.stringify(data));
|
|
22742
|
-
}));
|
|
22743
|
-
}
|
|
22744
|
-
put(url, data, config) {
|
|
22745
|
-
const configs = config || {
|
|
22746
|
-
headers: {}
|
|
22747
|
-
};
|
|
22748
|
-
return new Promise(((resolve, reject) => {
|
|
22749
|
-
const xhr = new XMLHttpRequest;
|
|
22750
|
-
xhr.onload = response => {
|
|
22751
|
-
4 == xhr.readyState && '200' == xhr.status ? resolve({
|
|
22752
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22753
|
-
status: xhr.status,
|
|
22754
|
-
statusText: xhr.statusText
|
|
22755
|
-
}) : 4 == xhr.readyState && '200' !== xhr.status && reject({
|
|
22756
|
-
data: isJsonString(xhr.responseText) ? JSON.parse(xhr.responseText) : xhr.responseText,
|
|
22757
|
-
status: xhr.status,
|
|
22758
|
-
statusText: xhr.statusText
|
|
22759
|
-
});
|
|
22760
|
-
}, xhr.open('PUT', url, !0), xhr.onreadystatechange = () => {
|
|
22761
|
-
xhr.readyState;
|
|
22762
|
-
};
|
|
22763
|
-
for (const key in configs.headers) {
|
|
22764
|
-
xhr.setRequestHeader(key, configs.headers[key]);
|
|
22765
|
-
}
|
|
22766
|
-
xhr.onerror = e => {
|
|
22767
|
-
reject(e);
|
|
22768
|
-
}, xhr.ontimeout = e => {
|
|
22769
|
-
reject(e);
|
|
22770
|
-
}, xhr.onabort = e => {
|
|
22771
|
-
reject(e);
|
|
22772
|
-
}, console.log('data', JSON.stringify(data)), xhr.send(JSON.stringify(data));
|
|
22773
|
-
}));
|
|
22774
|
-
}
|
|
22775
|
-
}
|
|
22776
|
-
|
|
22777
22930
|
const faceCheckRequest = (url, faceBase64, userFaceBase64) => new Promise(function() {
|
|
22778
22931
|
var _ref = _asyncToGenerator((function*(resolve, reject) {
|
|
22779
22932
|
let r = new Request;
|
|
@@ -22830,7 +22983,7 @@ const faceCheckRequest = (url, faceBase64, userFaceBase64) => new Promise(functi
|
|
|
22830
22983
|
};
|
|
22831
22984
|
}());
|
|
22832
22985
|
|
|
22833
|
-
var name = '@crh-fe/oava-customer-sdk', version = '1.0.
|
|
22986
|
+
var name = '@crh-fe/oava-customer-sdk', version = '1.0.60', description = 'Customer JS SDK package for oava-widget', type = 'module', main = './dist/customerComponent.js', files = [ 'dist', 'README.md' ], publishConfig = {
|
|
22834
22987
|
access: 'public'
|
|
22835
22988
|
}, pkg = {
|
|
22836
22989
|
name,
|
|
@@ -53217,10 +53370,10 @@ CpeProductsCicSDK_umd.exports, function(module, exports) {
|
|
|
53217
53370
|
|
|
53218
53371
|
var CpeProductsCicSDK_umdExports = CpeProductsCicSDK_umd.exports, CpeProductsCicSDK = getDefaultExportFromCjs(CpeProductsCicSDK_umdExports);
|
|
53219
53372
|
|
|
53220
|
-
const FACE_CHECK_TRANSFER_REASON = 'face-check-transfer', CUSTOMER_FACE_CHECK_TRANSFER_CODE = '402', SUBTITLE_REVIEW = '正在审核您的开户资料,请稍等…', ASR_MATCH_STABLE_MS = 1e3, ASR_MATCH_SILENCE_MS = 800, ASR_SPEECH_LEVEL = .015;
|
|
53373
|
+
const FACE_CHECK_TRANSFER_REASON = 'face-check-transfer', CUSTOMER_FACE_CHECK_TRANSFER_CODE = '402', SUBTITLE_REVIEW = '正在审核您的开户资料,请稍等…', ASR_MATCH_STABLE_MS = 1e3, ASR_MATCH_SILENCE_MS = 800, ASR_SPEECH_LEVEL = .015, SILENT_SUBTITLE_WORDS = new Set([ '静默视频', '静默话术', '静默', '静默音频' ]), isSilentSubtitle = text => 'string' == typeof text && SILENT_SUBTITLE_WORDS.has(text.trim());
|
|
53221
53374
|
|
|
53222
53375
|
function IndexWidget({customer, options}) {
|
|
53223
|
-
const {roomToken, aiServerUrl, faceCheckTimer, userFaceBase64, maxWaitTime = 180, authorization, apiUrl, logServiceUrl, request_no, isBrowserEnv = !0, showBackButton = !1, recordAnswerOnly = !1,
|
|
53376
|
+
const {roomToken, aiServerUrl, faceCheckTimer, userFaceBase64, maxWaitTime = 180, authorization, apiUrl, logServiceUrl, request_no, isBrowserEnv = !0, showBackButton = !1, recordAnswerOnly = !1, asrConfig} = options, realtimeAsrCredentialsRef = reactExports.useRef(null), realtimeAsrConfigRecordIdRef = reactExports.useRef(null), [asrWaitTimes, setAsrWaitTimes] = reactExports.useState(5), [subtitle, setSubtitle] = reactExports.useState(''), [textMessage, setTextMessage] = reactExports.useState(''), reviewTextMessageRef = reactExports.useRef(''), [playingList, setPlayingList] = reactExports.useState([]), [readyCount, setReadyCount] = reactExports.useState(0), [asrText, setAsrText] = reactExports.useState(''), asrResultTimerRef = reactExports.useRef(null), asrCountdownTimerRef = reactExports.useRef(null), realtimeAsrRoundRef = reactExports.useRef(null), seenRealtimeAsrRoundsRef = reactExports.useRef(new Set), isAwaitingAnswerRef = reactExports.useRef(!1), isAnsweringRef = reactExports.useRef(!1), isCustomerAudioMutedRef = reactExports.useRef(!1), audioOperationRef = reactExports.useRef(Promise.resolve()), isUnmountedRef = reactExports.useRef(!1), sessionEndingRef = reactExports.useRef(!1), answerFailureShownRef = reactExports.useRef(!1), recordFailureTimerRef = reactExports.useRef(null), [recordFailureType, setRecordFailureType] = reactExports.useState('face'), [noFaceCount, setNoFaceCount] = reactExports.useState(0), [isNoFace, setIsNoFace] = reactExports.useState(!1), [hasCompareResultFailed, setHasCompareResultFailed] = reactExports.useState(!1), [playingIndexs, setPlayingIndexs] = reactExports.useState([]), playingIndexsRef = reactExports.useRef(playingIndexs), [aiAgentStreamId, setAiAgentStreamId] = reactExports.useState(''), [customerStreamId, setCustomerStreamId] = reactExports.useState(''), [customerImage, setCustomerImage] = reactExports.useState(''), [isSend, setIsSend] = reactExports.useState(!1), [isSubscribeAgent, setIsSubscribeAgent] = reactExports.useState(!1), [showAgentInfo, setShowAgentInfo] = reactExports.useState(!1), [agentInfo, setAgentInfo] = reactExports.useState(''), aiAgentStreamIdRef = reactExports.useRef(aiAgentStreamId), silentAgentStreamIdRef = reactExports.useRef(null), playingListRef = reactExports.useRef(playingList), asrWaitTimesRef = reactExports.useRef(asrWaitTimes), customerImageRef = reactExports.useRef(customerImage), joinRoomTimes = reactExports.useRef(0), publishStreamTimes = reactExports.useRef(0), createStreamTimes = reactExports.useRef(0), subscribeStreamTimes = reactExports.useRef(0), [isReady, setIsReady] = reactExports.useState(!1), [isTransferring, setIsTransferring] = reactExports.useState(!1), [h5ExtraData, setH5ExtraData] = reactExports.useState(''), [isRecording, setIsRecording] = reactExports.useState(!1), [recordId, setRecordId] = reactExports.useState(''), recordIdRef = reactExports.useRef(recordId), isRecordingRef = reactExports.useRef(isRecording), recordFaceCheckFailCountRef = reactExports.useRef(0), recordFaceCheckFailReportedRef = reactExports.useRef(!1), recordFaceCheckFailThresholdRef = reactExports.useRef(0), [isCustomerVideoReady, setIsCustomerVideoReady] = reactExports.useState(!1), [showExitDialog, setShowExitDialog] = reactExports.useState(!1), [showPlayTip, setShowPlayTip] = reactExports.useState(!1), [playTipTarget, setPlayTipTarget] = reactExports.useState(''), [showAudioCallToast, setShowAudioCallToast] = reactExports.useState(!1), [isSilentAgentAudioMode, setIsSilentAgentAudioMode] = reactExports.useState(!1), isSilentAgentAudioModeRef = reactExports.useRef(isSilentAgentAudioMode), [showWaitView, setShowWaitView] = reactExports.useState(!1), [isHumanSilentAgent, setIsHumanSilentAgent] = reactExports.useState(!1);
|
|
53224
53377
|
reactExports.useRef(isHumanSilentAgent);
|
|
53225
53378
|
const [frameRateThreshold, setFrameRateThreshold] = reactExports.useState(null), [maxFrameRateCheckCount, setMaxFrameRateCheckCount] = reactExports.useState(3), maxFrameRateCheckCountRef = reactExports.useRef(maxFrameRateCheckCount), frameRateThresholdRef = reactExports.useRef(frameRateThreshold), [frameRateCheckCount, setFrameRateCheckCount] = reactExports.useState(0), frameRateCheckCountRef = reactExports.useRef(frameRateCheckCount), [showErrorToast, setShowErrorToast] = reactExports.useState(!1), [showRecordFaceCheckFailToast, setShowRecordFaceCheckFailToast] = reactExports.useState(!1), isCallConnected = Boolean(aiAgentStreamId && isReady), frameRateAlertReportedRef = reactExports.useRef(!1), reportLog = createBusinessTraceReporter({
|
|
53226
53379
|
logServiceUrl,
|
|
@@ -53255,15 +53408,30 @@ function IndexWidget({customer, options}) {
|
|
|
53255
53408
|
message: String((null == error ? void 0 : error.message) || error || '实时语音识别失败').replace(/wss?:\/\/[^\s"'<>]+/gi, '[WebSocket 地址已隐藏]').slice(0, 500)
|
|
53256
53409
|
}, null != (null == error ? void 0 : error.code) ? {
|
|
53257
53410
|
code: error.code
|
|
53258
|
-
} : {}), isCurrentRealtimeRound = round => !isUnmountedRef.current && round.active && realtimeAsrRoundRef.current === round, cancelRealtimeAsr = () => {
|
|
53259
|
-
var _round$client;
|
|
53411
|
+
} : {}), isCurrentRealtimeRound = round => !isUnmountedRef.current && round.active && realtimeAsrRoundRef.current === round, cancelRealtimeAsr = (reason = 'cancelled') => {
|
|
53412
|
+
var _round$client, _round$text, _round$client2;
|
|
53260
53413
|
const round = realtimeAsrRoundRef.current;
|
|
53261
|
-
round && (
|
|
53262
|
-
|
|
53414
|
+
round && (asrDebug('round.cancel', {
|
|
53415
|
+
roundId: round.roundId,
|
|
53416
|
+
questionKey: round.questionKey,
|
|
53417
|
+
reason,
|
|
53418
|
+
clientState: (null === (_round$client = round.client) || void 0 === _round$client ? void 0 : _round$client.state) || 'not-created',
|
|
53419
|
+
textLength: (null === (_round$text = round.text) || void 0 === _round$text ? void 0 : _round$text.length) || 0
|
|
53420
|
+
}), realtimeAsrRoundRef.current = null, round.active = !1, clearTimeout(round.deadlineTimer),
|
|
53421
|
+
clearTimeout(round.matchTimer), null === (_round$client2 = round.client) || void 0 === _round$client2 || _round$client2.destroy());
|
|
53263
53422
|
}, completeRealtimeAsr = (round, detail = {}) => {
|
|
53264
|
-
var _round$
|
|
53423
|
+
var _round$client3;
|
|
53265
53424
|
if (!isCurrentRealtimeRound(round) || round.submitted) {
|
|
53266
|
-
return
|
|
53425
|
+
return void asrDebug('round.complete.skipped', {
|
|
53426
|
+
roundId: null == round ? void 0 : round.roundId,
|
|
53427
|
+
questionKey: null == round ? void 0 : round.questionKey,
|
|
53428
|
+
active: Boolean(null == round ? void 0 : round.active),
|
|
53429
|
+
submitted: Boolean(null == round ? void 0 : round.submitted),
|
|
53430
|
+
isCurrent: Boolean(round && realtimeAsrRoundRef.current === round),
|
|
53431
|
+
unmounted: isUnmountedRef.current,
|
|
53432
|
+
reason: detail.reason || '',
|
|
53433
|
+
hasError: Boolean(detail.error || (null == round ? void 0 : round.error))
|
|
53434
|
+
});
|
|
53267
53435
|
}
|
|
53268
53436
|
round.submitted = !0, round.active = !1, realtimeAsrRoundRef.current = null, clearTimeout(round.deadlineTimer),
|
|
53269
53437
|
clearTimeout(round.matchTimer), clearAsrTimers(), isAwaitingAnswerRef.current = !1,
|
|
@@ -53300,7 +53468,7 @@ function IndexWidget({customer, options}) {
|
|
|
53300
53468
|
} catch (_) {
|
|
53301
53469
|
reportSendFailure();
|
|
53302
53470
|
}
|
|
53303
|
-
null === (_round$
|
|
53471
|
+
null === (_round$client3 = round.client) || void 0 === _round$client3 || _round$client3.destroy();
|
|
53304
53472
|
}, stopRealtimeAsr = (round, reason) => {
|
|
53305
53473
|
if (isCurrentRealtimeRound(round) && ('timeout' === reason && (round.reason = reason,
|
|
53306
53474
|
clearTimeout(round.deadlineTimer), clearInterval(asrCountdownTimerRef.current),
|
|
@@ -53341,7 +53509,15 @@ function IndexWidget({customer, options}) {
|
|
|
53341
53509
|
round.matchTimer = null, isCurrentRealtimeRound(round) && !round.stopping && (null == round.lastAudioAt || Date.now() - round.lastAudioAt > 250 || 3 !== matchAnswerResult(round.text.replace(/[,,]/g, ''), round.correctAnswer, round.errorAnswer) && (Date.now() - round.textChangedAt >= ASR_MATCH_STABLE_MS && Date.now() - round.lastSpeechAt >= ASR_MATCH_SILENCE_MS ? stopRealtimeAsr(round, 'matched') : scheduleRealtimeAsrMatch(round)));
|
|
53342
53510
|
}), delay);
|
|
53343
53511
|
}, startRealtimeAsr = (data, view) => {
|
|
53344
|
-
const duration = getRealtimeAsrDuration(data.durationSeconds || asrWaitTimesRef.current)
|
|
53512
|
+
const duration = getRealtimeAsrDuration(data.durationSeconds || asrWaitTimesRef.current);
|
|
53513
|
+
asrDebug('round.start', {
|
|
53514
|
+
roundId: data.roundId,
|
|
53515
|
+
questionKey: data.questionKey,
|
|
53516
|
+
duration,
|
|
53517
|
+
recordId: realtimeAsrConfigRecordIdRef.current,
|
|
53518
|
+
hasConfigPromise: Boolean(realtimeAsrCredentialsRef.current)
|
|
53519
|
+
});
|
|
53520
|
+
const round = {
|
|
53345
53521
|
roundId: data.roundId,
|
|
53346
53522
|
questionKey: data.questionKey,
|
|
53347
53523
|
correctAnswer: 'string' == typeof data.correctAnswer ? data.correctAnswer : void 0,
|
|
@@ -53360,8 +53536,8 @@ function IndexWidget({customer, options}) {
|
|
|
53360
53536
|
realtimeAsrRoundRef.current = round;
|
|
53361
53537
|
try {
|
|
53362
53538
|
var _customer$localStream;
|
|
53363
|
-
if (config =
|
|
53364
|
-
throw new Error('
|
|
53539
|
+
if (config = getAsrConfig(asrConfig, !0), 1 !== config.type) {
|
|
53540
|
+
throw new Error('坐席已启用实时识别,但客户端 asrConfig.type 未设为 1');
|
|
53365
53541
|
}
|
|
53366
53542
|
if (!data.roundId || null == data.questionKey || '' === data.questionKey) {
|
|
53367
53543
|
throw new Error('实时识别消息缺少 roundId 或 questionKey');
|
|
@@ -53372,16 +53548,31 @@ function IndexWidget({customer, options}) {
|
|
|
53372
53548
|
}
|
|
53373
53549
|
setShowWaitView(!0), renderCir(duration, view, (() => stopRealtimeAsr(round, 'timeout')), round.deadlineAt),
|
|
53374
53550
|
round.deadlineTimer = setTimeout((() => stopRealtimeAsr(round, 'timeout')), 1e3 * duration),
|
|
53375
|
-
Promise.resolve(updateAnswerAudio(!0)).then((()
|
|
53551
|
+
Promise.resolve(updateAnswerAudio(!0)).then(_asyncToGenerator((function*() {
|
|
53552
|
+
if (!isCurrentRealtimeRound(round)) {
|
|
53553
|
+
return;
|
|
53554
|
+
}
|
|
53555
|
+
const result = yield realtimeAsrCredentialsRef.current;
|
|
53376
53556
|
if (!isCurrentRealtimeRound(round)) {
|
|
53377
53557
|
return;
|
|
53378
53558
|
}
|
|
53559
|
+
if (null != result && result.error) {
|
|
53560
|
+
throw result.error;
|
|
53561
|
+
}
|
|
53562
|
+
const credentials = null == result ? void 0 : result.credentials;
|
|
53563
|
+
if (asrDebug('round.config', {
|
|
53564
|
+
roundId: round.roundId,
|
|
53565
|
+
appId: null == credentials ? void 0 : credentials.appId,
|
|
53566
|
+
remainingMs: round.deadlineAt - Date.now()
|
|
53567
|
+
}), !credentials) {
|
|
53568
|
+
throw new Error('尚未收到开始录制通知,未获取实时 ASR 配置');
|
|
53569
|
+
}
|
|
53379
53570
|
if (Date.now() >= round.deadlineAt) {
|
|
53380
53571
|
return void stopRealtimeAsr(round, 'timeout');
|
|
53381
53572
|
}
|
|
53382
53573
|
const client = new RealtimeAsrClient({
|
|
53383
|
-
wsUrl:
|
|
53384
|
-
appId:
|
|
53574
|
+
wsUrl: credentials.wsUrl,
|
|
53575
|
+
appId: credentials.appId,
|
|
53385
53576
|
mediaStream: stream,
|
|
53386
53577
|
business: getRealtimeAsrBusiness(config, duration)
|
|
53387
53578
|
});
|
|
@@ -53400,7 +53591,14 @@ function IndexWidget({customer, options}) {
|
|
|
53400
53591
|
})), client.addEventListener('error', (({detail}) => {
|
|
53401
53592
|
isCurrentRealtimeRound(round) && (round.error = detail);
|
|
53402
53593
|
})), client.addEventListener('end', (({detail}) => ((round, detail = {}) => {
|
|
53403
|
-
if (
|
|
53594
|
+
if (asrDebug('round.asr.end', {
|
|
53595
|
+
roundId: round.roundId,
|
|
53596
|
+
questionKey: round.questionKey,
|
|
53597
|
+
reason: detail.reason || '',
|
|
53598
|
+
textLength: 'string' == typeof detail.text ? detail.text.length : round.text.length,
|
|
53599
|
+
hasError: Boolean(detail.error || round.error),
|
|
53600
|
+
isCurrent: isCurrentRealtimeRound(round)
|
|
53601
|
+
}), isCurrentRealtimeRound(round)) {
|
|
53404
53602
|
if (clearTimeout(round.matchTimer), round.matchTimer = null, round.text = 'string' == typeof detail.text ? detail.text : round.text,
|
|
53405
53603
|
!detail.error && !round.error && 'final' === detail.reason && 3 === matchAnswerResult(round.text.replace(/[,,]/g, ''), round.correctAnswer, round.errorAnswer) && Date.now() < round.deadlineAt) {
|
|
53406
53604
|
return round.endDetail = detail, round.stopping = !1, round.reason = null, setAsrText(round.text),
|
|
@@ -53415,7 +53613,7 @@ function IndexWidget({customer, options}) {
|
|
|
53415
53613
|
})(round, detail))), Promise.resolve(client.start()).catch((error => completeRealtimeAsr(round, {
|
|
53416
53614
|
error
|
|
53417
53615
|
})));
|
|
53418
|
-
})).catch((error => completeRealtimeAsr(round, {
|
|
53616
|
+
}))).catch((error => completeRealtimeAsr(round, {
|
|
53419
53617
|
error
|
|
53420
53618
|
})));
|
|
53421
53619
|
} catch (error) {
|
|
@@ -53423,11 +53621,11 @@ function IndexWidget({customer, options}) {
|
|
|
53423
53621
|
error
|
|
53424
53622
|
});
|
|
53425
53623
|
}
|
|
53426
|
-
}, resetAsrDisplay = () => {
|
|
53427
|
-
cancelRealtimeAsr(), clearAsrTimers(), isAwaitingAnswerRef.current = !1, updateAnswerAudio(!1),
|
|
53624
|
+
}, resetAsrDisplay = (reason = 'display-reset') => {
|
|
53625
|
+
cancelRealtimeAsr(reason), clearAsrTimers(), isAwaitingAnswerRef.current = !1, updateAnswerAudio(!1),
|
|
53428
53626
|
setAsrText(''), setShowWaitView(!1);
|
|
53429
53627
|
}, updatePlaybackSubtitle = text => {
|
|
53430
|
-
resetAsrDisplay(), setSubtitle(text);
|
|
53628
|
+
isSilentSubtitle(text) || (resetAsrDisplay('playback-subtitle'), setSubtitle(text));
|
|
53431
53629
|
}, resetRecordFaceCheckFailState = (preserveAnswerFailure = !1) => {
|
|
53432
53630
|
clearTimeout(recordFailureTimerRef.current), recordFaceCheckFailCountRef.current = 0,
|
|
53433
53631
|
recordFaceCheckFailReportedRef.current = !1, preserveAnswerFailure && answerFailureShownRef.current || (answerFailureShownRef.current = !1,
|
|
@@ -53438,7 +53636,7 @@ function IndexWidget({customer, options}) {
|
|
|
53438
53636
|
syncRecordingAudio();
|
|
53439
53637
|
}), [ isRecording ]);
|
|
53440
53638
|
const subscribeRemoteStream = function() {
|
|
53441
|
-
var
|
|
53639
|
+
var _ref3 = _asyncToGenerator((function*(streamId, streamLabel) {
|
|
53442
53640
|
const startTime = Date.now();
|
|
53443
53641
|
try {
|
|
53444
53642
|
return yield customer.subscribeStream(streamId), subscribeStreamTimes.current = Date.now() - startTime,
|
|
@@ -53458,10 +53656,10 @@ function IndexWidget({customer, options}) {
|
|
|
53458
53656
|
}
|
|
53459
53657
|
}));
|
|
53460
53658
|
return function(_x, _x2) {
|
|
53461
|
-
return
|
|
53659
|
+
return _ref3.apply(this, arguments);
|
|
53462
53660
|
};
|
|
53463
53661
|
}(), joinRoom = function() {
|
|
53464
|
-
var
|
|
53662
|
+
var _ref4 = _asyncToGenerator((function*() {
|
|
53465
53663
|
console.log('joinRoom');
|
|
53466
53664
|
try {
|
|
53467
53665
|
listen();
|
|
@@ -53489,11 +53687,11 @@ function IndexWidget({customer, options}) {
|
|
|
53489
53687
|
}
|
|
53490
53688
|
}));
|
|
53491
53689
|
return function() {
|
|
53492
|
-
return
|
|
53690
|
+
return _ref4.apply(this, arguments);
|
|
53493
53691
|
};
|
|
53494
53692
|
}(), listen = () => {
|
|
53495
53693
|
customer.onStreamAdd(function() {
|
|
53496
|
-
var
|
|
53694
|
+
var _ref5 = _asyncToGenerator((function*(info) {
|
|
53497
53695
|
console.log('onStreamAdd', info);
|
|
53498
53696
|
let streamId = info.id;
|
|
53499
53697
|
reportLog('stream_add', 'info', 'info', {
|
|
@@ -53604,14 +53802,14 @@ function IndexWidget({customer, options}) {
|
|
|
53604
53802
|
}
|
|
53605
53803
|
}));
|
|
53606
53804
|
return function(_x3) {
|
|
53607
|
-
return
|
|
53805
|
+
return _ref5.apply(this, arguments);
|
|
53608
53806
|
};
|
|
53609
53807
|
}()), customer.onMessageReceived((msg => {
|
|
53610
|
-
|
|
53808
|
+
dealWithMessage(msg.message);
|
|
53611
53809
|
})), customer.onPlayingEvent(function() {
|
|
53612
|
-
var
|
|
53810
|
+
var _ref6 = _asyncToGenerator((function*(data) {
|
|
53613
53811
|
let msg = data.data;
|
|
53614
|
-
if (
|
|
53812
|
+
if (msg.streamId === aiAgentStreamIdRef.current) {
|
|
53615
53813
|
if ('started' === msg.playingProgress || 'switched' === msg.playingProgress) {
|
|
53616
53814
|
let file = playingListRef.current[playingIndexsRef.current[msg.currentFileIndex]], isCurrentFileInPlayingList = !1;
|
|
53617
53815
|
for (let i = 0; i < playingListRef.current.length; i++) {
|
|
@@ -53620,7 +53818,7 @@ function IndexWidget({customer, options}) {
|
|
|
53620
53818
|
break;
|
|
53621
53819
|
}
|
|
53622
53820
|
}
|
|
53623
|
-
isCurrentFileInPlayingList && file && file.words_content &&
|
|
53821
|
+
isCurrentFileInPlayingList && file && file.words_content && !isSilentSubtitle(file.words_content) && (reviewTextMessageRef.current = '',
|
|
53624
53822
|
updatePlaybackSubtitle(file.words_content), 0 == msg.currentFileIndex && 0 == playingIndexsRef.current[0] && setShowAgentInfo(!0)),
|
|
53625
53823
|
isCurrentFileInPlayingList && file && 'switched' === msg.playingProgress && 0 == playingIndexsRef.current[0] && (isSilentAgentAudioModeRef.current || reviewTextMessageRef.current || setSubtitle(SUBTITLE_REVIEW));
|
|
53626
53824
|
} else {
|
|
@@ -53629,7 +53827,7 @@ function IndexWidget({customer, options}) {
|
|
|
53629
53827
|
}
|
|
53630
53828
|
}));
|
|
53631
53829
|
return function(_x4) {
|
|
53632
|
-
return
|
|
53830
|
+
return _ref6.apply(this, arguments);
|
|
53633
53831
|
};
|
|
53634
53832
|
}()), customer.onParticipantAdded((e => {
|
|
53635
53833
|
console.log('有新用户加入', e);
|
|
@@ -53638,7 +53836,7 @@ function IndexWidget({customer, options}) {
|
|
|
53638
53836
|
phase: 'business',
|
|
53639
53837
|
recordStatus: 'end',
|
|
53640
53838
|
recordId: e.recordId || ''
|
|
53641
|
-
}), setRecordId(''), setIsRecording(!1), resetRecordFaceCheckFailState(!0));
|
|
53839
|
+
}), setRecordId(''), setIsRecording(!1), recordFaceCheckFailReportedRef.current || resetRecordFaceCheckFailState(!0));
|
|
53642
53840
|
})), customer.onRecordAddListener((e => {
|
|
53643
53841
|
console.log('录制开启', e), e.recordId == recordIdRef.current && (reportLog('record_state_change', 'info', 'success', {
|
|
53644
53842
|
phase: 'business',
|
|
@@ -53652,7 +53850,7 @@ function IndexWidget({customer, options}) {
|
|
|
53652
53850
|
recordId: e.recordId || '',
|
|
53653
53851
|
errorCode: (null == e ? void 0 : e.code) || '',
|
|
53654
53852
|
errorMessage: (null == e ? void 0 : e.message) || ''
|
|
53655
|
-
}), setRecordId(''), setIsRecording(!1), resetRecordFaceCheckFailState(!0));
|
|
53853
|
+
}), setRecordId(''), setIsRecording(!1), recordFaceCheckFailReportedRef.current || resetRecordFaceCheckFailState(!0));
|
|
53656
53854
|
})), customer.onPublishQualityReport((event => {
|
|
53657
53855
|
var _event$message;
|
|
53658
53856
|
let frameRate = null === (_event$message = event.message) || void 0 === _event$message || null === (_event$message = _event$message.report) || void 0 === _event$message || null === (_event$message = _event$message.info) || void 0 === _event$message ? void 0 : _event$message.frameRate;
|
|
@@ -53674,7 +53872,7 @@ function IndexWidget({customer, options}) {
|
|
|
53674
53872
|
}
|
|
53675
53873
|
const isCustomerTransfer = reason === FACE_CHECK_TRANSFER_REASON;
|
|
53676
53874
|
isCustomerTransfer && (sessionEndingRef.current = !0, customer.sessionEndReason = reason),
|
|
53677
|
-
resetAsrDisplay(), console.log('%c session End', 'color: red; font-size: 20px;');
|
|
53875
|
+
resetAsrDisplay('session-end'), console.log('%c session End', 'color: red; font-size: 20px;');
|
|
53678
53876
|
let info = {
|
|
53679
53877
|
type: 'quit',
|
|
53680
53878
|
extraData: 'auto-quit',
|
|
@@ -53719,12 +53917,15 @@ function IndexWidget({customer, options}) {
|
|
|
53719
53917
|
return;
|
|
53720
53918
|
}
|
|
53721
53919
|
answerFailureShownRef.current = !0, clearTimeout(recordFailureTimerRef.current),
|
|
53722
|
-
resetAsrDisplay(), setRecordFailureType('answer'), setShowRecordFaceCheckFailToast(!0);
|
|
53920
|
+
resetAsrDisplay('answer-fail'), setRecordFailureType('answer'), setShowRecordFaceCheckFailToast(!0);
|
|
53723
53921
|
} else {
|
|
53724
53922
|
if (answerFailureShownRef.current) {
|
|
53725
53923
|
return;
|
|
53726
53924
|
}
|
|
53727
53925
|
if ('text' === data.type) {
|
|
53926
|
+
if (isSilentSubtitle(data.message)) {
|
|
53927
|
+
return;
|
|
53928
|
+
}
|
|
53728
53929
|
reviewTextMessageRef.current = data.message || '', setSubtitle(data.message);
|
|
53729
53930
|
} else if ('insert-playing' === data.type) {
|
|
53730
53931
|
reviewTextMessageRef.current = '', !isSilentAgentAudioModeRef.current && updatePlaybackSubtitle(data.data);
|
|
@@ -53734,7 +53935,7 @@ function IndexWidget({customer, options}) {
|
|
|
53734
53935
|
} else if ('cmd' === data.type) {
|
|
53735
53936
|
switch (data.cmd) {
|
|
53736
53937
|
case 'transfer':
|
|
53737
|
-
realtimeAsrRoundRef.current && resetAsrDisplay(), setIsTransferring(!0);
|
|
53938
|
+
realtimeAsrRoundRef.current && resetAsrDisplay('transfer'), setIsTransferring(!0);
|
|
53738
53939
|
break;
|
|
53739
53940
|
|
|
53740
53941
|
case 'cancel-transfer':
|
|
@@ -53756,7 +53957,7 @@ function IndexWidget({customer, options}) {
|
|
|
53756
53957
|
}
|
|
53757
53958
|
}
|
|
53758
53959
|
let view = document.getElementById('customer-widget-waitView');
|
|
53759
|
-
reviewTextMessageRef.current = '', resetAsrDisplay();
|
|
53960
|
+
reviewTextMessageRef.current = '', resetAsrDisplay('new-asr-round');
|
|
53760
53961
|
const answerMaterial = playingIndexsRef.current.reduce(((last, index) => {
|
|
53761
53962
|
const material = playingListRef.current[index];
|
|
53762
53963
|
return !0 === (null == material ? void 0 : material.isSound) ? material : last;
|
|
@@ -53768,13 +53969,13 @@ function IndexWidget({customer, options}) {
|
|
|
53768
53969
|
whiteList: answerLists.whiteList,
|
|
53769
53970
|
blackList: answerLists.blackList,
|
|
53770
53971
|
matchRule: '完整答案相等'
|
|
53771
|
-
}), isAwaitingAnswerRef.current = !0, setSubtitle('请在倒计时结束前用"是"或"否"完成回复'), !0 === data.realtimeAsr ? startRealtimeAsr(data, view) : (
|
|
53972
|
+
}), isAwaitingAnswerRef.current = !0, setSubtitle('请在倒计时结束前用"是"或"否"完成回复'), !0 === data.realtimeAsr ? startRealtimeAsr(data, view) : (1 === (null == asrConfig ? void 0 : asrConfig.type) && reportLog('realtime_asr_mode_mismatch', 'warn', 'info', {
|
|
53772
53973
|
phase: 'business',
|
|
53773
53974
|
message: '客户端配置了实时识别,坐席本轮使用离线识别'
|
|
53774
53975
|
}), updateAnswerAudio(!0), setShowWaitView(!0), renderCir(asrWaitTimesRef.current, view));
|
|
53775
53976
|
} else if ('cancel-realtime-asr' === data.type) {
|
|
53776
53977
|
const round = realtimeAsrRoundRef.current;
|
|
53777
|
-
round && round.roundId === data.roundId && round.questionKey === data.questionKey && resetAsrDisplay();
|
|
53978
|
+
round && round.roundId === data.roundId && round.questionKey === data.questionKey && resetAsrDisplay(data.reason || 'agent-cancel');
|
|
53778
53979
|
} else if ('answer' === data.type) {
|
|
53779
53980
|
const round = realtimeAsrRoundRef.current;
|
|
53780
53981
|
if ((round || data.roundId) && (!round || data.roundId !== round.roundId || data.questionKey !== round.questionKey)) {
|
|
@@ -53783,23 +53984,40 @@ function IndexWidget({customer, options}) {
|
|
|
53783
53984
|
if (!isAwaitingAnswerRef.current) {
|
|
53784
53985
|
return;
|
|
53785
53986
|
}
|
|
53786
|
-
cancelRealtimeAsr(), isAwaitingAnswerRef.current = !1, updateAnswerAudio(!1),
|
|
53987
|
+
cancelRealtimeAsr('agent-answer'), isAwaitingAnswerRef.current = !1, updateAnswerAudio(!1),
|
|
53988
|
+
clearAsrTimers();
|
|
53787
53989
|
let text = data.text || '';
|
|
53788
53990
|
setShowWaitView(!1), setAsrText(text), asrResultTimerRef.current = setTimeout((() => {
|
|
53789
53991
|
asrResultTimerRef.current = null, setAsrText('');
|
|
53790
53992
|
}), 1e3);
|
|
53791
|
-
} else {
|
|
53792
|
-
'update-
|
|
53793
|
-
|
|
53794
|
-
|
|
53795
|
-
|
|
53796
|
-
|
|
53797
|
-
|
|
53993
|
+
} else if ('update-playingIndex' === data.type) {
|
|
53994
|
+
realtimeAsrRoundRef.current && resetAsrDisplay('update-playing-index'), Array.isArray(data.playingAiList) && (playingListRef.current = data.playingAiList,
|
|
53995
|
+
setPlayingList(data.playingAiList)), playingIndexsRef.current = data.data, setPlayingIndexs(data.data);
|
|
53996
|
+
} else if ('agent-info' === data.type) {
|
|
53997
|
+
console.log('agent-info', data), setAgentInfo(data.message), setFrameRateThreshold(data.frameRateThreshold),
|
|
53998
|
+
setMaxFrameRateCheckCount(data.maxFrameRateCheckCount);
|
|
53999
|
+
} else if ('h5-link' === data.type) {
|
|
54000
|
+
setH5ExtraData(data.extraData);
|
|
54001
|
+
} else if ('system-recordId' === data.type) {
|
|
54002
|
+
var _asrConfig$type;
|
|
54003
|
+
asrDebug('record.start', {
|
|
54004
|
+
recordId: data.recordId,
|
|
54005
|
+
asrType: null !== (_asrConfig$type = null == asrConfig ? void 0 : asrConfig.type) && void 0 !== _asrConfig$type ? _asrConfig$type : 0,
|
|
54006
|
+
duplicate: realtimeAsrConfigRecordIdRef.current === data.recordId
|
|
54007
|
+
}), 1 === getAsrConfig(asrConfig).type && data.recordId && realtimeAsrConfigRecordIdRef.current !== data.recordId && (cancelRealtimeAsr('new-record-id'),
|
|
54008
|
+
realtimeAsrConfigRecordIdRef.current = data.recordId, realtimeAsrCredentialsRef.current = queryRealtimeAsrConfig(aiServerUrl, asrConfig).then((credentials => ({
|
|
54009
|
+
credentials
|
|
54010
|
+
})), (error => ({
|
|
54011
|
+
error
|
|
54012
|
+
})))), console.log('data.recordId', data.recordId), setRecordId(data.recordId),
|
|
54013
|
+
setIsRecording(!0), recordIdRef.current = data.recordId, resetRecordFaceCheckFailState(),
|
|
54014
|
+
reportLog('record_state_change', 'info', 'success', {
|
|
53798
54015
|
phase: 'business',
|
|
53799
54016
|
recordStatus: 'start',
|
|
53800
54017
|
recordId: data.recordId || ''
|
|
53801
|
-
})
|
|
53802
|
-
|
|
54018
|
+
});
|
|
54019
|
+
} else {
|
|
54020
|
+
'playing-audio-message' === data.type ? (reviewTextMessageRef.current = '', updatePlaybackSubtitle(data.message)) : 'hangup-audio-call' === data.type && (setIsSilentAgentAudioMode(!1),
|
|
53803
54021
|
setShowAudioCallToast(!1));
|
|
53804
54022
|
}
|
|
53805
54023
|
}
|
|
@@ -53824,7 +54042,7 @@ function IndexWidget({customer, options}) {
|
|
|
53824
54042
|
}, checkFace = () => setInterval(_asyncToGenerator((function*() {
|
|
53825
54043
|
var _s$data;
|
|
53826
54044
|
let base64 = yield captureLocal('customer'), s = yield faceCheckRequest(aiServerUrl + '/singly/detect', base64, userFaceBase64);
|
|
53827
|
-
if (
|
|
54045
|
+
if (0 !== (null === (_s$data = s.data) || void 0 === _s$data ? void 0 : _s$data.error_no)) {
|
|
53828
54046
|
var _s$data2, _s$data3;
|
|
53829
54047
|
(() => {
|
|
53830
54048
|
const threshold = Number(recordFaceCheckFailThresholdRef.current || 0);
|
|
@@ -53850,8 +54068,8 @@ function IndexWidget({customer, options}) {
|
|
|
53850
54068
|
}), 1e3);
|
|
53851
54069
|
})();
|
|
53852
54070
|
const score = null === (_s$data2 = s.data) || void 0 === _s$data2 ? void 0 : _s$data2.score;
|
|
53853
|
-
if (!1 === (null === (_s$data3 = s.data) || void 0 === _s$data3 ? void 0 : _s$data3.compare_result) && null != score && 0 !== score && '0' !== score && (
|
|
53854
|
-
|
|
54071
|
+
if (!1 === (null === (_s$data3 = s.data) || void 0 === _s$data3 ? void 0 : _s$data3.compare_result) && null != score && 0 !== score && '0' !== score && setHasCompareResultFailed(!0),
|
|
54072
|
+
null != score && 0 !== score && '0' !== score) {
|
|
53855
54073
|
return void setIsNoFace(!1);
|
|
53856
54074
|
}
|
|
53857
54075
|
setNoFaceCount((prevCount => {
|
|
@@ -53879,7 +54097,7 @@ function IndexWidget({customer, options}) {
|
|
|
53879
54097
|
})), faceCheckTimer || 2e3), checkFaceAndCaptureOnce = () => {
|
|
53880
54098
|
let timer = null, isChecking = !1;
|
|
53881
54099
|
const runCheck = function() {
|
|
53882
|
-
var
|
|
54100
|
+
var _ref8 = _asyncToGenerator((function*() {
|
|
53883
54101
|
if (!isChecking) {
|
|
53884
54102
|
isChecking = !0;
|
|
53885
54103
|
try {
|
|
@@ -53895,12 +54113,12 @@ function IndexWidget({customer, options}) {
|
|
|
53895
54113
|
}
|
|
53896
54114
|
}));
|
|
53897
54115
|
return function() {
|
|
53898
|
-
return
|
|
54116
|
+
return _ref8.apply(this, arguments);
|
|
53899
54117
|
};
|
|
53900
54118
|
}();
|
|
53901
54119
|
return timer = setInterval(runCheck, faceCheckTimer || 2e3), timer;
|
|
53902
54120
|
}, publishStream = function() {
|
|
53903
|
-
var
|
|
54121
|
+
var _ref9 = _asyncToGenerator((function*(stream) {
|
|
53904
54122
|
try {
|
|
53905
54123
|
let startTime = Date.now(), publish = yield customer.publish(stream);
|
|
53906
54124
|
setCustomerStreamId(publish.id);
|
|
@@ -53935,13 +54153,13 @@ function IndexWidget({customer, options}) {
|
|
|
53935
54153
|
}
|
|
53936
54154
|
}));
|
|
53937
54155
|
return function(_x5) {
|
|
53938
|
-
return
|
|
54156
|
+
return _ref9.apply(this, arguments);
|
|
53939
54157
|
};
|
|
53940
54158
|
}();
|
|
53941
54159
|
reactExports.useEffect((() => (isUnmountedRef.current = !1, reportLog('component_mount', 'info', 'info', {
|
|
53942
54160
|
phase: 'init'
|
|
53943
54161
|
}), joinRoom(), () => {
|
|
53944
|
-
isUnmountedRef.current = !0, clearTimeout(recordFailureTimerRef.current), cancelRealtimeAsr(),
|
|
54162
|
+
isUnmountedRef.current = !0, clearTimeout(recordFailureTimerRef.current), cancelRealtimeAsr('component-unmount'),
|
|
53945
54163
|
clearAsrTimers(), isAwaitingAnswerRef.current = !1, isAnsweringRef.current = !1;
|
|
53946
54164
|
})), []), reactExports.useEffect((() => {
|
|
53947
54165
|
frameRateThresholdRef.current = frameRateThreshold;
|
|
@@ -53958,7 +54176,7 @@ function IndexWidget({customer, options}) {
|
|
|
53958
54176
|
})), setShowErrorToast(!0));
|
|
53959
54177
|
}), [ frameRateCheckCount ]), reactExports.useEffect((() => {
|
|
53960
54178
|
if (playingListRef.current = playingList, customerImageRef.current = customerImage,
|
|
53961
|
-
|
|
54179
|
+
playingList.length > 0 && customerImageRef.current && !isSend) {
|
|
53962
54180
|
let info = {
|
|
53963
54181
|
type: 'customerImage',
|
|
53964
54182
|
data: customerImageRef.current
|
|
@@ -54002,7 +54220,7 @@ function IndexWidget({customer, options}) {
|
|
|
54002
54220
|
clearInterval(timer);
|
|
54003
54221
|
};
|
|
54004
54222
|
}), [ customerStreamId, customerImage ]), reactExports.useEffect((() => {
|
|
54005
|
-
|
|
54223
|
+
playingIndexs && (playingIndexsRef.current = playingIndexs);
|
|
54006
54224
|
}), [ playingIndexs ]), reactExports.useEffect((() => {
|
|
54007
54225
|
console.log('listen subtitle', subtitle), subtitle && (document.getElementById('customer-top-container').style.display = 'flex');
|
|
54008
54226
|
}), [ subtitle ]), reactExports.useEffect((() => {
|
|
@@ -54460,7 +54678,7 @@ class CustomerComponent extends EventTarget {
|
|
|
54460
54678
|
this.disconnectedParticipantId = null;
|
|
54461
54679
|
}
|
|
54462
54680
|
init(id, options) {
|
|
54463
|
-
|
|
54681
|
+
getAsrConfig(null == options ? void 0 : options.asrConfig, !0), console.log('init', id, redactRealtimeAsrOptions(options)),
|
|
54464
54682
|
this.traceReporter = createBusinessTraceReporter({
|
|
54465
54683
|
logServiceUrl: null == options ? void 0 : options.logServiceUrl,
|
|
54466
54684
|
requestNo: null == options ? void 0 : options.request_no,
|