ruiyun-human 1.0.1

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.
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
2
+ <rect width="100" height="100" rx="20" fill="#42b883"/>
3
+ <text y=".9em" font-size="90" fill="white" text-anchor="middle" x="50">V</text>
4
+ </svg>
Binary file
Binary file
@@ -0,0 +1,892 @@
1
+ import { openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode, createElementVNode, ref, watch, onMounted, onUnmounted, nextTick } from "vue";
2
+ const _export_sfc = (sfc, props) => {
3
+ const target = sfc.__vccOpts || sfc;
4
+ for (const [key, val] of props) {
5
+ target[key] = val;
6
+ }
7
+ return target;
8
+ };
9
+ const _sfc_main$2 = {
10
+ __name: "index",
11
+ props: {
12
+ type: {
13
+ type: String,
14
+ default: "primary"
15
+ }
16
+ },
17
+ emits: ["click"],
18
+ setup(__props) {
19
+ return (_ctx, _cache) => {
20
+ return openBlock(), createElementBlock("button", {
21
+ class: normalizeClass(["demo-btn", __props.type]),
22
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click"))
23
+ }, [
24
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
25
+ ], 2);
26
+ };
27
+ }
28
+ };
29
+ const DemoButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-9a48516a"]]);
30
+ DemoButton.install = (app) => app.component("DemoButton", DemoButton);
31
+ const _hoisted_1 = { class: "demo-input-wrap" };
32
+ const _hoisted_2 = {
33
+ key: 0,
34
+ class: "prefix"
35
+ };
36
+ const _hoisted_3 = ["type", "placeholder", "value", "disabled"];
37
+ const _hoisted_4 = {
38
+ key: 1,
39
+ class: "suffix"
40
+ };
41
+ const _sfc_main$1 = {
42
+ __name: "index",
43
+ props: {
44
+ modelValue: {
45
+ type: [String, Number],
46
+ default: ""
47
+ },
48
+ placeholder: {
49
+ type: String,
50
+ default: "请输入内容"
51
+ },
52
+ inputType: {
53
+ type: String,
54
+ default: "text"
55
+ },
56
+ disabled: {
57
+ type: Boolean,
58
+ default: false
59
+ }
60
+ },
61
+ emits: ["update:modelValue", "focus", "blur"],
62
+ setup(__props, { emit: __emit }) {
63
+ const emit = __emit;
64
+ const handleInput = (e) => emit("update:modelValue", e.target.value);
65
+ return (_ctx, _cache) => {
66
+ return openBlock(), createElementBlock("div", _hoisted_1, [
67
+ _ctx.$slots.prefix ? (openBlock(), createElementBlock("span", _hoisted_2, [
68
+ renderSlot(_ctx.$slots, "prefix", {}, void 0, true)
69
+ ])) : createCommentVNode("", true),
70
+ createElementVNode("input", {
71
+ class: "demo-input",
72
+ type: __props.inputType,
73
+ placeholder: __props.placeholder,
74
+ value: __props.modelValue,
75
+ disabled: __props.disabled,
76
+ onInput: handleInput,
77
+ onFocus: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("focus")),
78
+ onBlur: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("blur"))
79
+ }, null, 40, _hoisted_3),
80
+ _ctx.$slots.suffix ? (openBlock(), createElementBlock("span", _hoisted_4, [
81
+ renderSlot(_ctx.$slots, "suffix", {}, void 0, true)
82
+ ])) : createCommentVNode("", true)
83
+ ]);
84
+ };
85
+ }
86
+ };
87
+ const DemoInput = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-28a3493c"]]);
88
+ DemoInput.install = (app) => app.component("DemoInput", DemoInput);
89
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
90
+ function getDefaultExportFromCjs(x) {
91
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
92
+ }
93
+ var recorder = { exports: {} };
94
+ /*!
95
+ *
96
+ * js-audio-recorder - js audio recorder plugin
97
+ *
98
+ * @version v1.0.7
99
+ * @homepage https://github.com/2fps/recorder
100
+ * @author 2fps <echoweb@126.com> (https://www.zhuyuntao.cn)
101
+ * @license MIT
102
+ *
103
+ */
104
+ (function(module, exports) {
105
+ !function(t, e) {
106
+ module.exports = e();
107
+ }(commonjsGlobal, function() {
108
+ return function(t) {
109
+ var e = {};
110
+ function n(i) {
111
+ if (e[i]) return e[i].exports;
112
+ var o = e[i] = { i, l: false, exports: {} };
113
+ return t[i].call(o.exports, o, o.exports, n), o.l = true, o.exports;
114
+ }
115
+ return n.m = t, n.c = e, n.d = function(t2, e2, i) {
116
+ n.o(t2, e2) || Object.defineProperty(t2, e2, { enumerable: true, get: i });
117
+ }, n.r = function(t2) {
118
+ "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true });
119
+ }, n.t = function(t2, e2) {
120
+ if (1 & e2 && (t2 = n(t2)), 8 & e2) return t2;
121
+ if (4 & e2 && "object" == typeof t2 && t2 && t2.__esModule) return t2;
122
+ var i = /* @__PURE__ */ Object.create(null);
123
+ if (n.r(i), Object.defineProperty(i, "default", { enumerable: true, value: t2 }), 2 & e2 && "string" != typeof t2) for (var o in t2) n.d(i, o, (function(e3) {
124
+ return t2[e3];
125
+ }).bind(null, o));
126
+ return i;
127
+ }, n.n = function(t2) {
128
+ var e2 = t2 && t2.__esModule ? function() {
129
+ return t2.default;
130
+ } : function() {
131
+ return t2;
132
+ };
133
+ return n.d(e2, "a", e2), e2;
134
+ }, n.o = function(t2, e2) {
135
+ return Object.prototype.hasOwnProperty.call(t2, e2);
136
+ }, n.p = "", n(n.s = 1);
137
+ }([function(t, e, n) {
138
+ function i(t2, e2, n2) {
139
+ for (var i2 = 0; i2 < n2.length; i2++) t2.setUint8(e2 + i2, n2.charCodeAt(i2));
140
+ }
141
+ Object.defineProperty(e, "__esModule", { value: true }), e.compress = function(t2, e2, n2) {
142
+ for (var i2 = e2 / n2, o = Math.max(i2, 1), r = t2.left, a = t2.right, s = Math.floor((r.length + a.length) / i2), u = new Float32Array(s), c = 0, l = 0; c < s; ) {
143
+ var f = Math.floor(l);
144
+ u[c] = r[f], c++, a.length && (u[c] = a[f], c++), l += o;
145
+ }
146
+ return u;
147
+ }, e.encodePCM = function(t2, e2, n2) {
148
+ void 0 === n2 && (n2 = true);
149
+ var i2 = 0, o = t2.length * (e2 / 8), r = new ArrayBuffer(o), a = new DataView(r);
150
+ if (8 === e2) for (var s = 0; s < t2.length; s++, i2++) {
151
+ var u = (c = Math.max(-1, Math.min(1, t2[s]))) < 0 ? 128 * c : 127 * c;
152
+ u = +u + 128, a.setInt8(i2, u);
153
+ }
154
+ else for (s = 0; s < t2.length; s++, i2 += 2) {
155
+ var c = Math.max(-1, Math.min(1, t2[s]));
156
+ a.setInt16(i2, c < 0 ? 32768 * c : 32767 * c, n2);
157
+ }
158
+ return a;
159
+ }, e.encodeWAV = function(t2, e2, n2, o, r, a) {
160
+ void 0 === a && (a = true);
161
+ var s = n2 > e2 ? e2 : n2, u = r, c = new ArrayBuffer(44 + t2.byteLength), l = new DataView(c), f = o, p = 0;
162
+ i(l, p, "RIFF"), p += 4, l.setUint32(p, 36 + t2.byteLength, a), i(l, p += 4, "WAVE"), i(l, p += 4, "fmt "), p += 4, l.setUint32(p, 16, a), p += 4, l.setUint16(p, 1, a), p += 2, l.setUint16(p, f, a), p += 2, l.setUint32(p, s, a), p += 4, l.setUint32(p, f * s * (u / 8), a), p += 4, l.setUint16(p, f * (u / 8), a), p += 2, l.setUint16(p, u, a), i(l, p += 2, "data"), p += 4, l.setUint32(p, t2.byteLength, a), p += 4;
163
+ for (var d = 0; d < t2.byteLength; ) l.setUint8(p, t2.getUint8(d)), p++, d++;
164
+ return l;
165
+ };
166
+ }, function(t, e, n) {
167
+ var i, o = this && this.__extends || (i = function(t2, e2) {
168
+ return (i = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t3, e3) {
169
+ t3.__proto__ = e3;
170
+ } || function(t3, e3) {
171
+ for (var n2 in e3) e3.hasOwnProperty(n2) && (t3[n2] = e3[n2]);
172
+ })(t2, e2);
173
+ }, function(t2, e2) {
174
+ function n2() {
175
+ this.constructor = t2;
176
+ }
177
+ i(t2, e2), t2.prototype = null === e2 ? Object.create(e2) : (n2.prototype = e2.prototype, new n2());
178
+ });
179
+ Object.defineProperty(e, "__esModule", { value: true });
180
+ var r = n(2), a = n(0), s = n(3), u = function(t2) {
181
+ function e2(e3) {
182
+ void 0 === e3 && (e3 = {});
183
+ var n2 = t2.call(this, e3) || this;
184
+ return n2.isrecording = false, n2.ispause = false, n2.isplaying = false, n2;
185
+ }
186
+ return o(e2, t2), e2.prototype.setOption = function(t3) {
187
+ void 0 === t3 && (t3 = {}), this.setNewOption(t3);
188
+ }, e2.prototype.start = function() {
189
+ return this.isrecording ? Promise.reject() : (this.isrecording = true, this.startRecord());
190
+ }, e2.prototype.pause = function() {
191
+ this.isrecording && !this.ispause && (this.ispause = true, this.pauseRecord());
192
+ }, e2.prototype.resume = function() {
193
+ this.isrecording && this.ispause && (this.ispause = false, this.resumeRecord());
194
+ }, e2.prototype.stop = function() {
195
+ this.isrecording && (this.isrecording = false, this.ispause = false, this.stopRecord());
196
+ }, e2.prototype.play = function() {
197
+ this.stop(), this.isplaying = true, this.onplay && this.onplay(), s.default.addPlayEnd(this.onplayend);
198
+ var t3 = this.getWAV();
199
+ t3.byteLength > 44 && s.default.play(t3.buffer);
200
+ }, e2.prototype.getPlayTime = function() {
201
+ return s.default.getPlayTime();
202
+ }, e2.prototype.pausePlay = function() {
203
+ !this.isrecording && this.isplaying && (this.isplaying = false, this.onpauseplay && this.onpauseplay(), s.default.pausePlay());
204
+ }, e2.prototype.resumePlay = function() {
205
+ this.isrecording || this.isplaying || (this.isplaying = true, this.onresumeplay && this.onresumeplay(), s.default.resumePlay());
206
+ }, e2.prototype.stopPlay = function() {
207
+ this.isrecording || (this.isplaying = false, this.onstopplay && this.onstopplay(), s.default.stopPlay());
208
+ }, e2.prototype.destroy = function() {
209
+ return s.default.destroyPlay(), this.destroyRecord();
210
+ }, e2.prototype.getRecordAnalyseData = function() {
211
+ return this.getAnalyseData();
212
+ }, e2.prototype.getPlayAnalyseData = function() {
213
+ return s.default.getAnalyseData();
214
+ }, e2.prototype.getPCM = function() {
215
+ this.stop();
216
+ var t3 = this.getData();
217
+ return t3 = a.compress(t3, this.inputSampleRate, this.outputSampleRate), a.encodePCM(t3, this.oututSampleBits, this.littleEdian);
218
+ }, e2.prototype.getPCMBlob = function() {
219
+ return new Blob([this.getPCM()]);
220
+ }, e2.prototype.downloadPCM = function(t3) {
221
+ void 0 === t3 && (t3 = "recorder");
222
+ var e3 = this.getPCMBlob();
223
+ r.downloadPCM(e3, t3);
224
+ }, e2.prototype.getWAV = function() {
225
+ var t3 = this.getPCM();
226
+ return a.encodeWAV(t3, this.inputSampleRate, this.outputSampleRate, this.config.numChannels, this.oututSampleBits, this.littleEdian);
227
+ }, e2.prototype.getWAVBlob = function() {
228
+ return new Blob([this.getWAV()], { type: "audio/wav" });
229
+ }, e2.prototype.downloadWAV = function(t3) {
230
+ void 0 === t3 && (t3 = "recorder");
231
+ var e3 = this.getWAVBlob();
232
+ r.downloadWAV(e3, t3);
233
+ }, e2.prototype.download = function(t3, e3, n2) {
234
+ r.download(t3, e3, n2);
235
+ }, e2.prototype.getChannelData = function() {
236
+ var t3 = this.getPCM(), e3 = t3.byteLength, n2 = this.littleEdian, i2 = { left: null, right: null };
237
+ if (2 === this.config.numChannels) {
238
+ var o2 = new DataView(new ArrayBuffer(e3 / 2)), r2 = new DataView(new ArrayBuffer(e3 / 2));
239
+ if (16 === this.config.sampleBits) for (var a2 = 0; a2 < e3 / 2; a2 += 2) o2.setInt16(a2, t3.getInt16(2 * a2, n2), n2), r2.setInt16(a2, t3.getInt16(2 * a2 + 2, n2), n2);
240
+ else for (a2 = 0; a2 < e3 / 2; a2 += 2) o2.setInt8(a2, t3.getInt8(2 * a2)), r2.setInt8(a2, t3.getInt8(2 * a2 + 1));
241
+ i2.left = o2, i2.right = r2;
242
+ } else i2.left = t3;
243
+ return i2;
244
+ }, e2;
245
+ }(n(5).default);
246
+ e.default = u;
247
+ }, function(t, e, n) {
248
+ function i(t2, e2, n2) {
249
+ var i2 = document.createElement("a");
250
+ i2.href = window.URL.createObjectURL(t2), i2.download = e2 + "." + n2, i2.click();
251
+ }
252
+ Object.defineProperty(e, "__esModule", { value: true }), e.downloadWAV = function(t2, e2) {
253
+ void 0 === e2 && (e2 = "recorder"), i(t2, e2, "wav");
254
+ }, e.downloadPCM = function(t2, e2) {
255
+ void 0 === e2 && (e2 = "recorder"), i(t2, e2, "pcm");
256
+ }, e.download = function(t2, e2, n2) {
257
+ return i(t2, e2, n2);
258
+ };
259
+ }, function(t, e, n) {
260
+ Object.defineProperty(e, "__esModule", { value: true });
261
+ var i = n(4), o = null, r = 0, a = 0, s = null, u = null, c = null, l = false, f = 0, p = function() {
262
+ };
263
+ function d() {
264
+ return l = false, s.decodeAudioData(c.slice(0), function(t2) {
265
+ (o = s.createBufferSource()).onended = function() {
266
+ l || (f = s.currentTime - a + r, p());
267
+ }, o.buffer = t2, o.connect(u), u.connect(s.destination), o.start(0, r), a = s.currentTime;
268
+ }, function(t2) {
269
+ i.throwError(t2);
270
+ });
271
+ }
272
+ function h() {
273
+ o && (o.stop(), o = null);
274
+ }
275
+ var y = function() {
276
+ function t2() {
277
+ }
278
+ return t2.play = function(t3) {
279
+ return s || (s = new (window.AudioContext || window.webkitAudioContext)(), (u = s.createAnalyser()).fftSize = 2048), this.stopPlay(), c = t3, f = 0, d();
280
+ }, t2.pausePlay = function() {
281
+ h(), r += s.currentTime - a, l = true;
282
+ }, t2.resumePlay = function() {
283
+ return d();
284
+ }, t2.stopPlay = function() {
285
+ r = 0, c = null, h();
286
+ }, t2.destroyPlay = function() {
287
+ this.stopPlay();
288
+ }, t2.getAnalyseData = function() {
289
+ var t3 = new Uint8Array(u.frequencyBinCount);
290
+ return u.getByteTimeDomainData(t3), t3;
291
+ }, t2.addPlayEnd = function(t3) {
292
+ void 0 === t3 && (t3 = function() {
293
+ }), p = t3;
294
+ }, t2.getPlayTime = function() {
295
+ var t3 = l ? r : s.currentTime - a + r;
296
+ return f || t3;
297
+ }, t2;
298
+ }();
299
+ e.default = y;
300
+ }, function(t, e, n) {
301
+ Object.defineProperty(e, "__esModule", { value: true }), e.throwError = function(t2) {
302
+ throw new Error(t2);
303
+ };
304
+ }, function(t, e, n) {
305
+ Object.defineProperty(e, "__esModule", { value: true });
306
+ var i = n(0), o = function() {
307
+ function t2(e2) {
308
+ void 0 === e2 && (e2 = {}), this.size = 0, this.lBuffer = [], this.rBuffer = [], this.tempPCM = [], this.inputSampleBits = 16, this.fileSize = 0, this.duration = 0, this.needRecord = true;
309
+ var n2, i2 = new (window.AudioContext || window.webkitAudioContext)();
310
+ this.inputSampleRate = i2.sampleRate, this.setNewOption(e2), this.littleEdian = (n2 = new ArrayBuffer(2), new DataView(n2).setInt16(0, 256, true), 256 === new Int16Array(n2)[0]), t2.initUserMedia();
311
+ }
312
+ return t2.prototype.setNewOption = function(t3) {
313
+ void 0 === t3 && (t3 = {}), this.config = { sampleBits: ~[8, 16].indexOf(t3.sampleBits) ? t3.sampleBits : 16, sampleRate: ~[8e3, 11025, 16e3, 22050, 24e3, 44100, 48e3].indexOf(t3.sampleRate) ? t3.sampleRate : this.inputSampleRate, numChannels: ~[1, 2].indexOf(t3.numChannels) ? t3.numChannels : 1 }, this.outputSampleRate = this.config.sampleRate, this.oututSampleBits = this.config.sampleBits;
314
+ }, t2.prototype.startRecord = function() {
315
+ var t3 = this;
316
+ return this.context && this.destroyRecord(), this.initRecorder(), navigator.mediaDevices.getUserMedia({ audio: true }).then(function(e2) {
317
+ t3.audioInput = t3.context.createMediaStreamSource(e2), t3.stream = e2;
318
+ }).then(function() {
319
+ t3.audioInput.connect(t3.analyser), t3.analyser.connect(t3.recorder), t3.recorder.connect(t3.context.destination);
320
+ });
321
+ }, t2.prototype.pauseRecord = function() {
322
+ this.needRecord = false;
323
+ }, t2.prototype.resumeRecord = function() {
324
+ this.needRecord = true;
325
+ }, t2.prototype.stopRecord = function() {
326
+ this.audioInput && this.audioInput.disconnect(), this.source && this.source.stop(), this.recorder.disconnect(), this.analyser.disconnect(), this.needRecord = true;
327
+ }, t2.prototype.destroyRecord = function() {
328
+ return this.clearRecordStatus(), this.stopStream(), this.closeAudioContext();
329
+ }, t2.prototype.getAnalyseData = function() {
330
+ var t3 = new Uint8Array(this.analyser.frequencyBinCount);
331
+ return this.analyser.getByteTimeDomainData(t3), t3;
332
+ }, t2.prototype.getData = function() {
333
+ return this.flat();
334
+ }, t2.prototype.clearRecordStatus = function() {
335
+ this.lBuffer.length = 0, this.rBuffer.length = 0, this.size = 0, this.fileSize = 0, this.PCM = null, this.audioInput = null, this.duration = 0;
336
+ }, t2.prototype.flat = function() {
337
+ var t3 = null, e2 = new Float32Array(0);
338
+ 1 === this.config.numChannels ? t3 = new Float32Array(this.size) : (t3 = new Float32Array(this.size / 2), e2 = new Float32Array(this.size / 2));
339
+ for (var n2 = 0, i2 = 0; i2 < this.lBuffer.length; i2++) t3.set(this.lBuffer[i2], n2), n2 += this.lBuffer[i2].length;
340
+ n2 = 0;
341
+ for (i2 = 0; i2 < this.rBuffer.length; i2++) e2.set(this.rBuffer[i2], n2), n2 += this.rBuffer[i2].length;
342
+ return { left: t3, right: e2 };
343
+ }, t2.prototype.initRecorder = function() {
344
+ var t3 = this;
345
+ this.clearRecordStatus(), this.context = new (window.AudioContext || window.webkitAudioContext)(), this.analyser = this.context.createAnalyser(), this.analyser.fftSize = 2048;
346
+ var e2 = this.context.createScriptProcessor || this.context.createJavaScriptNode;
347
+ this.recorder = e2.apply(this.context, [4096, this.config.numChannels, this.config.numChannels]), this.recorder.onaudioprocess = function(e3) {
348
+ if (t3.needRecord) {
349
+ var n2, i2 = e3.inputBuffer.getChannelData(0), o2 = null;
350
+ t3.lBuffer.push(new Float32Array(i2)), t3.size += i2.length, 2 === t3.config.numChannels && (o2 = e3.inputBuffer.getChannelData(1), t3.rBuffer.push(new Float32Array(o2)), t3.size += o2.length), t3.fileSize = Math.floor(t3.size / Math.max(t3.inputSampleRate / t3.outputSampleRate, 1)) * (t3.oututSampleBits / 8), n2 = 100 * Math.max.apply(Math, i2), t3.duration += 4096 / t3.inputSampleRate, t3.onprocess && t3.onprocess(t3.duration), t3.onprogress && t3.onprogress({ duration: t3.duration, fileSize: t3.fileSize, vol: n2 });
351
+ }
352
+ };
353
+ }, t2.prototype.stopStream = function() {
354
+ this.stream && this.stream.getTracks && (this.stream.getTracks().forEach(function(t3) {
355
+ return t3.stop();
356
+ }), this.stream = null);
357
+ }, t2.prototype.closeAudioContext = function() {
358
+ return this.context && this.context.close && "closed" !== this.context.state ? this.context.close() : new Promise(function(t3) {
359
+ t3();
360
+ });
361
+ }, t2.initUserMedia = function() {
362
+ void 0 === navigator.mediaDevices && (navigator.mediaDevices = {}), void 0 === navigator.mediaDevices.getUserMedia && (navigator.mediaDevices.getUserMedia = function(t3) {
363
+ var e2 = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
364
+ return e2 ? new Promise(function(n2, i2) {
365
+ e2.call(navigator, t3, n2, i2);
366
+ }) : Promise.reject(new Error("浏览器不支持 getUserMedia !"));
367
+ });
368
+ }, t2.prototype.transformIntoPCM = function(t3, e2) {
369
+ var n2 = new Float32Array(t3), o2 = new Float32Array(e2), r = i.compress({ left: n2, right: o2 }, this.inputSampleRate, this.outputSampleRate);
370
+ return i.encodePCM(r, this.oututSampleBits, this.littleEdian);
371
+ }, t2.getPermission = function() {
372
+ return this.initUserMedia(), navigator.mediaDevices.getUserMedia({ audio: true }).then(function(t3) {
373
+ t3 && t3.getTracks().forEach(function(t4) {
374
+ return t4.stop();
375
+ });
376
+ });
377
+ }, t2;
378
+ }();
379
+ e.default = o;
380
+ }]).default;
381
+ });
382
+ })(recorder);
383
+ var recorderExports = recorder.exports;
384
+ var jsAudioRecorder = recorderExports;
385
+ const Recorder = /* @__PURE__ */ getDefaultExportFromCjs(jsAudioRecorder);
386
+ const baseTTSUrl = "http://192.168.3.182:8002";
387
+ const ASR_URL = "http://192.168.3.182:9988/transcribe";
388
+ const _sfc_main = {
389
+ __name: "index",
390
+ props: {
391
+ humans: {
392
+ type: Array,
393
+ default: () => []
394
+ }
395
+ },
396
+ emits: ["loaded", "changed", "paused", "resumed", "audio-ready"],
397
+ setup(__props, { expose: __expose, emit: __emit }) {
398
+ const props = __props;
399
+ const emit = __emit;
400
+ const containerRef = ref(null);
401
+ const canvasRef = ref(null);
402
+ const ctx = ref(null);
403
+ const currentHuman = ref(null);
404
+ const animationId = ref(null);
405
+ const frameIndex = ref(1);
406
+ const timestamp = ref(null);
407
+ const frames = ref({ standby: [], speakStart: [], speakLoop: [], speakEnd: [] });
408
+ const animationState = ref("standby");
409
+ const loopDirection = ref(1);
410
+ const isPaused = ref(false);
411
+ const pauseSnapshot = ref(null);
412
+ const loadFrames = () => {
413
+ frames.value = { standby: [], speakStart: [], speakLoop: [], speakEnd: [] };
414
+ const folder = currentHuman.value.folder;
415
+ const { standbyNum, speakNum } = {
416
+ standbyNum: currentHuman.value.standby.standbyNum,
417
+ speakNum: currentHuman.value.speak.speakNum
418
+ };
419
+ for (let i = 1; i <= standbyNum; i++) {
420
+ const image = new Image();
421
+ image.src = encodeURI(`${folder}/standby/standby (${i}).png`);
422
+ frames.value.standby.push(image);
423
+ }
424
+ const startEnd = Math.floor(speakNum * 0.6);
425
+ const loopEnd = Math.floor(speakNum * 0.9);
426
+ for (let i = 1; i <= startEnd; i++) {
427
+ const image = new Image();
428
+ image.src = encodeURI(`${folder}/speak/speak (${i}).png`);
429
+ frames.value.speakStart.push(image);
430
+ }
431
+ for (let i = startEnd; i <= loopEnd; i++) {
432
+ const image = new Image();
433
+ image.src = encodeURI(`${folder}/speak/speak (${i}).png`);
434
+ frames.value.speakLoop.push(image);
435
+ }
436
+ for (let i = loopEnd; i <= speakNum; i++) {
437
+ const image = new Image();
438
+ image.src = encodeURI(`${folder}/speak/speak (${i}).png`);
439
+ frames.value.speakEnd.push(image);
440
+ }
441
+ };
442
+ const draw = (image) => {
443
+ if (!ctx.value || !image || image.width <= 0 || image.height <= 0) return;
444
+ const canvas = canvasRef.value;
445
+ ctx.value.clearRect(0, 0, canvas.width, canvas.height);
446
+ const scale = Math.min(canvas.width / image.width, canvas.height / image.height);
447
+ const width = image.width * scale;
448
+ const height = image.height * scale;
449
+ const x = (canvas.width - width) / 2;
450
+ const y = (canvas.height - height) / 2;
451
+ ctx.value.drawImage(image, x, y, width, height);
452
+ };
453
+ const stop = () => {
454
+ if (animationId.value) {
455
+ cancelAnimationFrame(animationId.value);
456
+ animationId.value = null;
457
+ }
458
+ frameIndex.value = 1;
459
+ animationState.value = "standby";
460
+ };
461
+ const runAnimation = (state) => {
462
+ stop();
463
+ animationState.value = state;
464
+ loopDirection.value = 1;
465
+ let currentFrames;
466
+ let interval;
467
+ let loopConfig = null;
468
+ switch (state) {
469
+ case "standby":
470
+ currentFrames = frames.value.standby;
471
+ interval = currentHuman.value.standby.interval;
472
+ loopConfig = { type: "pingpong", next: "standby" };
473
+ break;
474
+ case "speak":
475
+ currentFrames = frames.value.speakStart;
476
+ interval = currentHuman.value.speak.interval;
477
+ loopConfig = { type: "once", next: "speakLoop" };
478
+ break;
479
+ case "speakLoop":
480
+ currentFrames = frames.value.speakLoop;
481
+ interval = currentHuman.value.speak.interval;
482
+ loopConfig = { type: "pingpong", next: "speakLoop" };
483
+ break;
484
+ case "speakEnd":
485
+ currentFrames = frames.value.speakEnd;
486
+ interval = currentHuman.value.speak.interval;
487
+ loopConfig = { type: "once", next: "standby" };
488
+ break;
489
+ default:
490
+ return;
491
+ }
492
+ const updateFrame = () => {
493
+ if (!loopConfig) {
494
+ frameIndex.value = frameIndex.value >= currentFrames.length ? 1 : frameIndex.value + 1;
495
+ return false;
496
+ }
497
+ if (loopConfig.type === "once") {
498
+ frameIndex.value++;
499
+ if (frameIndex.value <= currentFrames.length) return false;
500
+ if (loopConfig.next === "standby") {
501
+ standby();
502
+ return true;
503
+ }
504
+ if (loopConfig.next === "speakLoop") {
505
+ frameIndex.value = 1;
506
+ currentFrames = frames.value.speakLoop;
507
+ loopConfig = { type: "pingpong", next: "speakLoop" };
508
+ }
509
+ return false;
510
+ }
511
+ if (loopConfig.type === "pingpong") {
512
+ frameIndex.value += loopDirection.value;
513
+ }
514
+ return false;
515
+ };
516
+ const animate = (time) => {
517
+ if (!timestamp.value) timestamp.value = time;
518
+ if (isPaused.value) {
519
+ animationId.value = requestAnimationFrame(animate);
520
+ return;
521
+ }
522
+ if (time - timestamp.value >= interval) {
523
+ if (loopConfig && loopConfig.type === "pingpong") {
524
+ const nextIndex = frameIndex.value + loopDirection.value;
525
+ if (nextIndex > currentFrames.length) {
526
+ loopDirection.value = -1;
527
+ } else if (nextIndex < 1) {
528
+ loopDirection.value = 1;
529
+ }
530
+ }
531
+ draw(currentFrames[frameIndex.value - 1]);
532
+ const shouldStop = updateFrame();
533
+ if (shouldStop) return;
534
+ timestamp.value = time;
535
+ }
536
+ animationId.value = requestAnimationFrame(animate);
537
+ };
538
+ animationId.value = requestAnimationFrame(animate);
539
+ };
540
+ const standby = () => {
541
+ runAnimation("standby");
542
+ };
543
+ const speak = () => {
544
+ runAnimation("speak");
545
+ };
546
+ const stopSpeaking = () => {
547
+ if (animationState.value === "speak" || animationState.value === "speakLoop") {
548
+ runAnimation("speakEnd");
549
+ } else {
550
+ standby();
551
+ }
552
+ };
553
+ const pause = () => {
554
+ if (isPaused.value) return;
555
+ isPaused.value = true;
556
+ pauseSnapshot.value = {
557
+ state: animationState.value,
558
+ frameIndex: frameIndex.value,
559
+ loopDirection: loopDirection.value
560
+ };
561
+ emit("paused");
562
+ };
563
+ const resume = () => {
564
+ if (!isPaused.value) return;
565
+ isPaused.value = false;
566
+ timestamp.value = null;
567
+ if (pauseSnapshot.value) {
568
+ animationState.value = pauseSnapshot.value.state;
569
+ frameIndex.value = pauseSnapshot.value.frameIndex;
570
+ loopDirection.value = pauseSnapshot.value.loopDirection;
571
+ }
572
+ emit("resumed");
573
+ };
574
+ const waitFramesLoaded = (callback) => {
575
+ let loadedCount = 0;
576
+ const allFrames = [
577
+ ...frames.value.standby,
578
+ ...frames.value.speakStart,
579
+ ...frames.value.speakLoop,
580
+ ...frames.value.speakEnd
581
+ ];
582
+ const checkLoaded = () => {
583
+ loadedCount++;
584
+ if (loadedCount >= allFrames.length) {
585
+ callback();
586
+ }
587
+ };
588
+ allFrames.forEach((img) => {
589
+ if (img.complete) {
590
+ checkLoaded();
591
+ } else {
592
+ img.onload = checkLoaded;
593
+ img.onerror = checkLoaded;
594
+ }
595
+ });
596
+ };
597
+ const init = () => {
598
+ nextTick(() => {
599
+ if (!containerRef.value || !canvasRef.value) return;
600
+ if (!props.humans || props.humans.length === 0) return;
601
+ if (!currentHuman.value) {
602
+ currentHuman.value = props.humans[0];
603
+ }
604
+ const canvas = canvasRef.value;
605
+ const dpr = window.devicePixelRatio || 1;
606
+ const width = containerRef.value.clientWidth;
607
+ const height = containerRef.value.clientHeight;
608
+ canvas.width = width * 3 * dpr;
609
+ canvas.height = height * 3 * dpr;
610
+ canvas.style.width = width + "px";
611
+ canvas.style.height = height + "px";
612
+ ctx.value = canvas.getContext("2d");
613
+ ctx.value.scale(dpr, dpr);
614
+ loadFrames();
615
+ waitFramesLoaded(() => {
616
+ draw(frames.value.standby[0]);
617
+ emit("loaded", currentHuman.value);
618
+ });
619
+ });
620
+ };
621
+ const currentAudio = ref(null);
622
+ const currentTtsRequestId = ref(null);
623
+ const playTTS = async (text) => {
624
+ var _a, _b, _c, _d, _e, _f, _g, _h;
625
+ if (!text || !((_a = currentHuman.value) == null ? void 0 : _a.isMuted)) return;
626
+ if (currentAudio.value) {
627
+ currentAudio.value.pause();
628
+ currentAudio.value = null;
629
+ }
630
+ currentTtsRequestId.value = Date.now();
631
+ const requestId = currentTtsRequestId.value;
632
+ try {
633
+ const cleanText = text.replace(/```[\s\S]*?```/g, "").replace(/`[^`]+`/g, "").replace(/[#*_~]/g, "").replace(/\n+/g, ",").replace(/\s+/g, " ").replace(/[,。!?]{2,}/g, ",").trim();
634
+ if (!cleanText) return;
635
+ const baseUrl = baseTTSUrl;
636
+ const sessionHash = "session_" + Date.now();
637
+ let speed = ((_c = (_b = currentHuman.value) == null ? void 0 : _b.speakSet) == null ? void 0 : _c.speed) || 1;
638
+ let age = ((_e = (_d = currentHuman.value) == null ? void 0 : _d.speakSet) == null ? void 0 : _e.age) || "Young Adult / 青年";
639
+ let sex = ((_g = (_f = currentHuman.value) == null ? void 0 : _f.speakSet) == null ? void 0 : _g.sex) || "Female / 女";
640
+ const data = [cleanText, "Auto", 32, 2, true, speed, null, true, true, sex, age, "Auto", "Auto", "Auto", "Auto"];
641
+ console.log("[OmniVoice] 提交请求:", { text: cleanText, length: cleanText.length, fn_index: 1 });
642
+ const joinRes = await fetch(`${baseUrl}/gradio_api/queue/join`, {
643
+ method: "POST",
644
+ headers: { "Content-Type": "application/json" },
645
+ body: JSON.stringify({ data, session_hash: sessionHash, fn_index: 1, trigger_id: 50 })
646
+ });
647
+ const joinData = await joinRes.json();
648
+ console.log("[OmniVoice] Step1 响应:", joinData);
649
+ console.log("[OmniVoice] Step2: 轮询等待结果");
650
+ let audioUrl = "";
651
+ let maxPolls = 60;
652
+ let pollInterval = 1e3;
653
+ while (!audioUrl && maxPolls > 0) {
654
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
655
+ maxPolls--;
656
+ try {
657
+ const pollRes = await fetch(`${baseUrl}/gradio_api/queue/data?session_hash=${sessionHash}`);
658
+ const pollText = await pollRes.text();
659
+ const lines = pollText.split("\n");
660
+ for (const line of lines) {
661
+ const trimLine = line.trim();
662
+ if (!trimLine.startsWith("data: ")) continue;
663
+ try {
664
+ const json = JSON.parse(trimLine.replace("data: ", ""));
665
+ console.log("[OmniVoice] 轮询消息:", json);
666
+ if (json.msg === "process_completed" && ((_h = json.output) == null ? void 0 : _h.data)) {
667
+ const fileData = json.output.data[0];
668
+ console.log("[OmniVoice] 获取到音频:", fileData);
669
+ if (fileData == null ? void 0 : fileData.url) audioUrl = fileData.url;
670
+ else if (fileData == null ? void 0 : fileData.path) audioUrl = `${baseUrl}/gradio_api/file=${fileData.path}`;
671
+ else if (typeof fileData === "string") audioUrl = fileData.startsWith("http") ? fileData : `${baseUrl}/gradio_api/file=${fileData}`;
672
+ else if (Array.isArray(fileData) && fileData.length >= 2) {
673
+ const samplingRate = fileData[0];
674
+ const waveform = fileData[1];
675
+ console.log("[OmniVoice] 直接获取到音频数组:", { samplingRate, waveformLength: waveform == null ? void 0 : waveform.length });
676
+ if (samplingRate && waveform && Array.isArray(waveform)) {
677
+ const audioBuffer = new ArrayBuffer(waveform.length * 2);
678
+ const view = new DataView(audioBuffer);
679
+ for (let i = 0; i < waveform.length; i++) {
680
+ view.setInt16(i * 2, waveform[i], true);
681
+ }
682
+ const wavBlob = createWavBlob(audioBuffer, samplingRate, 1, 16);
683
+ const audioObjectUrl = URL.createObjectURL(wavBlob);
684
+ if (currentTtsRequestId.value !== requestId) {
685
+ URL.revokeObjectURL(audioObjectUrl);
686
+ return;
687
+ }
688
+ currentAudio.value = new Audio(audioObjectUrl);
689
+ currentAudio.value.onplaying = () => {
690
+ console.log("[OmniVoice] 音频开始播放");
691
+ speak();
692
+ };
693
+ currentAudio.value.onended = () => {
694
+ console.log("[OmniVoice] 音频播放结束");
695
+ stopSpeaking();
696
+ currentAudio.value = null;
697
+ URL.revokeObjectURL(audioObjectUrl);
698
+ };
699
+ currentAudio.value.onerror = () => {
700
+ console.error("[OmniVoice] 音频播放失败");
701
+ stopSpeaking();
702
+ currentAudio.value = null;
703
+ URL.revokeObjectURL(audioObjectUrl);
704
+ };
705
+ await currentAudio.value.play();
706
+ return;
707
+ }
708
+ }
709
+ break;
710
+ } else if (json.msg === "process_error") {
711
+ console.error("[OmniVoice] 处理错误:", json);
712
+ standby();
713
+ return;
714
+ }
715
+ } catch (e) {
716
+ console.error("[OmniVoice] 解析轮询消息失败:", e);
717
+ }
718
+ }
719
+ } catch (e) {
720
+ console.warn("[OmniVoice] 轮询失败:", e.message);
721
+ }
722
+ }
723
+ if (audioUrl) {
724
+ if (audioUrl.startsWith("/")) audioUrl = baseUrl + audioUrl;
725
+ console.log("[OmniVoice] 下载音频:", audioUrl);
726
+ if (currentTtsRequestId.value !== requestId) return;
727
+ const audioRes = await fetch(audioUrl);
728
+ const audioBlob = await audioRes.blob();
729
+ const audioObjectUrl = URL.createObjectURL(audioBlob);
730
+ currentAudio.value = new Audio(audioObjectUrl);
731
+ currentAudio.value.onplaying = () => {
732
+ console.log("[OmniVoice] 音频开始播放");
733
+ speak();
734
+ };
735
+ currentAudio.value.onended = () => {
736
+ console.log("[OmniVoice] 音频播放结束");
737
+ stopSpeaking();
738
+ currentAudio.value = null;
739
+ URL.revokeObjectURL(audioObjectUrl);
740
+ };
741
+ currentAudio.value.onerror = () => {
742
+ console.error("[OmniVoice] 音频播放失败");
743
+ stopSpeaking();
744
+ currentAudio.value = null;
745
+ URL.revokeObjectURL(audioObjectUrl);
746
+ };
747
+ await currentAudio.value.play();
748
+ } else {
749
+ console.error("[OmniVoice] 未获取到音频");
750
+ standby();
751
+ }
752
+ } catch (e) {
753
+ console.error("[OmniVoice] TTS失败:", e);
754
+ standby();
755
+ }
756
+ };
757
+ const startRecord = async () => {
758
+ try {
759
+ if (recorder2.value) recorder2.value.stop();
760
+ await recorder2.value.start();
761
+ } catch (e) {
762
+ console.error("录音启动失败:", e);
763
+ }
764
+ };
765
+ const stopRecord = async () => {
766
+ if (!recorder2.value) return;
767
+ try {
768
+ recorder2.value.stop();
769
+ const blob = recorder2.value.getWAVBlob();
770
+ if (blob.size < 1e3) {
771
+ return;
772
+ }
773
+ const text = await audioToText(blob);
774
+ emit("audio-ready", text);
775
+ } catch (e) {
776
+ console.error("录音处理失败:", e);
777
+ }
778
+ };
779
+ const audioToText = async (blob) => {
780
+ var _a;
781
+ const formData = new FormData();
782
+ formData.append("file", blob, "recorded_audio.wav");
783
+ try {
784
+ const res = await fetch(ASR_URL, {
785
+ method: "POST",
786
+ body: formData
787
+ });
788
+ console.log("STT结果:", res);
789
+ const text = ((_a = res.data) == null ? void 0 : _a.text) || res.text;
790
+ } catch (e) {
791
+ console.error("STT失败:", e);
792
+ }
793
+ };
794
+ const createWavBlob = (audioBuffer, sampleRate, channels, bitsPerSample) => {
795
+ const bytesPerSample = bitsPerSample / 8;
796
+ const blockAlign = channels * bytesPerSample;
797
+ const dataSize = audioBuffer.byteLength;
798
+ const buffer = new ArrayBuffer(44 + dataSize);
799
+ const view = new DataView(buffer);
800
+ view.setUint8(0, 82);
801
+ view.setUint8(1, 73);
802
+ view.setUint8(2, 70);
803
+ view.setUint8(3, 70);
804
+ view.setUint32(4, 36 + dataSize, true);
805
+ view.setUint8(8, 87);
806
+ view.setUint8(9, 65);
807
+ view.setUint8(10, 86);
808
+ view.setUint8(11, 69);
809
+ view.setUint8(12, 102);
810
+ view.setUint8(13, 109);
811
+ view.setUint8(14, 116);
812
+ view.setUint8(15, 32);
813
+ view.setUint32(16, 16, true);
814
+ view.setUint16(20, 1, true);
815
+ view.setUint16(22, channels, true);
816
+ view.setUint32(24, sampleRate, true);
817
+ view.setUint32(28, sampleRate * blockAlign, true);
818
+ view.setUint16(32, blockAlign, true);
819
+ view.setUint16(34, bitsPerSample, true);
820
+ view.setUint8(36, 100);
821
+ view.setUint8(37, 97);
822
+ view.setUint8(38, 116);
823
+ view.setUint8(39, 97);
824
+ view.setUint32(40, dataSize, true);
825
+ const audioData = new Uint8Array(audioBuffer);
826
+ const destData = new Uint8Array(buffer, 44);
827
+ destData.set(audioData);
828
+ return new Blob([buffer], { type: "audio/wav" });
829
+ };
830
+ let recorder2 = ref(null);
831
+ const initRecorder = () => {
832
+ console.log("initRecorder");
833
+ if (!recorder2.value) {
834
+ recorder2.value = new Recorder({
835
+ sampleBits: 16,
836
+ sampleRate: 16e3,
837
+ numChannels: 1
838
+ });
839
+ }
840
+ };
841
+ __expose({
842
+ standby,
843
+ speak,
844
+ stopSpeaking,
845
+ pause,
846
+ resume,
847
+ playTTS,
848
+ startRecord,
849
+ stopRecord
850
+ });
851
+ watch(() => props.humans, (val) => {
852
+ if (val && val.length > 0 && !currentHuman.value) {
853
+ init();
854
+ }
855
+ }, { deep: true });
856
+ onMounted(() => {
857
+ initRecorder();
858
+ init();
859
+ });
860
+ onUnmounted(() => {
861
+ stop();
862
+ if (recorder2.value) {
863
+ recorder2.value.stop();
864
+ }
865
+ });
866
+ return (_ctx, _cache) => {
867
+ return openBlock(), createElementBlock("div", {
868
+ class: "digital-human",
869
+ ref_key: "containerRef",
870
+ ref: containerRef
871
+ }, [
872
+ createElementVNode("canvas", {
873
+ ref_key: "canvasRef",
874
+ ref: canvasRef
875
+ }, null, 512)
876
+ ], 512);
877
+ };
878
+ }
879
+ };
880
+ const DigitalHuman = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-132811db"]]);
881
+ DigitalHuman.install = (app) => app.component("DigitalHuman", DigitalHuman);
882
+ const components = [DemoButton, DemoInput, DigitalHuman];
883
+ const install = (app) => {
884
+ components.forEach((comp) => app.use(comp));
885
+ };
886
+ const index = { install };
887
+ export {
888
+ DemoButton,
889
+ DemoInput,
890
+ DigitalHuman,
891
+ index as default
892
+ };
@@ -0,0 +1,11 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RuiYunHuman={},e.Vue)}(this,function(e,t){"use strict";const _export_sfc=(e,t)=>{const a=e.__vccOpts||e;for(const[o,r]of t)a[o]=r;return a},a=_export_sfc({__name:"index",props:{type:{type:String,default:"primary"}},emits:["click"],setup:e=>(a,o)=>(t.openBlock(),t.createElementBlock("button",{class:t.normalizeClass(["demo-btn",e.type]),onClick:o[0]||(o[0]=e=>a.$emit("click"))},[t.renderSlot(a.$slots,"default",{},void 0,!0)],2))},[["__scopeId","data-v-9a48516a"]]);a.install=e=>e.component("DemoButton",a);const o={class:"demo-input-wrap"},r={key:0,class:"prefix"},s=["type","placeholder","value","disabled"],l={key:1,class:"suffix"},u=_export_sfc({__name:"index",props:{modelValue:{type:[String,Number],default:""},placeholder:{type:String,default:"请输入内容"},inputType:{type:String,default:"text"},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","blur"],setup(e,{emit:a}){const u=a,handleInput=e=>u("update:modelValue",e.target.value);return(a,u)=>(t.openBlock(),t.createElementBlock("div",o,[a.$slots.prefix?(t.openBlock(),t.createElementBlock("span",r,[t.renderSlot(a.$slots,"prefix",{},void 0,!0)])):t.createCommentVNode("",!0),t.createElementVNode("input",{class:"demo-input",type:e.inputType,placeholder:e.placeholder,value:e.modelValue,disabled:e.disabled,onInput:handleInput,onFocus:u[0]||(u[0]=e=>a.$emit("focus")),onBlur:u[1]||(u[1]=e=>a.$emit("blur"))},null,40,s),a.$slots.suffix?(t.openBlock(),t.createElementBlock("span",l,[t.renderSlot(a.$slots,"suffix",{},void 0,!0)])):t.createCommentVNode("",!0)]))}},[["__scopeId","data-v-28a3493c"]]);u.install=e=>e.component("DemoInput",u);"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c={exports:{}};
2
+ /*!
3
+ *
4
+ * js-audio-recorder - js audio recorder plugin
5
+ *
6
+ * @version v1.0.7
7
+ * @homepage https://github.com/2fps/recorder
8
+ * @author 2fps <echoweb@126.com> (https://www.zhuyuntao.cn)
9
+ * @license MIT
10
+ *
11
+ */c.exports=function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,a){function i(e,t,a){for(var o=0;o<a.length;o++)e.setUint8(t+o,a.charCodeAt(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.compress=function(e,t,a){for(var o=t/a,r=Math.max(o,1),s=e.left,l=e.right,u=Math.floor((s.length+l.length)/o),c=new Float32Array(u),f=0,v=0;f<u;){var y=Math.floor(v);c[f]=s[y],f++,l.length&&(c[f]=l[y],f++),v+=r}return c},t.encodePCM=function(e,t,a){void 0===a&&(a=!0);var o=0,r=e.length*(t/8),s=new ArrayBuffer(r),l=new DataView(s);if(8===t)for(var u=0;u<e.length;u++,o++){var c=(f=Math.max(-1,Math.min(1,e[u])))<0?128*f:127*f;c=+c+128,l.setInt8(o,c)}else for(u=0;u<e.length;u++,o+=2){var f=Math.max(-1,Math.min(1,e[u]));l.setInt16(o,f<0?32768*f:32767*f,a)}return l},t.encodeWAV=function(e,t,a,o,r,s){void 0===s&&(s=!0);var l=a>t?t:a,u=r,c=new ArrayBuffer(44+e.byteLength),f=new DataView(c),v=o,y=0;i(f,y,"RIFF"),y+=4,f.setUint32(y,36+e.byteLength,s),i(f,y+=4,"WAVE"),i(f,y+=4,"fmt "),y+=4,f.setUint32(y,16,s),y+=4,f.setUint16(y,1,s),y+=2,f.setUint16(y,v,s),y+=2,f.setUint32(y,l,s),y+=4,f.setUint32(y,v*l*(u/8),s),y+=4,f.setUint16(y,v*(u/8),s),y+=2,f.setUint16(y,u,s),i(f,y+=2,"data"),y+=4,f.setUint32(y,e.byteLength,s),y+=4;for(var g=0;g<e.byteLength;)f.setUint8(y,e.getUint8(g)),y++,g++;return f}},function(e,t,a){var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])})(e,t)},function(e,t){function n2(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n2.prototype=t.prototype,new n2)});Object.defineProperty(t,"__esModule",{value:!0});var s=a(2),l=a(0),u=a(3),c=function(e){function e2(t){void 0===t&&(t={});var a=e.call(this,t)||this;return a.isrecording=!1,a.ispause=!1,a.isplaying=!1,a}return r(e2,e),e2.prototype.setOption=function(e){void 0===e&&(e={}),this.setNewOption(e)},e2.prototype.start=function(){return this.isrecording?Promise.reject():(this.isrecording=!0,this.startRecord())},e2.prototype.pause=function(){this.isrecording&&!this.ispause&&(this.ispause=!0,this.pauseRecord())},e2.prototype.resume=function(){this.isrecording&&this.ispause&&(this.ispause=!1,this.resumeRecord())},e2.prototype.stop=function(){this.isrecording&&(this.isrecording=!1,this.ispause=!1,this.stopRecord())},e2.prototype.play=function(){this.stop(),this.isplaying=!0,this.onplay&&this.onplay(),u.default.addPlayEnd(this.onplayend);var e=this.getWAV();e.byteLength>44&&u.default.play(e.buffer)},e2.prototype.getPlayTime=function(){return u.default.getPlayTime()},e2.prototype.pausePlay=function(){!this.isrecording&&this.isplaying&&(this.isplaying=!1,this.onpauseplay&&this.onpauseplay(),u.default.pausePlay())},e2.prototype.resumePlay=function(){this.isrecording||this.isplaying||(this.isplaying=!0,this.onresumeplay&&this.onresumeplay(),u.default.resumePlay())},e2.prototype.stopPlay=function(){this.isrecording||(this.isplaying=!1,this.onstopplay&&this.onstopplay(),u.default.stopPlay())},e2.prototype.destroy=function(){return u.default.destroyPlay(),this.destroyRecord()},e2.prototype.getRecordAnalyseData=function(){return this.getAnalyseData()},e2.prototype.getPlayAnalyseData=function(){return u.default.getAnalyseData()},e2.prototype.getPCM=function(){this.stop();var e=this.getData();return e=l.compress(e,this.inputSampleRate,this.outputSampleRate),l.encodePCM(e,this.oututSampleBits,this.littleEdian)},e2.prototype.getPCMBlob=function(){return new Blob([this.getPCM()])},e2.prototype.downloadPCM=function(e){void 0===e&&(e="recorder");var t=this.getPCMBlob();s.downloadPCM(t,e)},e2.prototype.getWAV=function(){var e=this.getPCM();return l.encodeWAV(e,this.inputSampleRate,this.outputSampleRate,this.config.numChannels,this.oututSampleBits,this.littleEdian)},e2.prototype.getWAVBlob=function(){return new Blob([this.getWAV()],{type:"audio/wav"})},e2.prototype.downloadWAV=function(e){void 0===e&&(e="recorder");var t=this.getWAVBlob();s.downloadWAV(t,e)},e2.prototype.download=function(e,t,a){s.download(e,t,a)},e2.prototype.getChannelData=function(){var e=this.getPCM(),t=e.byteLength,a=this.littleEdian,o={left:null,right:null};if(2===this.config.numChannels){var r=new DataView(new ArrayBuffer(t/2)),s=new DataView(new ArrayBuffer(t/2));if(16===this.config.sampleBits)for(var l=0;l<t/2;l+=2)r.setInt16(l,e.getInt16(2*l,a),a),s.setInt16(l,e.getInt16(2*l+2,a),a);else for(l=0;l<t/2;l+=2)r.setInt8(l,e.getInt8(2*l)),s.setInt8(l,e.getInt8(2*l+1));o.left=r,o.right=s}else o.left=e;return o},e2}(a(5).default);t.default=c},function(e,t,a){function i(e,t,a){var o=document.createElement("a");o.href=window.URL.createObjectURL(e),o.download=t+"."+a,o.click()}Object.defineProperty(t,"__esModule",{value:!0}),t.downloadWAV=function(e,t){void 0===t&&(t="recorder"),i(e,t,"wav")},t.downloadPCM=function(e,t){void 0===t&&(t="recorder"),i(e,t,"pcm")},t.download=function(e,t,a){return i(e,t,a)}},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var o=a(4),r=null,s=0,l=0,u=null,c=null,f=null,v=!1,y=0,p=function(){};function d(){return v=!1,u.decodeAudioData(f.slice(0),function(e){(r=u.createBufferSource()).onended=function(){v||(y=u.currentTime-l+s,p())},r.buffer=e,r.connect(c),c.connect(u.destination),r.start(0,s),l=u.currentTime},function(e){o.throwError(e)})}function h(){r&&(r.stop(),r=null)}var g=function(){function t2(){}return t2.play=function(e){return u||(u=new(window.AudioContext||window.webkitAudioContext),(c=u.createAnalyser()).fftSize=2048),this.stopPlay(),f=e,y=0,d()},t2.pausePlay=function(){h(),s+=u.currentTime-l,v=!0},t2.resumePlay=function(){return d()},t2.stopPlay=function(){s=0,f=null,h()},t2.destroyPlay=function(){this.stopPlay()},t2.getAnalyseData=function(){var e=new Uint8Array(c.frequencyBinCount);return c.getByteTimeDomainData(e),e},t2.addPlayEnd=function(e){void 0===e&&(e=function(){}),p=e},t2.getPlayTime=function(){var e=v?s:u.currentTime-l+s;return y||e},t2}();t.default=g},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0}),t.throwError=function(e){throw new Error(e)}},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var o=a(0),r=function(){function t2(e){void 0===e&&(e={}),this.size=0,this.lBuffer=[],this.rBuffer=[],this.tempPCM=[],this.inputSampleBits=16,this.fileSize=0,this.duration=0,this.needRecord=!0;var t,a=new(window.AudioContext||window.webkitAudioContext);this.inputSampleRate=a.sampleRate,this.setNewOption(e),this.littleEdian=(t=new ArrayBuffer(2),new DataView(t).setInt16(0,256,!0),256===new Int16Array(t)[0]),t2.initUserMedia()}return t2.prototype.setNewOption=function(e){void 0===e&&(e={}),this.config={sampleBits:~[8,16].indexOf(e.sampleBits)?e.sampleBits:16,sampleRate:~[8e3,11025,16e3,22050,24e3,44100,48e3].indexOf(e.sampleRate)?e.sampleRate:this.inputSampleRate,numChannels:~[1,2].indexOf(e.numChannels)?e.numChannels:1},this.outputSampleRate=this.config.sampleRate,this.oututSampleBits=this.config.sampleBits},t2.prototype.startRecord=function(){var e=this;return this.context&&this.destroyRecord(),this.initRecorder(),navigator.mediaDevices.getUserMedia({audio:!0}).then(function(t){e.audioInput=e.context.createMediaStreamSource(t),e.stream=t}).then(function(){e.audioInput.connect(e.analyser),e.analyser.connect(e.recorder),e.recorder.connect(e.context.destination)})},t2.prototype.pauseRecord=function(){this.needRecord=!1},t2.prototype.resumeRecord=function(){this.needRecord=!0},t2.prototype.stopRecord=function(){this.audioInput&&this.audioInput.disconnect(),this.source&&this.source.stop(),this.recorder.disconnect(),this.analyser.disconnect(),this.needRecord=!0},t2.prototype.destroyRecord=function(){return this.clearRecordStatus(),this.stopStream(),this.closeAudioContext()},t2.prototype.getAnalyseData=function(){var e=new Uint8Array(this.analyser.frequencyBinCount);return this.analyser.getByteTimeDomainData(e),e},t2.prototype.getData=function(){return this.flat()},t2.prototype.clearRecordStatus=function(){this.lBuffer.length=0,this.rBuffer.length=0,this.size=0,this.fileSize=0,this.PCM=null,this.audioInput=null,this.duration=0},t2.prototype.flat=function(){var e=null,t=new Float32Array(0);1===this.config.numChannels?e=new Float32Array(this.size):(e=new Float32Array(this.size/2),t=new Float32Array(this.size/2));for(var a=0,o=0;o<this.lBuffer.length;o++)e.set(this.lBuffer[o],a),a+=this.lBuffer[o].length;for(a=0,o=0;o<this.rBuffer.length;o++)t.set(this.rBuffer[o],a),a+=this.rBuffer[o].length;return{left:e,right:t}},t2.prototype.initRecorder=function(){var e=this;this.clearRecordStatus(),this.context=new(window.AudioContext||window.webkitAudioContext),this.analyser=this.context.createAnalyser(),this.analyser.fftSize=2048;var t=this.context.createScriptProcessor||this.context.createJavaScriptNode;this.recorder=t.apply(this.context,[4096,this.config.numChannels,this.config.numChannels]),this.recorder.onaudioprocess=function(t){if(e.needRecord){var a,o=t.inputBuffer.getChannelData(0),r=null;e.lBuffer.push(new Float32Array(o)),e.size+=o.length,2===e.config.numChannels&&(r=t.inputBuffer.getChannelData(1),e.rBuffer.push(new Float32Array(r)),e.size+=r.length),e.fileSize=Math.floor(e.size/Math.max(e.inputSampleRate/e.outputSampleRate,1))*(e.oututSampleBits/8),a=100*Math.max.apply(Math,o),e.duration+=4096/e.inputSampleRate,e.onprocess&&e.onprocess(e.duration),e.onprogress&&e.onprogress({duration:e.duration,fileSize:e.fileSize,vol:a})}}},t2.prototype.stopStream=function(){this.stream&&this.stream.getTracks&&(this.stream.getTracks().forEach(function(e){return e.stop()}),this.stream=null)},t2.prototype.closeAudioContext=function(){return this.context&&this.context.close&&"closed"!==this.context.state?this.context.close():new Promise(function(e){e()})},t2.initUserMedia=function(){void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(e){var t=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;return t?new Promise(function(a,o){t.call(navigator,e,a,o)}):Promise.reject(new Error("浏览器不支持 getUserMedia !"))})},t2.prototype.transformIntoPCM=function(e,t){var a=new Float32Array(e),r=new Float32Array(t),s=o.compress({left:a,right:r},this.inputSampleRate,this.outputSampleRate);return o.encodePCM(s,this.oututSampleBits,this.littleEdian)},t2.getPermission=function(){return this.initUserMedia(),navigator.mediaDevices.getUserMedia({audio:!0}).then(function(e){e&&e.getTracks().forEach(function(e){return e.stop()})})},t2}();t.default=r}]).default;const f=getDefaultExportFromCjs(c.exports),v=_export_sfc({__name:"index",props:{humans:{type:Array,default:()=>[]}},emits:["loaded","changed","paused","resumed","audio-ready"],setup(e,{expose:a,emit:o}){const r=e,s=o,l=t.ref(null),u=t.ref(null),c=t.ref(null),v=t.ref(null),y=t.ref(null),g=t.ref(1),m=t.ref(null),w=t.ref({standby:[],speakStart:[],speakLoop:[],speakEnd:[]}),b=t.ref("standby"),k=t.ref(1),U=t.ref(!1),x=t.ref(null),draw=e=>{if(!c.value||!e||e.width<=0||e.height<=0)return;const t=u.value;c.value.clearRect(0,0,t.width,t.height);const a=Math.min(t.width/e.width,t.height/e.height),o=e.width*a,r=e.height*a,s=(t.width-o)/2,l=(t.height-r)/2;c.value.drawImage(e,s,l,o,r)},stop=()=>{y.value&&(cancelAnimationFrame(y.value),y.value=null),g.value=1,b.value="standby"},runAnimation=e=>{let t,a;stop(),b.value=e,k.value=1;let o=null;switch(e){case"standby":t=w.value.standby,a=v.value.standby.interval,o={type:"pingpong",next:"standby"};break;case"speak":t=w.value.speakStart,a=v.value.speak.interval,o={type:"once",next:"speakLoop"};break;case"speakLoop":t=w.value.speakLoop,a=v.value.speak.interval,o={type:"pingpong",next:"speakLoop"};break;case"speakEnd":t=w.value.speakEnd,a=v.value.speak.interval,o={type:"once",next:"standby"};break;default:return}const animate=e=>{if(m.value||(m.value=e),U.value)y.value=requestAnimationFrame(animate);else{if(e-m.value>=a){if(o&&"pingpong"===o.type){const e=g.value+k.value;e>t.length?k.value=-1:e<1&&(k.value=1)}draw(t[g.value-1]);if(o?"once"===o.type?(g.value++,!(g.value<=t.length||("standby"===o.next?(standby(),0):("speakLoop"===o.next&&(g.value=1,t=w.value.speakLoop,o={type:"pingpong",next:"speakLoop"}),1)))):("pingpong"===o.type&&(g.value+=k.value),!1):(g.value=g.value>=t.length?1:g.value+1,!1))return;m.value=e}y.value=requestAnimationFrame(animate)}};y.value=requestAnimationFrame(animate)},standby=()=>{runAnimation("standby")},speak=()=>{runAnimation("speak")},stopSpeaking=()=>{"speak"===b.value||"speakLoop"===b.value?runAnimation("speakEnd"):standby()},init=()=>{t.nextTick(()=>{if(!l.value||!u.value)return;if(!r.humans||0===r.humans.length)return;v.value||(v.value=r.humans[0]);const e=u.value,t=window.devicePixelRatio||1,a=l.value.clientWidth,o=l.value.clientHeight;e.width=3*a*t,e.height=3*o*t,e.style.width=a+"px",e.style.height=o+"px",c.value=e.getContext("2d"),c.value.scale(t,t),(()=>{w.value={standby:[],speakStart:[],speakLoop:[],speakEnd:[]};const e=v.value.folder,{standbyNum:t,speakNum:a}={standbyNum:v.value.standby.standbyNum,speakNum:v.value.speak.speakNum};for(let s=1;s<=t;s++){const t=new Image;t.src=encodeURI(`${e}/standby/standby (${s}).png`),w.value.standby.push(t)}const o=Math.floor(.6*a),r=Math.floor(.9*a);for(let s=1;s<=o;s++){const t=new Image;t.src=encodeURI(`${e}/speak/speak (${s}).png`),w.value.speakStart.push(t)}for(let s=o;s<=r;s++){const t=new Image;t.src=encodeURI(`${e}/speak/speak (${s}).png`),w.value.speakLoop.push(t)}for(let s=r;s<=a;s++){const t=new Image;t.src=encodeURI(`${e}/speak/speak (${s}).png`),w.value.speakEnd.push(t)}})(),(e=>{let t=0;const a=[...w.value.standby,...w.value.speakStart,...w.value.speakLoop,...w.value.speakEnd],checkLoaded=()=>{t++,t>=a.length&&e()};a.forEach(e=>{e.complete?checkLoaded():(e.onload=checkLoaded,e.onerror=checkLoaded)})})(()=>{draw(w.value.standby[0]),s("loaded",v.value)})})},A=t.ref(null),R=t.ref(null),audioToText=async e=>{var t;const a=new FormData;a.append("file",e,"recorded_audio.wav");try{const e=await fetch("http://192.168.3.182:9988/transcribe",{method:"POST",body:a});(null==(t=e.data)?void 0:t.text)||e.text}catch(o){}},createWavBlob=(e,t,a,o)=>{const r=a*(o/8),s=e.byteLength,l=new ArrayBuffer(44+s),u=new DataView(l);u.setUint8(0,82),u.setUint8(1,73),u.setUint8(2,70),u.setUint8(3,70),u.setUint32(4,36+s,!0),u.setUint8(8,87),u.setUint8(9,65),u.setUint8(10,86),u.setUint8(11,69),u.setUint8(12,102),u.setUint8(13,109),u.setUint8(14,116),u.setUint8(15,32),u.setUint32(16,16,!0),u.setUint16(20,1,!0),u.setUint16(22,a,!0),u.setUint32(24,t,!0),u.setUint32(28,t*r,!0),u.setUint16(32,r,!0),u.setUint16(34,o,!0),u.setUint8(36,100),u.setUint8(37,97),u.setUint8(38,116),u.setUint8(39,97),u.setUint32(40,s,!0);const c=new Uint8Array(e);return new Uint8Array(l,44).set(c),new Blob([l],{type:"audio/wav"})};let S=t.ref(null);return a({standby:standby,speak:speak,stopSpeaking:stopSpeaking,pause:()=>{U.value||(U.value=!0,x.value={state:b.value,frameIndex:g.value,loopDirection:k.value},s("paused"))},resume:()=>{U.value&&(U.value=!1,m.value=null,x.value&&(b.value=x.value.state,g.value=x.value.frameIndex,k.value=x.value.loopDirection),s("resumed"))},playTTS:async e=>{var t,a,o,r,s,l,u,c;if(!e||!(null==(t=v.value)?void 0:t.isMuted))return;A.value&&(A.value.pause(),A.value=null),R.value=Date.now();const f=R.value;try{const t=e.replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"").replace(/[#*_~]/g,"").replace(/\n+/g,",").replace(/\s+/g," ").replace(/[,。!?]{2,}/g,",").trim();if(!t)return;const g="http://192.168.3.182:8002",m="session_"+Date.now();let w=(null==(o=null==(a=v.value)?void 0:a.speakSet)?void 0:o.speed)||1,b=(null==(s=null==(r=v.value)?void 0:r.speakSet)?void 0:s.age)||"Young Adult / 青年";const k=[t,"Auto",32,2,!0,w,null,!0,!0,(null==(u=null==(l=v.value)?void 0:l.speakSet)?void 0:u.sex)||"Female / 女",b,"Auto","Auto","Auto","Auto"],U=await fetch(`${g}/gradio_api/queue/join`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:k,session_hash:m,fn_index:1,trigger_id:50})});await U.json();let x="",S=60,_=1e3;for(;!x&&S>0;){await new Promise(e=>setTimeout(e,_)),S--;try{const e=await fetch(`${g}/gradio_api/queue/data?session_hash=${m}`),t=(await e.text()).split("\n");for(const a of t){const e=a.trim();if(e.startsWith("data: "))try{const t=JSON.parse(e.replace("data: ",""));if("process_completed"===t.msg&&(null==(c=t.output)?void 0:c.data)){const e=t.output.data[0];if(null==e?void 0:e.url)x=e.url;else if(null==e?void 0:e.path)x=`${g}/gradio_api/file=${e.path}`;else if("string"==typeof e)x=e.startsWith("http")?e:`${g}/gradio_api/file=${e}`;else if(Array.isArray(e)&&e.length>=2){const t=e[0],a=e[1];if(t&&a&&Array.isArray(a)){const e=new ArrayBuffer(2*a.length),o=new DataView(e);for(let t=0;t<a.length;t++)o.setInt16(2*t,a[t],!0);const r=createWavBlob(e,t,1,16),s=URL.createObjectURL(r);return R.value!==f?void URL.revokeObjectURL(s):(A.value=new Audio(s),A.value.onplaying=()=>{speak()},A.value.onended=()=>{stopSpeaking(),A.value=null,URL.revokeObjectURL(s)},A.value.onerror=()=>{stopSpeaking(),A.value=null,URL.revokeObjectURL(s)},void(await A.value.play()))}}break}if("process_error"===t.msg)return void standby()}catch(y){}}}catch(y){}}if(x){if(x.startsWith("/")&&(x=g+x),R.value!==f)return;const e=await fetch(x),t=await e.blob(),a=URL.createObjectURL(t);A.value=new Audio(a),A.value.onplaying=()=>{speak()},A.value.onended=()=>{stopSpeaking(),A.value=null,URL.revokeObjectURL(a)},A.value.onerror=()=>{stopSpeaking(),A.value=null,URL.revokeObjectURL(a)},await A.value.play()}else standby()}catch(y){standby()}},startRecord:async()=>{try{S.value&&S.value.stop(),await S.value.start()}catch(e){}},stopRecord:async()=>{if(S.value)try{S.value.stop();const e=S.value.getWAVBlob();if(e.size<1e3)return;const t=await audioToText(e);s("audio-ready",t)}catch(e){}}}),t.watch(()=>r.humans,e=>{e&&e.length>0&&!v.value&&init()},{deep:!0}),t.onMounted(()=>{S.value||(S.value=new f({sampleBits:16,sampleRate:16e3,numChannels:1})),init()}),t.onUnmounted(()=>{stop(),S.value&&S.value.stop()}),(e,a)=>(t.openBlock(),t.createElementBlock("div",{class:"digital-human",ref_key:"containerRef",ref:l},[t.createElementVNode("canvas",{ref_key:"canvasRef",ref:u},null,512)],512))}},[["__scopeId","data-v-132811db"]]);v.install=e=>e.component("DigitalHuman",v);const y=[a,u,v],g={install:e=>{y.forEach(t=>e.use(t))}};e.DemoButton=a,e.DemoInput=u,e.DigitalHuman=v,e.default=g,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .demo-btn[data-v-9a48516a]{padding:6px 14px;border-radius:4px;border:none;cursor:pointer;font-size:14px}.primary[data-v-9a48516a]{background:#409eff;color:#fff}.success[data-v-9a48516a]{background:#67c23a;color:#fff}.warning[data-v-9a48516a]{background:#e6a23c;color:#fff}.demo-input-wrap[data-v-28a3493c]{display:inline-flex;align-items:center;border:1px solid #dcdcdc;border-radius:4px;padding:0 10px}.demo-input-wrap[data-v-28a3493c]:focus-within{border-color:#409eff}.demo-input[data-v-28a3493c]{border:none;outline:none;padding:8px 6px;flex:1}.prefix[data-v-28a3493c],.suffix[data-v-28a3493c]{color:#909399}.digital-human[data-v-132811db]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.digital-human canvas[data-v-132811db]{max-width:100%;max-height:100%}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "ruiyun-human",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "description": "数字人初步实现",
6
+ "main": "./dist/ruiyun-human.umd.js",
7
+ "module": "./dist/ruiyun-human.es.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/ruiyun-human.es.js",
11
+ "require": "./dist/ruiyun-human.umd.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "dev": "vite",
19
+ "build": "vite build",
20
+ "preview": "vite preview"
21
+ },
22
+ "peerDependencies": {
23
+ "vue": "^3.2.0 || ^3.3.0 || ^3.4.0"
24
+ },
25
+ "devDependencies": {
26
+ "@tailwindcss/postcss": "^4.3.3",
27
+ "@vitejs/plugin-vue": "^5.0.4",
28
+ "autoprefixer": "^10.5.4",
29
+ "postcss": "^8.5.20",
30
+ "tailwindcss": "^4.3.3",
31
+ "terser": "^5.49.0",
32
+ "vite": "^5.1.4",
33
+ "vue": "^3.4.21"
34
+ },
35
+ "dependencies": {
36
+ "js-audio-recorder": "^1.0.7",
37
+ "vue-router": "^4.6.4"
38
+ }
39
+ }