@easyv/biz-components 0.0.12 → 0.0.15
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/dist/_virtual/___vite-browser-external.es.js +7 -0
- package/dist/_virtual/___vite-browser-external.es.js.map +1 -0
- package/dist/_virtual/__vite-browser-external.es.js +5 -0
- package/dist/_virtual/__vite-browser-external.es.js.map +1 -0
- package/dist/_virtual/_commonjs-dynamic-modules.es.js +7 -0
- package/dist/_virtual/_commonjs-dynamic-modules.es.js.map +1 -0
- package/dist/_virtual/_commonjsHelpers.es.js +24 -4
- package/dist/_virtual/_commonjsHelpers.es.js.map +1 -1
- package/dist/_virtual/aes.es.js +5 -0
- package/dist/_virtual/aes.es.js.map +1 -0
- package/dist/_virtual/blowfish.es.js +5 -0
- package/dist/_virtual/blowfish.es.js.map +1 -0
- package/dist/_virtual/cipher-core.es.js +5 -0
- package/dist/_virtual/cipher-core.es.js.map +1 -0
- package/dist/_virtual/core.es.js +5 -0
- package/dist/_virtual/core.es.js.map +1 -0
- package/dist/_virtual/enc-base64.es.js +5 -0
- package/dist/_virtual/enc-base64.es.js.map +1 -0
- package/dist/_virtual/enc-base64url.es.js +5 -0
- package/dist/_virtual/enc-base64url.es.js.map +1 -0
- package/dist/_virtual/enc-utf16.es.js +5 -0
- package/dist/_virtual/enc-utf16.es.js.map +1 -0
- package/dist/_virtual/evpkdf.es.js +5 -0
- package/dist/_virtual/evpkdf.es.js.map +1 -0
- package/dist/_virtual/format-hex.es.js +5 -0
- package/dist/_virtual/format-hex.es.js.map +1 -0
- package/dist/_virtual/hmac.es.js +5 -0
- package/dist/_virtual/hmac.es.js.map +1 -0
- package/dist/_virtual/index.es2.js +2 -2
- package/dist/_virtual/index.es3.js +2 -2
- package/dist/_virtual/index.es4.js +2 -2
- package/dist/_virtual/index.es5.js +2 -2
- package/dist/_virtual/index.es6.js +5 -0
- package/dist/_virtual/index.es6.js.map +1 -0
- package/dist/_virtual/index.es7.js +5 -0
- package/dist/_virtual/index.es7.js.map +1 -0
- package/dist/_virtual/lib-typedarrays.es.js +5 -0
- package/dist/_virtual/lib-typedarrays.es.js.map +1 -0
- package/dist/_virtual/md5.es.js +5 -0
- package/dist/_virtual/md5.es.js.map +1 -0
- package/dist/_virtual/mode-cfb.es.js +5 -0
- package/dist/_virtual/mode-cfb.es.js.map +1 -0
- package/dist/_virtual/mode-ctr-gladman.es.js +5 -0
- package/dist/_virtual/mode-ctr-gladman.es.js.map +1 -0
- package/dist/_virtual/mode-ctr.es.js +5 -0
- package/dist/_virtual/mode-ctr.es.js.map +1 -0
- package/dist/_virtual/mode-ecb.es.js +5 -0
- package/dist/_virtual/mode-ecb.es.js.map +1 -0
- package/dist/_virtual/mode-ofb.es.js +5 -0
- package/dist/_virtual/mode-ofb.es.js.map +1 -0
- package/dist/_virtual/pad-ansix923.es.js +5 -0
- package/dist/_virtual/pad-ansix923.es.js.map +1 -0
- package/dist/_virtual/pad-iso10126.es.js +5 -0
- package/dist/_virtual/pad-iso10126.es.js.map +1 -0
- package/dist/_virtual/pad-iso97971.es.js +5 -0
- package/dist/_virtual/pad-iso97971.es.js.map +1 -0
- package/dist/_virtual/pad-nopadding.es.js +5 -0
- package/dist/_virtual/pad-nopadding.es.js.map +1 -0
- package/dist/_virtual/pad-zeropadding.es.js +5 -0
- package/dist/_virtual/pad-zeropadding.es.js.map +1 -0
- package/dist/_virtual/pbkdf2.es.js +5 -0
- package/dist/_virtual/pbkdf2.es.js.map +1 -0
- package/dist/_virtual/rabbit-legacy.es.js +5 -0
- package/dist/_virtual/rabbit-legacy.es.js.map +1 -0
- package/dist/_virtual/rabbit.es.js +5 -0
- package/dist/_virtual/rabbit.es.js.map +1 -0
- package/dist/_virtual/rc4.es.js +5 -0
- package/dist/_virtual/rc4.es.js.map +1 -0
- package/dist/_virtual/ripemd160.es.js +5 -0
- package/dist/_virtual/ripemd160.es.js.map +1 -0
- package/dist/_virtual/sha1.es.js +5 -0
- package/dist/_virtual/sha1.es.js.map +1 -0
- package/dist/_virtual/sha224.es.js +5 -0
- package/dist/_virtual/sha224.es.js.map +1 -0
- package/dist/_virtual/sha256.es.js +5 -0
- package/dist/_virtual/sha256.es.js.map +1 -0
- package/dist/_virtual/sha3.es.js +5 -0
- package/dist/_virtual/sha3.es.js.map +1 -0
- package/dist/_virtual/sha384.es.js +5 -0
- package/dist/_virtual/sha384.es.js.map +1 -0
- package/dist/_virtual/sha512.es.js +5 -0
- package/dist/_virtual/sha512.es.js.map +1 -0
- package/dist/_virtual/tripledes.es.js +5 -0
- package/dist/_virtual/tripledes.es.js.map +1 -0
- package/dist/_virtual/x64-core.es.js +5 -0
- package/dist/_virtual/x64-core.es.js.map +1 -0
- package/dist/components/AiMessageRender/AiMessageRender.es.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useXunFeiSteamVoiceManager.d.ts +8 -0
- package/dist/hooks/useXunFeiSteamVoiceManager.es.js +15 -0
- package/dist/hooks/useXunFeiSteamVoiceManager.es.js.map +1 -0
- package/dist/index.es.js +14 -8
- package/dist/index.es.js.map +1 -1
- package/dist/node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/.pnpm/co-web-worker@1.0.1/node_modules/co-web-worker/index.es.js +16 -0
- package/dist/node_modules/.pnpm/co-web-worker@1.0.1/node_modules/co-web-worker/index.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.es.js +71 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.es.js +1133 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.es.js +546 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.es.js +509 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.es.js +82 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.es.js +89 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.es.js +101 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.es.js +72 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.es.js +55 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.es.js +85 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.es.js +50 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.es.js +29 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.es.js +73 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.es.js +38 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.es.js +47 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.es.js +30 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.es.js +29 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.es.js +28 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.es.js +27 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.es.js +27 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.es.js +25 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.es.js +23 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.es.js +30 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.es.js +76 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.es.js +75 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.es.js +77 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.es.js +65 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.es.js +400 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.es.js +51 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.es.js +38 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.es.js +59 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.es.js +118 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.es.js +39 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.es.js +149 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.es.js +731 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.es.js.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.es.js +237 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.es.js.map +1 -0
- package/dist/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.es.js +1 -1
- package/dist/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.es.js +1 -1
- package/dist/node_modules/.pnpm/style-to-js@1.1.16/node_modules/style-to-js/cjs/index.es.js +1 -1
- package/dist/node_modules/.pnpm/style-to-object@1.0.8/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/xunFeiVoice/RecorderManager/RecordManager-origin.d.ts +14 -0
- package/dist/utils/xunFeiVoice/RecorderManager/RecorderManager-draft.d.ts +38 -0
- package/dist/utils/xunFeiVoice/RecorderManager/RecorderManager.d.ts +47 -0
- package/dist/utils/xunFeiVoice/RecorderManager/RecorderManager.es.js +121 -0
- package/dist/utils/xunFeiVoice/RecorderManager/RecorderManager.es.js.map +1 -0
- package/dist/utils/xunFeiVoice/RecorderManager/index.d.ts +1 -0
- package/dist/utils/xunFeiVoice/RecorderManager/processor.worklet.d.ts +0 -0
- package/dist/utils/xunFeiVoice/RecorderManager/processor.worklet.es.js +379 -0
- package/dist/utils/xunFeiVoice/RecorderManager/processor.worklet.es.js.map +1 -0
- package/dist/utils/xunFeiVoice/XunFeiStreamVoiceManager.d.ts +66 -0
- package/dist/utils/xunFeiVoice/XunFeiStreamVoiceManager.es.js +165 -0
- package/dist/utils/xunFeiVoice/XunFeiStreamVoiceManager.es.js.map +1 -0
- package/dist/utils/xunFeiVoice/index.d.ts +2 -0
- package/dist/utils/xunFeiVoice/test/RecorderManager.cy.d.ts +1 -0
- package/dist/utils/xunFeiVoice/test/XunFeiVoiceManager.cy.d.ts +1 -0
- package/dist/utils/xunFeiVoice/types.d.ts +30 -0
- package/dist/utils/xunFeiVoice/utils.d.ts +1 -0
- package/dist/utils/xunFeiVoice/utils.es.js +11 -0
- package/dist/utils/xunFeiVoice/utils.es.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
const n = `!(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
function t(t, e) {
|
|
4
|
+
for (var r = 0; r < e.length; r++) {
|
|
5
|
+
var n = e[r];
|
|
6
|
+
(n.enumerable = n.enumerable || !1),
|
|
7
|
+
(n.configurable = !0),
|
|
8
|
+
'value' in n && (n.writable = !0),
|
|
9
|
+
Object.defineProperty(
|
|
10
|
+
t,
|
|
11
|
+
((i = n.key),
|
|
12
|
+
(o = void 0),
|
|
13
|
+
'symbol' ==
|
|
14
|
+
typeof (o = (function (t, e) {
|
|
15
|
+
if ('object' != typeof t || null === t) return t;
|
|
16
|
+
var r = t[Symbol.toPrimitive];
|
|
17
|
+
if (void 0 !== r) {
|
|
18
|
+
var n = r.call(t, e || 'default');
|
|
19
|
+
if ('object' != typeof n) return n;
|
|
20
|
+
throw new TypeError('@@toPrimitive must return a primitive value.');
|
|
21
|
+
}
|
|
22
|
+
return ('string' === e ? String : Number)(t);
|
|
23
|
+
})(i, 'string'))
|
|
24
|
+
? o
|
|
25
|
+
: String(o)),
|
|
26
|
+
n,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
var i, o;
|
|
30
|
+
}
|
|
31
|
+
function e(t) {
|
|
32
|
+
return (
|
|
33
|
+
(e = Object.setPrototypeOf
|
|
34
|
+
? Object.getPrototypeOf.bind()
|
|
35
|
+
: function (t) {
|
|
36
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
37
|
+
}),
|
|
38
|
+
e(t)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function r(t, e) {
|
|
42
|
+
return (
|
|
43
|
+
(r = Object.setPrototypeOf
|
|
44
|
+
? Object.setPrototypeOf.bind()
|
|
45
|
+
: function (t, e) {
|
|
46
|
+
return (t.__proto__ = e), t;
|
|
47
|
+
}),
|
|
48
|
+
r(t, e)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function n() {
|
|
52
|
+
if ('undefined' == typeof Reflect || !Reflect.construct) return !1;
|
|
53
|
+
if (Reflect.construct.sham) return !1;
|
|
54
|
+
if ('function' == typeof Proxy) return !0;
|
|
55
|
+
try {
|
|
56
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0;
|
|
57
|
+
} catch (t) {
|
|
58
|
+
return !1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function i(t, e, o) {
|
|
62
|
+
return (
|
|
63
|
+
(i = n()
|
|
64
|
+
? Reflect.construct.bind()
|
|
65
|
+
: function (t, e, n) {
|
|
66
|
+
var i = [null];
|
|
67
|
+
i.push.apply(i, e);
|
|
68
|
+
var o = new (Function.bind.apply(t, i))();
|
|
69
|
+
return n && r(o, n.prototype), o;
|
|
70
|
+
}),
|
|
71
|
+
i.apply(null, arguments)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function o(t) {
|
|
75
|
+
var n = 'function' == typeof Map ? new Map() : void 0;
|
|
76
|
+
return (
|
|
77
|
+
(o = function (t) {
|
|
78
|
+
if (null === t || ((o = t), -1 === Function.toString.call(o).indexOf('[native code]')))
|
|
79
|
+
return t;
|
|
80
|
+
var o;
|
|
81
|
+
if ('function' != typeof t)
|
|
82
|
+
throw new TypeError('Super expression must either be null or a function');
|
|
83
|
+
if (void 0 !== n) {
|
|
84
|
+
if (n.has(t)) return n.get(t);
|
|
85
|
+
n.set(t, a);
|
|
86
|
+
}
|
|
87
|
+
function a() {
|
|
88
|
+
return i(t, arguments, e(this).constructor);
|
|
89
|
+
}
|
|
90
|
+
return (
|
|
91
|
+
(a.prototype = Object.create(t.prototype, {
|
|
92
|
+
constructor: {
|
|
93
|
+
value: a,
|
|
94
|
+
enumerable: !1,
|
|
95
|
+
writable: !0,
|
|
96
|
+
configurable: !0,
|
|
97
|
+
},
|
|
98
|
+
})),
|
|
99
|
+
r(a, t)
|
|
100
|
+
);
|
|
101
|
+
}),
|
|
102
|
+
o(t)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
function a(t) {
|
|
106
|
+
if (void 0 === t)
|
|
107
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
108
|
+
return t;
|
|
109
|
+
}
|
|
110
|
+
function s(t) {
|
|
111
|
+
var r = n();
|
|
112
|
+
return function () {
|
|
113
|
+
var n,
|
|
114
|
+
i = e(t);
|
|
115
|
+
if (r) {
|
|
116
|
+
var o = e(this).constructor;
|
|
117
|
+
n = Reflect.construct(i, arguments, o);
|
|
118
|
+
} else n = i.apply(this, arguments);
|
|
119
|
+
return (function (t, e) {
|
|
120
|
+
if (e && ('object' == typeof e || 'function' == typeof e)) return e;
|
|
121
|
+
if (void 0 !== e)
|
|
122
|
+
throw new TypeError('Derived constructors may only return object or undefined');
|
|
123
|
+
return a(t);
|
|
124
|
+
})(this, n);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function fn(t) {
|
|
128
|
+
return (
|
|
129
|
+
(function (t) {
|
|
130
|
+
if (Array.isArray(t)) return u(t);
|
|
131
|
+
})(t) ||
|
|
132
|
+
(function (t) {
|
|
133
|
+
if (
|
|
134
|
+
t !== undefined &&
|
|
135
|
+
(('undefined' != typeof Symbol && null != t[Symbol.iterator]) || null != t['@@iterator'])
|
|
136
|
+
)
|
|
137
|
+
return Array.from(t);
|
|
138
|
+
})(t) ||
|
|
139
|
+
(function (t, e) {
|
|
140
|
+
if (!t) return;
|
|
141
|
+
if ('string' == typeof t) return u(t, e);
|
|
142
|
+
var r = Object.prototype.toString.call(t).slice(8, -1);
|
|
143
|
+
'Object' === r && t.constructor && (r = t.constructor.name);
|
|
144
|
+
if ('Map' === r || 'Set' === r) return Array.from(t);
|
|
145
|
+
if ('Arguments' === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return u(t, e);
|
|
146
|
+
})(t) ||
|
|
147
|
+
(function () {
|
|
148
|
+
throw new TypeError(
|
|
149
|
+
'Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
|
|
150
|
+
);
|
|
151
|
+
})()
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function u(t, e) {
|
|
155
|
+
(null == e || e > t.length) && (e = t.length);
|
|
156
|
+
for (var r = 0, n = new Array(e); r < e; r++) n[r] = t[r];
|
|
157
|
+
return n;
|
|
158
|
+
}
|
|
159
|
+
function l(t, e, r, n) {
|
|
160
|
+
(this.fromSampleRate = t),
|
|
161
|
+
(this.toSampleRate = e),
|
|
162
|
+
(this.channels = 0 | r),
|
|
163
|
+
(this.noReturn = !!n),
|
|
164
|
+
this.initialize();
|
|
165
|
+
}
|
|
166
|
+
(l.prototype.initialize = function () {
|
|
167
|
+
if (!(this.fromSampleRate > 0 && this.toSampleRate > 0 && this.channels > 0))
|
|
168
|
+
throw new Error('Invalid settings specified for the resampler.');
|
|
169
|
+
this.fromSampleRate == this.toSampleRate
|
|
170
|
+
? ((this.resampler = this.bypassResampler), (this.ratioWeight = 1))
|
|
171
|
+
: (this.fromSampleRate < this.toSampleRate
|
|
172
|
+
? ((this.lastWeight = 1), (this.resampler = this.compileLinearInterpolation))
|
|
173
|
+
: ((this.tailExists = !1),
|
|
174
|
+
(this.lastWeight = 0),
|
|
175
|
+
(this.resampler = this.compileMultiTap)),
|
|
176
|
+
(this.ratioWeight = this.fromSampleRate / this.toSampleRate));
|
|
177
|
+
}),
|
|
178
|
+
(l.prototype.compileLinearInterpolation = function (t) {
|
|
179
|
+
var e = t.length;
|
|
180
|
+
this.initializeBuffers(e);
|
|
181
|
+
var r,
|
|
182
|
+
n,
|
|
183
|
+
i = this.outputBufferSize,
|
|
184
|
+
o = this.ratioWeight,
|
|
185
|
+
a = this.lastWeight,
|
|
186
|
+
s = 0,
|
|
187
|
+
f = 0,
|
|
188
|
+
u = 0,
|
|
189
|
+
l = this.outputBuffer;
|
|
190
|
+
if (e % this.channels == 0) {
|
|
191
|
+
if (e > 0) {
|
|
192
|
+
for (; a < 1; a += o)
|
|
193
|
+
for (s = 1 - (f = a % 1), r = 0; r < this.channels; ++r)
|
|
194
|
+
l[u++] = this.lastOutput[r] * s + t[r] * f;
|
|
195
|
+
for (a--, e -= this.channels, n = Math.floor(a) * this.channels; u < i && n < e; ) {
|
|
196
|
+
for (s = 1 - (f = a % 1), r = 0; r < this.channels; ++r)
|
|
197
|
+
l[u++] = t[n + r] * s + t[n + this.channels + r] * f;
|
|
198
|
+
(a += o), (n = Math.floor(a) * this.channels);
|
|
199
|
+
}
|
|
200
|
+
for (r = 0; r < this.channels; ++r) this.lastOutput[r] = t[n++];
|
|
201
|
+
return (this.lastWeight = a % 1), this.bufferSlice(u);
|
|
202
|
+
}
|
|
203
|
+
return this.noReturn ? 0 : [];
|
|
204
|
+
}
|
|
205
|
+
throw new Error('Buffer was of incorrect sample length.');
|
|
206
|
+
}),
|
|
207
|
+
(l.prototype.compileMultiTap = function (t) {
|
|
208
|
+
var e = [],
|
|
209
|
+
r = t.length;
|
|
210
|
+
this.initializeBuffers(r);
|
|
211
|
+
var n = this.outputBufferSize;
|
|
212
|
+
if (r % this.channels == 0) {
|
|
213
|
+
if (r > 0) {
|
|
214
|
+
for (var i = this.ratioWeight, o = 0, a = 0; a < this.channels; ++a) e[a] = 0;
|
|
215
|
+
var s = 0,
|
|
216
|
+
f = 0,
|
|
217
|
+
u = !this.tailExists;
|
|
218
|
+
this.tailExists = !1;
|
|
219
|
+
var l = this.outputBuffer,
|
|
220
|
+
h = 0,
|
|
221
|
+
c = 0;
|
|
222
|
+
do {
|
|
223
|
+
if (u) for (o = i, a = 0; a < this.channels; ++a) e[a] = 0;
|
|
224
|
+
else {
|
|
225
|
+
for (o = this.lastWeight, a = 0; a < this.channels; ++a) e[a] += this.lastOutput[a];
|
|
226
|
+
u = !0;
|
|
227
|
+
}
|
|
228
|
+
for (; o > 0 && s < r; ) {
|
|
229
|
+
if (!(o >= (f = 1 + s - c))) {
|
|
230
|
+
for (a = 0; a < this.channels; ++a) e[a] += t[s + a] * o;
|
|
231
|
+
(c += o), (o = 0);
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
for (a = 0; a < this.channels; ++a) e[a] += t[s++] * f;
|
|
235
|
+
(c = s), (o -= f);
|
|
236
|
+
}
|
|
237
|
+
if (0 != o) {
|
|
238
|
+
for (this.lastWeight = o, a = 0; a < this.channels; ++a) this.lastOutput[a] = e[a];
|
|
239
|
+
this.tailExists = !0;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
for (a = 0; a < this.channels; ++a) l[h++] = e[a] / i;
|
|
243
|
+
} while (s < r && h < n);
|
|
244
|
+
return this.bufferSlice(h);
|
|
245
|
+
}
|
|
246
|
+
return this.noReturn ? 0 : [];
|
|
247
|
+
}
|
|
248
|
+
throw new Error('Buffer was of incorrect sample length.');
|
|
249
|
+
}),
|
|
250
|
+
(l.prototype.bypassResampler = function (t) {
|
|
251
|
+
return this.noReturn ? ((this.outputBuffer = t), t.length) : t;
|
|
252
|
+
}),
|
|
253
|
+
(l.prototype.bufferSlice = function (t) {
|
|
254
|
+
if (this.noReturn) return t;
|
|
255
|
+
try {
|
|
256
|
+
return this.outputBuffer.subarray(0, t);
|
|
257
|
+
} catch (e) {
|
|
258
|
+
try {
|
|
259
|
+
return (this.outputBuffer.length = t), this.outputBuffer;
|
|
260
|
+
} catch (e) {
|
|
261
|
+
return this.outputBuffer.slice(0, t);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}),
|
|
265
|
+
(l.prototype.initializeBuffers = function (t) {
|
|
266
|
+
this.outputBufferSize = Math.ceil((t * this.toSampleRate) / this.fromSampleRate);
|
|
267
|
+
try {
|
|
268
|
+
(this.outputBuffer = new Float32Array(this.outputBufferSize)),
|
|
269
|
+
(this.lastOutput = new Float32Array(this.channels));
|
|
270
|
+
} catch (t) {
|
|
271
|
+
(this.outputBuffer = []), (this.lastOutput = []);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
var h = (function (e) {
|
|
275
|
+
!(function (t, e) {
|
|
276
|
+
if ('function' != typeof e && null !== e)
|
|
277
|
+
throw new TypeError('Super expression must either be null or a function');
|
|
278
|
+
(t.prototype = Object.create(e && e.prototype, {
|
|
279
|
+
constructor: { value: t, writable: !0, configurable: !0 },
|
|
280
|
+
})),
|
|
281
|
+
Object.defineProperty(t, 'prototype', { writable: !1 }),
|
|
282
|
+
e && r(t, e);
|
|
283
|
+
})(h, e);
|
|
284
|
+
var n,
|
|
285
|
+
i,
|
|
286
|
+
o,
|
|
287
|
+
u = s(h);
|
|
288
|
+
function h() {
|
|
289
|
+
var t;
|
|
290
|
+
!(function (t, e) {
|
|
291
|
+
if (!(t instanceof e)) throw new TypeError('Cannot call a class as a function');
|
|
292
|
+
})(this, h);
|
|
293
|
+
var e = a((t = u.call(this)));
|
|
294
|
+
return (
|
|
295
|
+
(t.port.onmessage = function (t) {
|
|
296
|
+
var r = t.data,
|
|
297
|
+
n = r.type,
|
|
298
|
+
i = r.data;
|
|
299
|
+
if ((console.log('type', n), 'init' === n)) {
|
|
300
|
+
var o = i.frameSize,
|
|
301
|
+
a = i.toSampleRate,
|
|
302
|
+
s = i.arrayBufferType,
|
|
303
|
+
f = i.fromSampleRate;
|
|
304
|
+
return (
|
|
305
|
+
(e.frameSize = o * Math.floor(f / a)),
|
|
306
|
+
(e.resampler = new l(f, a, 1)),
|
|
307
|
+
(e.frameBuffer = []),
|
|
308
|
+
void (e.arrayBufferType = s)
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
'stop' === n &&
|
|
312
|
+
(e.port.postMessage({
|
|
313
|
+
frameBuffer: e.transData(e.frameBuffer),
|
|
314
|
+
isLastFrame: !0,
|
|
315
|
+
}),
|
|
316
|
+
(e.frameBuffer = []));
|
|
317
|
+
}),
|
|
318
|
+
t
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
return (
|
|
322
|
+
(n = h),
|
|
323
|
+
(i = [
|
|
324
|
+
{
|
|
325
|
+
key: 'process',
|
|
326
|
+
value: function (t) {
|
|
327
|
+
var e,
|
|
328
|
+
r = t[0][0];
|
|
329
|
+
if (!r) return true;
|
|
330
|
+
return this.frameSize
|
|
331
|
+
? ((e = this.frameBuffer).push.apply(e, fn(r)),
|
|
332
|
+
this.frameBuffer.length >= this.frameSize &&
|
|
333
|
+
(this.port.postMessage({
|
|
334
|
+
frameBuffer: this.transData(this.frameBuffer),
|
|
335
|
+
isLastFrame: !1,
|
|
336
|
+
}),
|
|
337
|
+
(this.frameBuffer = [])),
|
|
338
|
+
!0)
|
|
339
|
+
: (r &&
|
|
340
|
+
this.port.postMessage({
|
|
341
|
+
frameBuffer: this.transData(r),
|
|
342
|
+
isLastFrame: !1,
|
|
343
|
+
}),
|
|
344
|
+
!0);
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
key: 'transData',
|
|
349
|
+
value: function (t) {
|
|
350
|
+
return (
|
|
351
|
+
'short16' === this.arrayBufferType &&
|
|
352
|
+
(t = (function (t) {
|
|
353
|
+
for (
|
|
354
|
+
var e = new ArrayBuffer(2 * t.length), r = new DataView(e), n = 0, i = 0;
|
|
355
|
+
i < t.length;
|
|
356
|
+
i += 1, n += 2
|
|
357
|
+
) {
|
|
358
|
+
var o = Math.max(-1, Math.min(1, t[i]));
|
|
359
|
+
r.setInt16(n, o < 0 ? 32768 * o : 32767 * o, !0);
|
|
360
|
+
}
|
|
361
|
+
return r.buffer;
|
|
362
|
+
})((t = this.resampler.resampler(t)))),
|
|
363
|
+
t
|
|
364
|
+
);
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
]) && t(n.prototype, i),
|
|
368
|
+
o && t(n, o),
|
|
369
|
+
Object.defineProperty(n, 'prototype', { writable: !1 }),
|
|
370
|
+
h
|
|
371
|
+
);
|
|
372
|
+
})(o(AudioWorkletProcessor));
|
|
373
|
+
registerProcessor('processor-worklet', h);
|
|
374
|
+
})();
|
|
375
|
+
`;
|
|
376
|
+
export {
|
|
377
|
+
n as default
|
|
378
|
+
};
|
|
379
|
+
//# sourceMappingURL=processor.worklet.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.worklet.es.js","sources":["../../../../src/utils/xunFeiVoice/RecorderManager/processor.worklet.js?raw"],"sourcesContent":["export default \"!(function () {\\n 'use strict';\\n function t(t, e) {\\n for (var r = 0; r < e.length; r++) {\\n var n = e[r];\\n (n.enumerable = n.enumerable || !1),\\n (n.configurable = !0),\\n 'value' in n && (n.writable = !0),\\n Object.defineProperty(\\n t,\\n ((i = n.key),\\n (o = void 0),\\n 'symbol' ==\\n typeof (o = (function (t, e) {\\n if ('object' != typeof t || null === t) return t;\\n var r = t[Symbol.toPrimitive];\\n if (void 0 !== r) {\\n var n = r.call(t, e || 'default');\\n if ('object' != typeof n) return n;\\n throw new TypeError('@@toPrimitive must return a primitive value.');\\n }\\n return ('string' === e ? String : Number)(t);\\n })(i, 'string'))\\n ? o\\n : String(o)),\\n n,\\n );\\n }\\n var i, o;\\n }\\n function e(t) {\\n return (\\n (e = Object.setPrototypeOf\\n ? Object.getPrototypeOf.bind()\\n : function (t) {\\n return t.__proto__ || Object.getPrototypeOf(t);\\n }),\\n e(t)\\n );\\n }\\n function r(t, e) {\\n return (\\n (r = Object.setPrototypeOf\\n ? Object.setPrototypeOf.bind()\\n : function (t, e) {\\n return (t.__proto__ = e), t;\\n }),\\n r(t, e)\\n );\\n }\\n function n() {\\n if ('undefined' == typeof Reflect || !Reflect.construct) return !1;\\n if (Reflect.construct.sham) return !1;\\n if ('function' == typeof Proxy) return !0;\\n try {\\n return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0;\\n } catch (t) {\\n return !1;\\n }\\n }\\n function i(t, e, o) {\\n return (\\n (i = n()\\n ? Reflect.construct.bind()\\n : function (t, e, n) {\\n var i = [null];\\n i.push.apply(i, e);\\n var o = new (Function.bind.apply(t, i))();\\n return n && r(o, n.prototype), o;\\n }),\\n i.apply(null, arguments)\\n );\\n }\\n function o(t) {\\n var n = 'function' == typeof Map ? new Map() : void 0;\\n return (\\n (o = function (t) {\\n if (null === t || ((o = t), -1 === Function.toString.call(o).indexOf('[native code]')))\\n return t;\\n var o;\\n if ('function' != typeof t)\\n throw new TypeError('Super expression must either be null or a function');\\n if (void 0 !== n) {\\n if (n.has(t)) return n.get(t);\\n n.set(t, a);\\n }\\n function a() {\\n return i(t, arguments, e(this).constructor);\\n }\\n return (\\n (a.prototype = Object.create(t.prototype, {\\n constructor: {\\n value: a,\\n enumerable: !1,\\n writable: !0,\\n configurable: !0,\\n },\\n })),\\n r(a, t)\\n );\\n }),\\n o(t)\\n );\\n }\\n function a(t) {\\n if (void 0 === t)\\n throw new ReferenceError(\\\"this hasn't been initialised - super() hasn't been called\\\");\\n return t;\\n }\\n function s(t) {\\n var r = n();\\n return function () {\\n var n,\\n i = e(t);\\n if (r) {\\n var o = e(this).constructor;\\n n = Reflect.construct(i, arguments, o);\\n } else n = i.apply(this, arguments);\\n return (function (t, e) {\\n if (e && ('object' == typeof e || 'function' == typeof e)) return e;\\n if (void 0 !== e)\\n throw new TypeError('Derived constructors may only return object or undefined');\\n return a(t);\\n })(this, n);\\n };\\n }\\n function fn(t) {\\n return (\\n (function (t) {\\n if (Array.isArray(t)) return u(t);\\n })(t) ||\\n (function (t) {\\n if (\\n t !== undefined &&\\n (('undefined' != typeof Symbol && null != t[Symbol.iterator]) || null != t['@@iterator'])\\n )\\n return Array.from(t);\\n })(t) ||\\n (function (t, e) {\\n if (!t) return;\\n if ('string' == typeof t) return u(t, e);\\n var r = Object.prototype.toString.call(t).slice(8, -1);\\n 'Object' === r && t.constructor && (r = t.constructor.name);\\n if ('Map' === r || 'Set' === r) return Array.from(t);\\n if ('Arguments' === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return u(t, e);\\n })(t) ||\\n (function () {\\n throw new TypeError(\\n 'Invalid attempt to spread non-iterable instance.\\\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',\\n );\\n })()\\n );\\n }\\n function u(t, e) {\\n (null == e || e > t.length) && (e = t.length);\\n for (var r = 0, n = new Array(e); r < e; r++) n[r] = t[r];\\n return n;\\n }\\n function l(t, e, r, n) {\\n (this.fromSampleRate = t),\\n (this.toSampleRate = e),\\n (this.channels = 0 | r),\\n (this.noReturn = !!n),\\n this.initialize();\\n }\\n (l.prototype.initialize = function () {\\n if (!(this.fromSampleRate > 0 && this.toSampleRate > 0 && this.channels > 0))\\n throw new Error('Invalid settings specified for the resampler.');\\n this.fromSampleRate == this.toSampleRate\\n ? ((this.resampler = this.bypassResampler), (this.ratioWeight = 1))\\n : (this.fromSampleRate < this.toSampleRate\\n ? ((this.lastWeight = 1), (this.resampler = this.compileLinearInterpolation))\\n : ((this.tailExists = !1),\\n (this.lastWeight = 0),\\n (this.resampler = this.compileMultiTap)),\\n (this.ratioWeight = this.fromSampleRate / this.toSampleRate));\\n }),\\n (l.prototype.compileLinearInterpolation = function (t) {\\n var e = t.length;\\n this.initializeBuffers(e);\\n var r,\\n n,\\n i = this.outputBufferSize,\\n o = this.ratioWeight,\\n a = this.lastWeight,\\n s = 0,\\n f = 0,\\n u = 0,\\n l = this.outputBuffer;\\n if (e % this.channels == 0) {\\n if (e > 0) {\\n for (; a < 1; a += o)\\n for (s = 1 - (f = a % 1), r = 0; r < this.channels; ++r)\\n l[u++] = this.lastOutput[r] * s + t[r] * f;\\n for (a--, e -= this.channels, n = Math.floor(a) * this.channels; u < i && n < e; ) {\\n for (s = 1 - (f = a % 1), r = 0; r < this.channels; ++r)\\n l[u++] = t[n + r] * s + t[n + this.channels + r] * f;\\n (a += o), (n = Math.floor(a) * this.channels);\\n }\\n for (r = 0; r < this.channels; ++r) this.lastOutput[r] = t[n++];\\n return (this.lastWeight = a % 1), this.bufferSlice(u);\\n }\\n return this.noReturn ? 0 : [];\\n }\\n throw new Error('Buffer was of incorrect sample length.');\\n }),\\n (l.prototype.compileMultiTap = function (t) {\\n var e = [],\\n r = t.length;\\n this.initializeBuffers(r);\\n var n = this.outputBufferSize;\\n if (r % this.channels == 0) {\\n if (r > 0) {\\n for (var i = this.ratioWeight, o = 0, a = 0; a < this.channels; ++a) e[a] = 0;\\n var s = 0,\\n f = 0,\\n u = !this.tailExists;\\n this.tailExists = !1;\\n var l = this.outputBuffer,\\n h = 0,\\n c = 0;\\n do {\\n if (u) for (o = i, a = 0; a < this.channels; ++a) e[a] = 0;\\n else {\\n for (o = this.lastWeight, a = 0; a < this.channels; ++a) e[a] += this.lastOutput[a];\\n u = !0;\\n }\\n for (; o > 0 && s < r; ) {\\n if (!(o >= (f = 1 + s - c))) {\\n for (a = 0; a < this.channels; ++a) e[a] += t[s + a] * o;\\n (c += o), (o = 0);\\n break;\\n }\\n for (a = 0; a < this.channels; ++a) e[a] += t[s++] * f;\\n (c = s), (o -= f);\\n }\\n if (0 != o) {\\n for (this.lastWeight = o, a = 0; a < this.channels; ++a) this.lastOutput[a] = e[a];\\n this.tailExists = !0;\\n break;\\n }\\n for (a = 0; a < this.channels; ++a) l[h++] = e[a] / i;\\n } while (s < r && h < n);\\n return this.bufferSlice(h);\\n }\\n return this.noReturn ? 0 : [];\\n }\\n throw new Error('Buffer was of incorrect sample length.');\\n }),\\n (l.prototype.bypassResampler = function (t) {\\n return this.noReturn ? ((this.outputBuffer = t), t.length) : t;\\n }),\\n (l.prototype.bufferSlice = function (t) {\\n if (this.noReturn) return t;\\n try {\\n return this.outputBuffer.subarray(0, t);\\n } catch (e) {\\n try {\\n return (this.outputBuffer.length = t), this.outputBuffer;\\n } catch (e) {\\n return this.outputBuffer.slice(0, t);\\n }\\n }\\n }),\\n (l.prototype.initializeBuffers = function (t) {\\n this.outputBufferSize = Math.ceil((t * this.toSampleRate) / this.fromSampleRate);\\n try {\\n (this.outputBuffer = new Float32Array(this.outputBufferSize)),\\n (this.lastOutput = new Float32Array(this.channels));\\n } catch (t) {\\n (this.outputBuffer = []), (this.lastOutput = []);\\n }\\n });\\n var h = (function (e) {\\n !(function (t, e) {\\n if ('function' != typeof e && null !== e)\\n throw new TypeError('Super expression must either be null or a function');\\n (t.prototype = Object.create(e && e.prototype, {\\n constructor: { value: t, writable: !0, configurable: !0 },\\n })),\\n Object.defineProperty(t, 'prototype', { writable: !1 }),\\n e && r(t, e);\\n })(h, e);\\n var n,\\n i,\\n o,\\n u = s(h);\\n function h() {\\n var t;\\n !(function (t, e) {\\n if (!(t instanceof e)) throw new TypeError('Cannot call a class as a function');\\n })(this, h);\\n var e = a((t = u.call(this)));\\n return (\\n (t.port.onmessage = function (t) {\\n var r = t.data,\\n n = r.type,\\n i = r.data;\\n if ((console.log('type', n), 'init' === n)) {\\n var o = i.frameSize,\\n a = i.toSampleRate,\\n s = i.arrayBufferType,\\n f = i.fromSampleRate;\\n return (\\n (e.frameSize = o * Math.floor(f / a)),\\n (e.resampler = new l(f, a, 1)),\\n (e.frameBuffer = []),\\n void (e.arrayBufferType = s)\\n );\\n }\\n 'stop' === n &&\\n (e.port.postMessage({\\n frameBuffer: e.transData(e.frameBuffer),\\n isLastFrame: !0,\\n }),\\n (e.frameBuffer = []));\\n }),\\n t\\n );\\n }\\n return (\\n (n = h),\\n (i = [\\n {\\n key: 'process',\\n value: function (t) {\\n var e,\\n r = t[0][0];\\n if (!r) return true;\\n return this.frameSize\\n ? ((e = this.frameBuffer).push.apply(e, fn(r)),\\n this.frameBuffer.length >= this.frameSize &&\\n (this.port.postMessage({\\n frameBuffer: this.transData(this.frameBuffer),\\n isLastFrame: !1,\\n }),\\n (this.frameBuffer = [])),\\n !0)\\n : (r &&\\n this.port.postMessage({\\n frameBuffer: this.transData(r),\\n isLastFrame: !1,\\n }),\\n !0);\\n },\\n },\\n {\\n key: 'transData',\\n value: function (t) {\\n return (\\n 'short16' === this.arrayBufferType &&\\n (t = (function (t) {\\n for (\\n var e = new ArrayBuffer(2 * t.length), r = new DataView(e), n = 0, i = 0;\\n i < t.length;\\n i += 1, n += 2\\n ) {\\n var o = Math.max(-1, Math.min(1, t[i]));\\n r.setInt16(n, o < 0 ? 32768 * o : 32767 * o, !0);\\n }\\n return r.buffer;\\n })((t = this.resampler.resampler(t)))),\\n t\\n );\\n },\\n },\\n ]) && t(n.prototype, i),\\n o && t(n, o),\\n Object.defineProperty(n, 'prototype', { writable: !1 }),\\n h\\n );\\n })(o(AudioWorkletProcessor));\\n registerProcessor('processor-worklet', h);\\n})();\\n\""],"names":["workletJsString"],"mappings":"AAAA,MAAeA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { RecorderManager } from './RecorderManager';
|
|
2
|
+
import { RecordFrameInfo } from './types';
|
|
3
|
+
|
|
4
|
+
type errorType = 'socketConnect' | 'message' | 'record';
|
|
5
|
+
export interface XunFeiStreamVoiceManagerConfig {
|
|
6
|
+
onError: (errInfo: {
|
|
7
|
+
type: errorType;
|
|
8
|
+
message: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
/** ws 收到消息的回调
|
|
11
|
+
* @param info.message 消息内容
|
|
12
|
+
* @param info.isLatest 是否是最后一条消息。 isLatest 为 true 时, message 为完整的语音识别结果。
|
|
13
|
+
*/
|
|
14
|
+
onMessage: (info: {
|
|
15
|
+
message: string;
|
|
16
|
+
isLatest?: boolean;
|
|
17
|
+
}) => void;
|
|
18
|
+
/** webSocket 关闭的回调。
|
|
19
|
+
* 每次录音都会新建一个 webSocket 连接。录音结束后关闭 webSocket
|
|
20
|
+
*/
|
|
21
|
+
onWsClose: () => void;
|
|
22
|
+
/** 获取讯飞提供的 processor.worker.js 和 processor.worklet.js 的路径。
|
|
23
|
+
* 填写这两个文件的父路径就好。 如 a/b/processor.worker.js 则填写 a/b。
|
|
24
|
+
* 可以是oss地址,也可以是项目中的文件路径,智能通过url请求,能得到上面两个js文件即可。
|
|
25
|
+
* 目前已上传到 oss://{assetsBaseUrl}/announcement/easyvadmin/xun-fei-voice/ 目录下。
|
|
26
|
+
*/
|
|
27
|
+
processWorkJsPath: string;
|
|
28
|
+
/**
|
|
29
|
+
* 获取链接讯飞语音识别地址的 url
|
|
30
|
+
* @returns websocket url。详情查看讯飞文档里的鉴权方法:https://www.xfyun.cn/doc/asr/voicedictation/API.html#%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8%E6%B5%81%E7%A8%8B
|
|
31
|
+
*/
|
|
32
|
+
getWebSocketUrl?: () => string;
|
|
33
|
+
}
|
|
34
|
+
type SocketStatus = 'UNDEFINED' | 'CONNECTING' | 'OPEN' | 'CLOSING' | 'CLOSED';
|
|
35
|
+
/**
|
|
36
|
+
* 讯飞流式语音识别
|
|
37
|
+
*/
|
|
38
|
+
export declare class XunFeiStreamVoiceManager {
|
|
39
|
+
config: XunFeiStreamVoiceManagerConfig;
|
|
40
|
+
wsInstance: WebSocket | null;
|
|
41
|
+
status: SocketStatus;
|
|
42
|
+
recorder: RecorderManager | null;
|
|
43
|
+
isDestroy: boolean;
|
|
44
|
+
resultText: string;
|
|
45
|
+
resultTextTemp: string;
|
|
46
|
+
continueRecord: boolean;
|
|
47
|
+
startTimeStamp: number;
|
|
48
|
+
recordStatus: 'start' | 'stop';
|
|
49
|
+
readyToSend: boolean;
|
|
50
|
+
constructor(config: XunFeiStreamVoiceManagerConfig);
|
|
51
|
+
renderResult(resultData: string): void;
|
|
52
|
+
setConfig(newConfig: XunFeiStreamVoiceManagerConfig): void;
|
|
53
|
+
sendMessage(message: string): void;
|
|
54
|
+
recordConfigSend(): Promise<void>;
|
|
55
|
+
startNewSocket(): void;
|
|
56
|
+
recordProcess({ isLastFrame, frameBuffer }: RecordFrameInfo): void;
|
|
57
|
+
initializeRecorder(): void;
|
|
58
|
+
changeBtnStatus(status: SocketStatus): void;
|
|
59
|
+
startRecord(): void;
|
|
60
|
+
stopRecord(): Promise<void>;
|
|
61
|
+
/** 开启持续监听 */
|
|
62
|
+
startContinueRecord(): void;
|
|
63
|
+
stopContinueRecord(): void;
|
|
64
|
+
destroy(): void;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var S = Object.defineProperty;
|
|
2
|
+
var m = (i, t, e) => t in i ? S(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var o = (i, t, e) => m(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import d from "../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.es.js";
|
|
5
|
+
import { toBase64 as p } from "./utils.es.js";
|
|
6
|
+
import { RecorderManager as w } from "./RecorderManager/RecorderManager.es.js";
|
|
7
|
+
let u = 0;
|
|
8
|
+
const T = "93b73e33", y = "ZGJhMzQ5ZTJlMDgyYmE1ZTFlZDlmYjg0", I = "fe43de7a071e3a32ec03c6f09fe7bedf";
|
|
9
|
+
function R() {
|
|
10
|
+
const i = "wss://iat-api.xfyun.cn/v2/iat", t = "iat-api.xfyun.cn", e = I, s = y, r = (/* @__PURE__ */ new Date()).toUTCString(), n = "hmac-sha256", a = "host date request-line", h = `host: ${t}
|
|
11
|
+
date: ${r}
|
|
12
|
+
GET /v2/iat HTTP/1.1`, c = d.HmacSHA256(h, s), l = d.enc.Base64.stringify(c), g = `api_key="${e}", algorithm="${n}", headers="${a}", signature="${l}"`, f = window.btoa(g);
|
|
13
|
+
return `${i}?authorization=${f}&date=${r}&host=${t}`;
|
|
14
|
+
}
|
|
15
|
+
class C {
|
|
16
|
+
constructor(t) {
|
|
17
|
+
o(this, "wsInstance", null);
|
|
18
|
+
o(this, "status", "UNDEFINED");
|
|
19
|
+
o(this, "recorder", null);
|
|
20
|
+
o(this, "isDestroy", !1);
|
|
21
|
+
o(this, "resultText", "");
|
|
22
|
+
o(this, "resultTextTemp", "");
|
|
23
|
+
o(this, "continueRecord", !1);
|
|
24
|
+
o(this, "startTimeStamp", 0);
|
|
25
|
+
o(this, "recordStatus", "stop");
|
|
26
|
+
o(this, "readyToSend", !1);
|
|
27
|
+
this.config = t, this.initializeRecorder();
|
|
28
|
+
}
|
|
29
|
+
renderResult(t) {
|
|
30
|
+
var s, r;
|
|
31
|
+
const e = JSON.parse(t);
|
|
32
|
+
if (e.data && e.data.result) {
|
|
33
|
+
const n = e.data.result;
|
|
34
|
+
let a = "";
|
|
35
|
+
const h = n.ws;
|
|
36
|
+
for (let c = 0; c < h.length; c++)
|
|
37
|
+
a = a + h[c].cw[0].w;
|
|
38
|
+
n.pgs ? (n.pgs === "apd" && (this.resultText = this.resultTextTemp), this.resultTextTemp = this.resultText + a) : this.resultText = this.resultText + a;
|
|
39
|
+
}
|
|
40
|
+
if (e.code === 0 && e.data.status === 2) {
|
|
41
|
+
this.config.onMessage({ message: this.resultText, isLatest: !0 }), (s = this.wsInstance) == null || s.close();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
e.code === 0 && e.data.status === 1 && this.config.onMessage({ message: this.resultText, isLatest: !1 }), e.code !== 0 && ((r = this.wsInstance) == null || r.close(), this.config.onError({ type: "message", message: t }));
|
|
45
|
+
}
|
|
46
|
+
setConfig(t) {
|
|
47
|
+
this.config = {
|
|
48
|
+
...this.config,
|
|
49
|
+
...t
|
|
50
|
+
}, this.initializeRecorder();
|
|
51
|
+
}
|
|
52
|
+
sendMessage(t) {
|
|
53
|
+
var e;
|
|
54
|
+
((e = this.wsInstance) == null ? void 0 : e.readyState) === WebSocket.OPEN && this.readyToSend && this.wsInstance.send(t);
|
|
55
|
+
}
|
|
56
|
+
async recordConfigSend() {
|
|
57
|
+
var t;
|
|
58
|
+
if (!this.isDestroy)
|
|
59
|
+
try {
|
|
60
|
+
await ((t = this.recorder) == null ? void 0 : t.start({
|
|
61
|
+
sampleRate: 16e3,
|
|
62
|
+
frameSize: 1280
|
|
63
|
+
}));
|
|
64
|
+
const e = {
|
|
65
|
+
common: {
|
|
66
|
+
app_id: T
|
|
67
|
+
},
|
|
68
|
+
business: {
|
|
69
|
+
language: "zh_cn",
|
|
70
|
+
domain: "iat",
|
|
71
|
+
accent: "mandarin",
|
|
72
|
+
vad_eos: 5e3,
|
|
73
|
+
dwa: "wpgs"
|
|
74
|
+
},
|
|
75
|
+
data: {
|
|
76
|
+
status: 0,
|
|
77
|
+
format: "audio/L16;rate=16000",
|
|
78
|
+
encoding: "raw"
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this.readyToSend = !0, this.sendMessage(JSON.stringify(e));
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error("record error:", e), this.config.onError({ type: "record", message: "录音失败, 请检查权限!" });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
startNewSocket() {
|
|
87
|
+
var e, s;
|
|
88
|
+
console.log(
|
|
89
|
+
"%c ❤️ love ==== start new socket ",
|
|
90
|
+
"color: red; font-size: 16px;",
|
|
91
|
+
u,
|
|
92
|
+
(/* @__PURE__ */ new Date()).toUTCString()
|
|
93
|
+
), u++;
|
|
94
|
+
const t = ((s = (e = this.config).getWebSocketUrl) == null ? void 0 : s.call(e)) || R();
|
|
95
|
+
if ("WebSocket" in window)
|
|
96
|
+
this.wsInstance = new WebSocket(t);
|
|
97
|
+
else {
|
|
98
|
+
this.config.onError({ type: "socketConnect", message: "浏览器不支持 WebSocket" });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.wsInstance.onmessage = (r) => {
|
|
102
|
+
this.renderResult(r.data);
|
|
103
|
+
}, this.wsInstance.onerror = (r) => {
|
|
104
|
+
console.error("socket error:", r), this.changeBtnStatus("CLOSED");
|
|
105
|
+
}, this.wsInstance.onclose = async () => {
|
|
106
|
+
var r, n;
|
|
107
|
+
this.changeBtnStatus("CLOSED"), this.config.onWsClose(), (r = this.recorder) == null || r.stop(), this.continueRecord && (this.readyToSend = !1, await ((n = this.recorder) == null ? void 0 : n.close()), this.startRecord());
|
|
108
|
+
}, this.wsInstance.onopen = () => {
|
|
109
|
+
this.changeBtnStatus("OPEN"), this.recordConfigSend();
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
recordProcess({ isLastFrame: t, frameBuffer: e }) {
|
|
113
|
+
this.isDestroy || this.wsInstance && (this.wsInstance.readyState === this.wsInstance.OPEN && this.sendMessage(
|
|
114
|
+
JSON.stringify({
|
|
115
|
+
data: {
|
|
116
|
+
status: t ? 2 : 1,
|
|
117
|
+
format: "audio/L16;rate=16000",
|
|
118
|
+
encoding: "raw",
|
|
119
|
+
audio: p(e)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
), t && (this.readyToSend = !1, this.changeBtnStatus("CLOSING")));
|
|
123
|
+
}
|
|
124
|
+
initializeRecorder() {
|
|
125
|
+
this.recorder = new w(this.config.processWorkJsPath), this.recorder && (this.recorder.onFrameRecorded = (t) => {
|
|
126
|
+
this.recordProcess(t);
|
|
127
|
+
}, this.recorder.onStop = (t) => {
|
|
128
|
+
}, this.recorder.onStart = () => {
|
|
129
|
+
console.log("%c ❤️ love ==== recorder onStart:", "color: red; font-size: 16px;"), this.changeBtnStatus("OPEN");
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
changeBtnStatus(t) {
|
|
133
|
+
this.status = t;
|
|
134
|
+
}
|
|
135
|
+
startRecord() {
|
|
136
|
+
this.isDestroy || (this.startTimeStamp = Date.now(), this.resultText = "", this.resultTextTemp = "", this.startNewSocket());
|
|
137
|
+
}
|
|
138
|
+
async stopRecord() {
|
|
139
|
+
var t;
|
|
140
|
+
console.log("stop record ====", Date.now() - this.startTimeStamp), Date.now() - this.startTimeStamp < 500 ? setTimeout(() => {
|
|
141
|
+
var e;
|
|
142
|
+
(e = this.recorder) == null || e.stop();
|
|
143
|
+
}, 100) : (t = this.recorder) == null || t.stop(), setTimeout(() => {
|
|
144
|
+
var e, s;
|
|
145
|
+
((e = this.wsInstance) == null ? void 0 : e.readyState) === WebSocket.OPEN && ((s = this.wsInstance) == null || s.close());
|
|
146
|
+
}, 5e3);
|
|
147
|
+
}
|
|
148
|
+
/** 开启持续监听 */
|
|
149
|
+
startContinueRecord() {
|
|
150
|
+
this.continueRecord = !0, this.startRecord();
|
|
151
|
+
}
|
|
152
|
+
stopContinueRecord() {
|
|
153
|
+
this.continueRecord = !1, this.stopRecord();
|
|
154
|
+
}
|
|
155
|
+
destroy() {
|
|
156
|
+
this.isDestroy = !0, setTimeout(() => {
|
|
157
|
+
var t, e, s;
|
|
158
|
+
((t = this.wsInstance) == null ? void 0 : t.readyState) === WebSocket.OPEN && ((e = this.wsInstance) == null || e.close()), (s = this.recorder) == null || s.stop();
|
|
159
|
+
}, 1e3);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
C as XunFeiStreamVoiceManager
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=XunFeiStreamVoiceManager.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XunFeiStreamVoiceManager.es.js","sources":["../../../src/utils/xunFeiVoice/XunFeiStreamVoiceManager.ts"],"sourcesContent":["import CryptoJS from 'crypto-js';\nimport { RecorderManager } from './RecorderManager';\nimport type { RecordFrameInfo } from './types';\nimport { toBase64 } from './utils';\n\ntype errorType = 'socketConnect' | 'message' | 'record';\nlet startCount = 0;\n\nexport interface XunFeiStreamVoiceManagerConfig {\n onError: (errInfo: { type: errorType; message: string }) => void;\n /** ws 收到消息的回调\n * @param info.message 消息内容\n * @param info.isLatest 是否是最后一条消息。 isLatest 为 true 时, message 为完整的语音识别结果。\n */\n onMessage: (info: { message: string; isLatest?: boolean }) => void;\n /** webSocket 关闭的回调。\n * 每次录音都会新建一个 webSocket 连接。录音结束后关闭 webSocket\n */\n onWsClose: () => void;\n /** 获取讯飞提供的 processor.worker.js 和 processor.worklet.js 的路径。\n * 填写这两个文件的父路径就好。 如 a/b/processor.worker.js 则填写 a/b。\n * 可以是oss地址,也可以是项目中的文件路径,智能通过url请求,能得到上面两个js文件即可。\n * 目前已上传到 oss://{assetsBaseUrl}/announcement/easyvadmin/xun-fei-voice/ 目录下。\n */\n processWorkJsPath: string;\n // 获取 websocket url 的方法\n /**\n * 获取链接讯飞语音识别地址的 url\n * @returns websocket url。详情查看讯飞文档里的鉴权方法:https://www.xfyun.cn/doc/asr/voicedictation/API.html#%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8%E6%B5%81%E7%A8%8B\n */\n getWebSocketUrl?: () => string;\n}\ntype SocketStatus = 'UNDEFINED' | 'CONNECTING' | 'OPEN' | 'CLOSING' | 'CLOSED';\n\n/** 现在前端mock,后续移到接口下发 */\nconst APPID = '93b73e33';\nconst API_SECRET = 'ZGJhMzQ5ZTJlMDgyYmE1ZTFlZDlmYjg0';\nconst API_KEY = 'fe43de7a071e3a32ec03c6f09fe7bedf';\n/**\n * 获取websocket url\n * 该接口需要后端提供,这里为了方便前端处理\n */\nfunction getWebSocketUrl() {\n // 请求地址根据语种不同变化\n const url = 'wss://iat-api.xfyun.cn/v2/iat';\n const host = 'iat-api.xfyun.cn';\n const apiKey = API_KEY;\n const apiSecret = API_SECRET;\n const date = new Date().toUTCString();\n const algorithm = 'hmac-sha256';\n const headers = 'host date request-line';\n const signatureOrigin = `host: ${host}\\ndate: ${date}\\nGET /v2/iat HTTP/1.1`;\n const signatureSha = CryptoJS.HmacSHA256(signatureOrigin, apiSecret);\n const signature = CryptoJS.enc.Base64.stringify(signatureSha);\n const authorizationOrigin = `api_key=\"${apiKey}\", algorithm=\"${algorithm}\", headers=\"${headers}\", signature=\"${signature}\"`;\n const authorization = window.btoa(authorizationOrigin);\n return `${url}?authorization=${authorization}&date=${date}&host=${host}`;\n}\n\n/**\n * 讯飞流式语音识别\n */\nexport class XunFeiStreamVoiceManager {\n wsInstance: WebSocket | null = null;\n status: SocketStatus = 'UNDEFINED';\n recorder: RecorderManager | null = null;\n isDestroy = false;\n resultText = '';\n resultTextTemp = '';\n continueRecord = false;\n startTimeStamp = 0;\n recordStatus: 'start' | 'stop' = 'stop';\n readyToSend = false;\n\n constructor(public config: XunFeiStreamVoiceManagerConfig) {\n this.initializeRecorder();\n }\n renderResult(resultData: string) {\n // 识别结束\n const jsonData = JSON.parse(resultData);\n if (jsonData.data && jsonData.data.result) {\n const data = jsonData.data.result;\n let str = '';\n const ws = data.ws;\n for (let i = 0; i < ws.length; i++) {\n str = str + ws[i].cw[0].w;\n }\n // 开启 wpgs 会有此字段(前提:在控制台开通动态修正功能)\n // 取值为 \"apd\"时表示该片结果是追加到前面的最终结果;取值为\"rpl\" 时表示替换前面的部分结果,替换范围为rg字段\n if (data.pgs) {\n if (data.pgs === 'apd') {\n // 将resultTextTemp同步给resultText\n this.resultText = this.resultTextTemp;\n }\n // 将结果存储在resultTextTemp中\n this.resultTextTemp = this.resultText + str;\n } else {\n this.resultText = this.resultText + str;\n }\n }\n /**\n * 识别结果是否结束标识:\n * 0:识别的第一块结果。\n * 1:识别中间结果。\n * 2:识别最后一块结果\n */\n if (jsonData.code === 0 && jsonData.data.status === 2) {\n this.config.onMessage({ message: this.resultText, isLatest: true });\n this.wsInstance?.close();\n return;\n }\n if (jsonData.code === 0 && jsonData.data.status === 1) {\n this.config.onMessage({ message: this.resultText, isLatest: false });\n }\n // code 不为0时表示出错\n if (jsonData.code !== 0) {\n this.wsInstance?.close();\n this.config.onError({ type: 'message', message: resultData });\n }\n }\n\n setConfig(newConfig: XunFeiStreamVoiceManagerConfig) {\n this.config = {\n ...this.config,\n ...newConfig,\n };\n this.initializeRecorder();\n }\n sendMessage(message: string) {\n if (this.wsInstance?.readyState === WebSocket.OPEN && this.readyToSend) {\n this.wsInstance.send(message);\n }\n }\n\n async recordConfigSend() {\n if (this.isDestroy) {\n return;\n }\n try {\n // 开始录音\n await this.recorder?.start({\n sampleRate: 16000,\n frameSize: 1280,\n });\n const params = {\n common: {\n app_id: APPID,\n },\n business: {\n language: 'zh_cn',\n domain: 'iat',\n accent: 'mandarin',\n vad_eos: 5000,\n dwa: 'wpgs',\n },\n data: {\n status: 0,\n format: 'audio/L16;rate=16000',\n encoding: 'raw',\n },\n };\n this.readyToSend = true;\n this.sendMessage(JSON.stringify(params));\n } catch (error) {\n console.error('record error:', error);\n this.config.onError({ type: 'record', message: '录音失败, 请检查权限!' });\n }\n }\n\n startNewSocket() {\n console.log(\n '%c ❤️ love ==== start new socket ',\n 'color: red; font-size: 16px;',\n startCount,\n new Date().toUTCString(),\n );\n startCount++;\n const websocketUrl = this.config.getWebSocketUrl?.() || getWebSocketUrl();\n if ('WebSocket' in window) {\n this.wsInstance = new WebSocket(websocketUrl);\n } else {\n this.config.onError({ type: 'socketConnect', message: '浏览器不支持 WebSocket' });\n return;\n }\n this.wsInstance.onmessage = (e) => {\n // 处理返回数据\n this.renderResult(e.data);\n };\n this.wsInstance.onerror = (e) => {\n console.error('socket error:', e);\n this.changeBtnStatus('CLOSED');\n };\n this.wsInstance.onclose = async () => {\n this.changeBtnStatus('CLOSED');\n this.config.onWsClose();\n this.recorder?.stop();\n if (this.continueRecord) {\n this.readyToSend = false;\n await this.recorder?.close();\n this.startRecord();\n }\n };\n this.wsInstance.onopen = () => {\n this.changeBtnStatus('OPEN');\n this.recordConfigSend();\n };\n }\n\n recordProcess({ isLastFrame, frameBuffer }: RecordFrameInfo) {\n if (this.isDestroy) {\n return;\n }\n if (!this.wsInstance) {\n return;\n }\n if (this.wsInstance.readyState === this.wsInstance.OPEN) {\n this.sendMessage(\n JSON.stringify({\n data: {\n status: isLastFrame ? 2 : 1,\n format: 'audio/L16;rate=16000',\n encoding: 'raw',\n audio: toBase64(frameBuffer),\n },\n }),\n );\n }\n if (isLastFrame) {\n this.readyToSend = false;\n this.changeBtnStatus('CLOSING');\n }\n }\n\n initializeRecorder() {\n this.recorder = new RecorderManager(this.config.processWorkJsPath);\n if (!this.recorder) {\n return;\n }\n this.recorder.onFrameRecorded = (data: RecordFrameInfo) => {\n this.recordProcess(data);\n };\n this.recorder.onStop = (_data: ArrayBuffer[]) => {\n // do nothing\n };\n this.recorder.onStart = () => {\n console.log('%c ❤️ love ==== recorder onStart:', 'color: red; font-size: 16px;');\n this.changeBtnStatus('OPEN');\n };\n }\n\n changeBtnStatus(status: SocketStatus) {\n this.status = status;\n }\n\n startRecord() {\n if (this.isDestroy) {\n return;\n }\n this.startTimeStamp = Date.now();\n this.resultText = '';\n this.resultTextTemp = '';\n this.startNewSocket();\n }\n\n async stopRecord() {\n console.log('stop record ====', Date.now() - this.startTimeStamp);\n // 结束录音,为了防止刚开始就关闭\n if (Date.now() - this.startTimeStamp < 500) {\n setTimeout(() => {\n this.recorder?.stop();\n }, 100);\n } else {\n this.recorder?.stop();\n }\n // 这里为了防止ws没有返回结束的数据,导致 ws 一直没关,所以加个定时器,5s 后手动关闭\n setTimeout(() => {\n if (this.wsInstance?.readyState === WebSocket.OPEN) {\n this.wsInstance?.close();\n }\n }, 5000);\n }\n\n /** 开启持续监听 */\n startContinueRecord() {\n this.continueRecord = true;\n this.startRecord();\n }\n\n stopContinueRecord() {\n this.continueRecord = false;\n this.stopRecord();\n }\n\n destroy() {\n this.isDestroy = true;\n setTimeout(() => {\n if (this.wsInstance?.readyState === WebSocket.OPEN) {\n this.wsInstance?.close();\n }\n this.recorder?.stop();\n }, 1000);\n }\n}\n"],"names":["startCount","APPID","API_SECRET","API_KEY","getWebSocketUrl","url","host","apiKey","apiSecret","date","algorithm","headers","signatureOrigin","signatureSha","CryptoJS","signature","authorizationOrigin","authorization","XunFeiStreamVoiceManager","config","__publicField","resultData","jsonData","data","str","ws","i","_a","_b","newConfig","message","params","error","websocketUrl","e","isLastFrame","frameBuffer","toBase64","RecorderManager","_data","status","_c"],"mappings":";;;;;;AAMA,IAAIA,IAAa;AA6BjB,MAAMC,IAAQ,YACRC,IAAa,oCACbC,IAAU;AAKhB,SAASC,IAAkB;AAEzB,QAAMC,IAAM,iCACNC,IAAO,oBACPC,IAASJ,GACTK,IAAYN,GACZO,KAAO,oBAAI,KAAK,GAAE,YAAY,GAC9BC,IAAY,eACZC,IAAU,0BACVC,IAAkB,SAASN,CAAI;AAAA,QAAWG,CAAI;AAAA,uBAC9CI,IAAeC,EAAS,WAAWF,GAAiBJ,CAAS,GAC7DO,IAAYD,EAAS,IAAI,OAAO,UAAUD,CAAY,GACtDG,IAAsB,YAAYT,CAAM,iBAAiBG,CAAS,eAAeC,CAAO,iBAAiBI,CAAS,KAClHE,IAAgB,OAAO,KAAKD,CAAmB;AACrD,SAAO,GAAGX,CAAG,kBAAkBY,CAAa,SAASR,CAAI,SAASH,CAAI;AACxE;AAKO,MAAMY,EAAyB;AAAA,EAYpC,YAAmBC,GAAwC;AAX3D,IAAAC,EAAA,oBAA+B;AAC/B,IAAAA,EAAA,gBAAuB;AACvB,IAAAA,EAAA,kBAAmC;AACnC,IAAAA,EAAA,mBAAY;AACZ,IAAAA,EAAA,oBAAa;AACb,IAAAA,EAAA,wBAAiB;AACjB,IAAAA,EAAA,wBAAiB;AACjB,IAAAA,EAAA,wBAAiB;AACjB,IAAAA,EAAA,sBAAiC;AACjC,IAAAA,EAAA,qBAAc;AAEK,SAAA,SAAAD,GACjB,KAAK,mBAAmB;AAAA,EAAA;AAAA,EAE1B,aAAaE,GAAoB;;AAEzB,UAAAC,IAAW,KAAK,MAAMD,CAAU;AACtC,QAAIC,EAAS,QAAQA,EA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