@inupedia/spotlight-vue 0.9.0 → 0.9.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.
- package/dist/assets/spotlight-vue.css +1 -1
- package/dist/avatar/speech/spotlightSpeech.d.ts.map +1 -1
- package/dist/avatar/speech/spotlightSpeech.js +20 -31
- package/dist/avatar/voice/micAccess.d.ts +4 -0
- package/dist/avatar/voice/micAccess.d.ts.map +1 -0
- package/dist/avatar/voice/micAccess.js +26 -0
- package/dist/avatar/voice/phonePairing.d.ts +14 -0
- package/dist/avatar/voice/phonePairing.d.ts.map +1 -0
- package/dist/avatar/voice/phonePairing.js +30 -0
- package/dist/avatar/voice/usePhoneVoicePairing.d.ts +17 -0
- package/dist/avatar/voice/usePhoneVoicePairing.d.ts.map +1 -0
- package/dist/avatar/voice/usePhoneVoicePairing.js +88 -0
- package/dist/components/Live2dPanel.vue.d.ts +20 -0
- package/dist/components/Live2dPanel.vue.d.ts.map +1 -1
- package/dist/components/Live2dPanel.vue.js +1 -1
- package/dist/components/Live2dPanel2.vue.js +167 -62
- package/dist/components/SpotlightShell.vue.d.ts.map +1 -1
- package/dist/components/SpotlightShell.vue.js +2 -2
- package/dist/components/SpotlightShell2.vue.js +268 -255
- package/dist/node_modules/.pnpm/uqr@0.1.3/node_modules/uqr/dist/index.js +504 -0
- package/package.json +4 -3
|
@@ -1,407 +1,420 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { VoiceTurnController as
|
|
3
|
-
import { stopTtsBufferPlayback as
|
|
4
|
-
import { SpotlightSpeechService as
|
|
5
|
-
import { storeToRefs as
|
|
6
|
-
import { useSpotlightStore as
|
|
7
|
-
import { useSpotlightAvatarConfig as
|
|
8
|
-
import { unlockVoicePlayback as
|
|
9
|
-
import { shouldAbortVoiceOnPanelHide as
|
|
10
|
-
import { directorPhaseFromTurn as
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
1
|
+
import { defineComponent as xe, computed as R, ref as h, watch as te, onMounted as He, onUnmounted as Ke, openBlock as N, createElementBlock as re, Fragment as _e, createVNode as Re, unref as l, createBlock as Fe, createElementVNode as ie, createCommentVNode as Ie, nextTick as oe } from "vue";
|
|
2
|
+
import { VoiceTurnController as Me, sanitizeSpokenText as De, drainSpokenClips as ae, packSpokenSentences as Oe } from "@inupedia/spotlight-protocol";
|
|
3
|
+
import { stopTtsBufferPlayback as Ue, decodeTtsAudioFromBlob as qe, getTtsPlaybackContext as Ne, appendSilenceToAudioBuffer as $e, playTtsAudioBuffer as ze, TTS_CLIP_SILENCE_MS as le } from "../avatar/speech/live2dTtsPlayback.js";
|
|
4
|
+
import { SpotlightSpeechService as Ge, hasSpotlightSpeechConfig as We } from "../avatar/speech/spotlightSpeech.js";
|
|
5
|
+
import { storeToRefs as Ye } from "pinia";
|
|
6
|
+
import { useSpotlightStore as Qe } from "../store/spotlightStore.js";
|
|
7
|
+
import { useSpotlightAvatarConfig as je } from "../avatar/config.js";
|
|
8
|
+
import { unlockVoicePlayback as Je } from "../avatar/voice/voiceSession.js";
|
|
9
|
+
import { shouldAbortVoiceOnPanelHide as Xe } from "../avatar/voice/panelHidePolicy.js";
|
|
10
|
+
import { directorPhaseFromTurn as Ze } from "../avatar/voice/avatarDirector.js";
|
|
11
|
+
import { microphoneAccessMessage as $ } from "../avatar/voice/micAccess.js";
|
|
12
|
+
import { usePhoneVoicePairing as en } from "../avatar/voice/usePhoneVoicePairing.js";
|
|
13
|
+
import { useAgentSessionStore as nn } from "../session/agentSession.js";
|
|
14
|
+
import tn from "./SpotlightRoot.vue.js";
|
|
15
|
+
import rn from "./Live2dPanel.vue.js";
|
|
16
|
+
import { useLive2dOverlayStore as on } from "../store/live2dOverlayStore.js";
|
|
17
|
+
import { useLive2dSpeechStore as an } from "../store/live2dSpeechStore.js";
|
|
18
|
+
import { useLive2dVoiceChannelStore as ln } from "../store/live2dVoiceChannelStore.js";
|
|
19
|
+
import { devWarn as sn } from "../utils/devConsole.js";
|
|
20
|
+
const se = "Backquote", cn = "`", An = /* @__PURE__ */ xe({
|
|
19
21
|
__name: "SpotlightShell",
|
|
20
22
|
props: {
|
|
21
23
|
avatarEnabled: { type: Boolean, default: !1 }
|
|
22
24
|
},
|
|
23
25
|
setup(O) {
|
|
24
|
-
const
|
|
25
|
-
() =>
|
|
26
|
-
),
|
|
27
|
-
() =>
|
|
28
|
-
),
|
|
26
|
+
const S = O, F = je(), ce = R(
|
|
27
|
+
() => F.deckKicker?.trim() || "SPOTLIGHT"
|
|
28
|
+
), I = R(
|
|
29
|
+
() => F.greetingText?.trim() || "您好,我是 Spotlight 助手"
|
|
30
|
+
), t = Qe(), B = on(), { visible: g } = Ye(B), c = an(), u = ln(), w = new Ge(), L = h(null), p = h(!1), k = h(!1), E = h(!1), x = h(null), m = h(null), b = h(0), P = h(!1), z = R(
|
|
29
31
|
() => Math.max(
|
|
30
32
|
0,
|
|
31
|
-
|
|
33
|
+
F.briefingKeepLastMs ?? 0
|
|
32
34
|
)
|
|
33
35
|
);
|
|
34
|
-
let
|
|
35
|
-
const
|
|
36
|
-
let
|
|
37
|
-
const
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
let T = null;
|
|
37
|
+
const y = h(!1);
|
|
38
|
+
let H = Promise.resolve(), M = 0;
|
|
39
|
+
const s = new Me(), K = h(!1);
|
|
40
|
+
let U = 0, f = "", V = 0;
|
|
41
|
+
s.onAbort(async () => {
|
|
42
|
+
t.cancelPipeline(), K.value = !1, f = "", V = 0, C(), _(), c.reset(), import("../avatar/spine/live2dApp.js").then(
|
|
41
43
|
(e) => e.stopLive2dLipSync()
|
|
42
44
|
);
|
|
43
45
|
});
|
|
44
|
-
const
|
|
45
|
-
const e =
|
|
46
|
-
return
|
|
46
|
+
const ue = R(() => t.showThinkingBar ? !S.avatarEnabled || !g.value || t.pipelinePhase === "running" || P.value ? !0 : t.pipelinePhase === "done" : !1), pe = R(() => {
|
|
47
|
+
const e = t.agentSteps.length === 1 && t.agentSteps[0]?.label === "回答";
|
|
48
|
+
return t.pipelinePhase === "running" || e || P.value;
|
|
47
49
|
});
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
+
function fe() {
|
|
51
|
+
P.value = !1, g.value && (t.showThinkingBar = !1);
|
|
50
52
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
+
function G() {
|
|
54
|
+
L.value != null && (window.clearTimeout(L.value), L.value = null);
|
|
53
55
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
+
function _() {
|
|
57
|
+
G(), x.value && (x.value.abort(), x.value = null), k.value = !1, E.value = !1, p.value = !1, y.value = !1, u.reset(), w.cancel();
|
|
56
58
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
+
function C() {
|
|
60
|
+
T && (T.abort(), T = null), m.value && (m.value.abort(), m.value = null), D(), c.reset(), import("../avatar/spine/live2dApp.js").then(
|
|
59
61
|
(e) => e.stopLive2dLipSync()
|
|
60
62
|
);
|
|
61
63
|
}
|
|
62
|
-
function
|
|
63
|
-
return e <= 0 ? Promise.resolve() : new Promise((
|
|
64
|
+
function ve(e, n) {
|
|
65
|
+
return e <= 0 ? Promise.resolve() : new Promise((r, i) => {
|
|
64
66
|
const a = window.setTimeout(() => {
|
|
65
|
-
|
|
67
|
+
n?.removeEventListener("abort", o), r();
|
|
66
68
|
}, e), o = () => {
|
|
67
|
-
window.clearTimeout(a),
|
|
69
|
+
window.clearTimeout(a), i(new DOMException("Aborted", "AbortError"));
|
|
68
70
|
};
|
|
69
|
-
if (
|
|
71
|
+
if (n?.aborted) {
|
|
70
72
|
o();
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
n?.addEventListener("abort", o, { once: !0 });
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
|
-
async function
|
|
77
|
-
if (!
|
|
78
|
-
|
|
79
|
-
const e =
|
|
80
|
-
if (
|
|
81
|
-
|
|
78
|
+
async function de() {
|
|
79
|
+
if (!g.value || t.pipelinePhase === "running") return;
|
|
80
|
+
C(), b.value += 1;
|
|
81
|
+
const e = b.value, n = new AbortController();
|
|
82
|
+
if (T = n, !We()) {
|
|
83
|
+
T = null, await oe(), (await import("../avatar/spine/live2dApp.js")).playLive2dHello(), c.start(I.value, { instant: !0 }), c.reset();
|
|
82
84
|
return;
|
|
83
85
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
const r = w.synthesize(
|
|
87
|
+
I.value,
|
|
88
|
+
n.signal
|
|
87
89
|
);
|
|
88
|
-
if (await
|
|
89
|
-
requestAnimationFrame(() =>
|
|
90
|
-
}), !!v(
|
|
90
|
+
if (await oe(), await new Promise((i) => {
|
|
91
|
+
requestAnimationFrame(() => i());
|
|
92
|
+
}), !!v(n, e))
|
|
91
93
|
try {
|
|
92
|
-
const { blob:
|
|
93
|
-
if (!v(
|
|
94
|
-
await
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
const { blob: i } = await r;
|
|
95
|
+
if (!v(n, e)) return;
|
|
96
|
+
await J(
|
|
97
|
+
I.value,
|
|
98
|
+
i,
|
|
99
|
+
n,
|
|
98
100
|
e,
|
|
99
101
|
{ instantText: !0, playHelloWithSpeech: !0 }
|
|
100
102
|
);
|
|
101
|
-
} catch (
|
|
102
|
-
if (
|
|
103
|
-
const a =
|
|
104
|
-
|
|
103
|
+
} catch (i) {
|
|
104
|
+
if (n.signal.aborted) return;
|
|
105
|
+
const a = i instanceof Error ? i.message : "数字人招呼语音失败,请稍后重试。";
|
|
106
|
+
sn("[live2d-greeting]", a), v(n, e) && ((await import("../avatar/spine/live2dApp.js")).playLive2dHello(), c.start(I.value, { instant: !0 }), c.reset());
|
|
105
107
|
} finally {
|
|
106
|
-
|
|
108
|
+
T === n && (T = null);
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
+
function D() {
|
|
112
|
+
Ue();
|
|
111
113
|
}
|
|
112
|
-
function
|
|
114
|
+
function W() {
|
|
113
115
|
return globalThis.crypto?.randomUUID?.() ?? `turn-${Date.now()}-${Math.random()}`;
|
|
114
116
|
}
|
|
115
|
-
function
|
|
116
|
-
const e =
|
|
117
|
-
for (let
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
return
|
|
117
|
+
function he() {
|
|
118
|
+
const e = nn();
|
|
119
|
+
for (let n = e.conversationHistory.length - 1; n >= 0; n -= 1) {
|
|
120
|
+
const r = e.conversationHistory[n];
|
|
121
|
+
if (r?.role === "assistant" && r.content.trim())
|
|
122
|
+
return r.content.trim();
|
|
121
123
|
}
|
|
122
124
|
return "";
|
|
123
125
|
}
|
|
124
|
-
function
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
function me(e) {
|
|
127
|
+
const n = Oe(e);
|
|
128
|
+
n.length !== 0 && (s.setPhase("speaking"), n.forEach((r, i) => {
|
|
129
|
+
j({ text: r });
|
|
128
130
|
}));
|
|
129
131
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
+
function ge() {
|
|
133
|
+
C(), b.value += 1;
|
|
132
134
|
const e = new AbortController();
|
|
133
|
-
|
|
135
|
+
m.value = e, H = Promise.resolve(), M = 0, f = "", V = 0, P.value = !0, K.value = !0, W(), U = 0;
|
|
134
136
|
}
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const a =
|
|
137
|
+
function Y(e) {
|
|
138
|
+
const n = m.value;
|
|
139
|
+
if (!n || n.signal.aborted || !e) return;
|
|
140
|
+
const r = b.value, i = V;
|
|
141
|
+
V += 1;
|
|
142
|
+
const a = w.synthesize(e, n.signal).then(
|
|
141
143
|
(o) => ({ blob: o.blob, error: null }),
|
|
142
144
|
(o) => ({ blob: null, error: o })
|
|
143
145
|
);
|
|
144
|
-
|
|
146
|
+
M += 1, H = H.then(async () => {
|
|
145
147
|
const o = await a;
|
|
146
148
|
if (o.error) throw o.error;
|
|
147
|
-
if (!o.blob || !v(
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
await
|
|
149
|
+
if (!o.blob || !v(n, r)) return;
|
|
150
|
+
i === 0 && fe();
|
|
151
|
+
const A = V > i + 1 || f.length > 0 || t.pipelinePhase === "running" || t.loading;
|
|
152
|
+
await J(
|
|
151
153
|
e,
|
|
152
154
|
o.blob,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
n,
|
|
156
|
+
r,
|
|
155
157
|
{
|
|
156
158
|
instantText: !0,
|
|
157
|
-
hasFollowingClip:
|
|
159
|
+
hasFollowingClip: A
|
|
158
160
|
}
|
|
159
161
|
);
|
|
160
162
|
}).catch((o) => {
|
|
161
|
-
|
|
163
|
+
n.signal.aborted || (t.error = o instanceof Error ? o.message : "数字人语音播放失败,请稍后重试。");
|
|
162
164
|
});
|
|
163
165
|
}
|
|
164
|
-
function
|
|
166
|
+
function Q() {
|
|
165
167
|
if (!f) return;
|
|
166
|
-
const e =
|
|
168
|
+
const e = ae(f, { force: !0 });
|
|
167
169
|
f = "";
|
|
168
|
-
for (const
|
|
170
|
+
for (const n of e.ready) Y(n);
|
|
169
171
|
}
|
|
170
|
-
function
|
|
171
|
-
e.generation != null && e.generation !==
|
|
172
|
-
const
|
|
173
|
-
if (!
|
|
174
|
-
f +=
|
|
175
|
-
const
|
|
176
|
-
f =
|
|
177
|
-
for (const
|
|
172
|
+
function j(e) {
|
|
173
|
+
e.generation != null && e.generation !== U && (U = e.generation, W(), H = Promise.resolve(), f = "", V = 0);
|
|
174
|
+
const n = De(e.text);
|
|
175
|
+
if (!n) return;
|
|
176
|
+
f += n;
|
|
177
|
+
const r = ae(f);
|
|
178
|
+
f = r.rest;
|
|
179
|
+
for (const i of r.ready) Y(i);
|
|
178
180
|
}
|
|
179
|
-
async function
|
|
180
|
-
const e =
|
|
181
|
+
async function be() {
|
|
182
|
+
const e = m.value;
|
|
181
183
|
if (!e) {
|
|
182
|
-
|
|
184
|
+
K.value = !1;
|
|
183
185
|
return;
|
|
184
186
|
}
|
|
185
|
-
const
|
|
186
|
-
if (await
|
|
187
|
-
if (
|
|
187
|
+
const n = b.value;
|
|
188
|
+
if (await H, P.value = !1, (await import("../avatar/spine/live2dApp.js")).stopLive2dLipSync(), v(e, n)) {
|
|
189
|
+
if (z.value > 0 && M > 0)
|
|
188
190
|
try {
|
|
189
|
-
await
|
|
191
|
+
await ve(z.value, e.signal);
|
|
190
192
|
} catch {
|
|
191
193
|
}
|
|
192
|
-
v(e,
|
|
194
|
+
v(e, n) && c.reset();
|
|
193
195
|
}
|
|
194
|
-
|
|
196
|
+
m.value === e && (m.value = null), K.value = !1;
|
|
195
197
|
}
|
|
196
|
-
function v(e,
|
|
197
|
-
return !e.signal.aborted &&
|
|
198
|
+
function v(e, n) {
|
|
199
|
+
return !e.signal.aborted && b.value === n;
|
|
198
200
|
}
|
|
199
|
-
async function
|
|
200
|
-
if (!v(
|
|
201
|
+
async function J(e, n, r, i, a) {
|
|
202
|
+
if (!v(r, i)) return;
|
|
201
203
|
const o = a?.hasFollowingClip ?? !1;
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
if (!v(
|
|
205
|
-
a?.playHelloWithSpeech &&
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
o ?
|
|
204
|
+
D();
|
|
205
|
+
const A = await import("../avatar/spine/live2dApp.js"), { audioBuffer: Ee, envelope: Ve } = await qe(n);
|
|
206
|
+
if (!v(r, i)) return;
|
|
207
|
+
a?.playHelloWithSpeech && A.playLive2dHello(), c.start(e, { instant: a?.instantText ?? !0 });
|
|
208
|
+
const Ae = Ne(), Be = $e(
|
|
209
|
+
Ae,
|
|
210
|
+
Ee,
|
|
211
|
+
o ? le : Math.round(le / 2)
|
|
210
212
|
);
|
|
211
213
|
try {
|
|
212
|
-
await
|
|
213
|
-
onStart: (
|
|
214
|
-
|
|
214
|
+
await ze(Be, r.signal, {
|
|
215
|
+
onStart: (q) => {
|
|
216
|
+
A.bindLive2dLipSyncToClock(q, Ve);
|
|
215
217
|
}
|
|
216
218
|
});
|
|
217
|
-
} catch (
|
|
218
|
-
throw
|
|
219
|
+
} catch (q) {
|
|
220
|
+
throw A.stopLive2dLipSync(), D(), q;
|
|
219
221
|
}
|
|
220
|
-
o ||
|
|
222
|
+
o || A.stopLive2dLipSync(), D(), v(r, i) && (o || c.reset());
|
|
221
223
|
}
|
|
222
|
-
function
|
|
223
|
-
return !
|
|
224
|
+
function X() {
|
|
225
|
+
return !S.avatarEnabled || !g.value ? !1 : !t.loading && !E.value && !k.value;
|
|
224
226
|
}
|
|
225
|
-
function
|
|
226
|
-
return
|
|
227
|
+
function Z() {
|
|
228
|
+
return X() && !t.visible;
|
|
227
229
|
}
|
|
228
|
-
async function
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
|
|
232
|
-
const
|
|
230
|
+
async function ee(e) {
|
|
231
|
+
const n = e.trim();
|
|
232
|
+
if (!n) return;
|
|
233
|
+
t.prompt = n, s.setPhase("thinking"), ge();
|
|
234
|
+
const r = m.value, i = b.value;
|
|
233
235
|
try {
|
|
234
|
-
await
|
|
236
|
+
await t.submit({
|
|
235
237
|
interactionMode: "voice",
|
|
236
|
-
onVoiceSentence:
|
|
238
|
+
onVoiceSentence: j
|
|
237
239
|
});
|
|
238
240
|
} finally {
|
|
239
|
-
const a = !!
|
|
240
|
-
if (
|
|
241
|
-
const o =
|
|
242
|
-
o &&
|
|
241
|
+
const a = !!r && v(r, i);
|
|
242
|
+
if (Q(), a && M === 0) {
|
|
243
|
+
const o = he();
|
|
244
|
+
o && me(o), Q();
|
|
243
245
|
}
|
|
244
|
-
await
|
|
246
|
+
await be(), a && (s.resetTo("idle"), u.reset());
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
const d = en({
|
|
250
|
+
enabled: S.avatarEnabled,
|
|
251
|
+
onUtterance: ee
|
|
252
|
+
});
|
|
253
|
+
async function ne() {
|
|
254
|
+
if (k.value) return;
|
|
255
|
+
const e = y.value;
|
|
256
|
+
p.value = !1, e && u.setTranscribing(!0), k.value = !0;
|
|
257
|
+
const n = new AbortController();
|
|
258
|
+
x.value = n;
|
|
253
259
|
try {
|
|
254
|
-
const { text:
|
|
260
|
+
const { text: r } = await w.stopAndTranscribe(n.signal), i = r.trim();
|
|
255
261
|
if (e) {
|
|
256
|
-
if (
|
|
257
|
-
|
|
262
|
+
if (y.value = !1, u.setTranscribing(!1), !i) {
|
|
263
|
+
t.error = "没识别到内容,请靠近麦克风再说一次。";
|
|
258
264
|
return;
|
|
259
265
|
}
|
|
260
|
-
await
|
|
266
|
+
await ee(i);
|
|
261
267
|
return;
|
|
262
268
|
}
|
|
263
|
-
const a =
|
|
264
|
-
|
|
265
|
-
} catch (
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
n.error = r;
|
|
269
|
+
const a = t.prompt.trim();
|
|
270
|
+
t.prompt = a ? `${a} ${r}` : r;
|
|
271
|
+
} catch (r) {
|
|
272
|
+
if (n.signal.aborted) return;
|
|
273
|
+
t.error = $(r) || "语音识别失败,请重试。";
|
|
269
274
|
} finally {
|
|
270
|
-
|
|
275
|
+
x.value = null, k.value = !1, p.value = !1, y.value = !1, u.reset();
|
|
271
276
|
}
|
|
272
277
|
}
|
|
273
|
-
function
|
|
278
|
+
function ye(e) {
|
|
274
279
|
if (e.repeat || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
|
|
275
|
-
const
|
|
276
|
-
!
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
if (!(!
|
|
280
|
+
const n = Z();
|
|
281
|
+
!t.visible && !n || t.visible && t.loading || (e.preventDefault(), !(L.value != null || p.value) && (L.value = window.setTimeout(async () => {
|
|
282
|
+
L.value = null;
|
|
283
|
+
const r = Z();
|
|
284
|
+
if (!(!t.visible && !r) && !(t.visible && t.loading))
|
|
280
285
|
try {
|
|
281
|
-
await
|
|
282
|
-
} catch (
|
|
283
|
-
|
|
284
|
-
n.error = a, u.value = !1, m.value = !1, c.reset();
|
|
286
|
+
await w.startRecording(), p.value = !0, y.value = r, r ? u.setRecording(!0) : u.reset(), t.error = "";
|
|
287
|
+
} catch (i) {
|
|
288
|
+
t.error = $(i), p.value = !1, y.value = !1, u.reset();
|
|
285
289
|
}
|
|
286
290
|
}, 450)));
|
|
287
291
|
}
|
|
288
|
-
async function
|
|
289
|
-
if (!(!
|
|
290
|
-
|
|
292
|
+
async function Se() {
|
|
293
|
+
if (!(!X() || E.value)) {
|
|
294
|
+
E.value = !0;
|
|
291
295
|
try {
|
|
292
|
-
if (
|
|
293
|
-
|
|
296
|
+
if (C(), await w.startRecording(), !g.value) {
|
|
297
|
+
w.cancel();
|
|
294
298
|
return;
|
|
295
299
|
}
|
|
296
|
-
|
|
300
|
+
p.value = !0, y.value = !0, u.setRecording(!0), t.error = "";
|
|
297
301
|
} catch (e) {
|
|
298
|
-
|
|
299
|
-
n.error = t, u.value = !1, m.value = !1, c.reset();
|
|
302
|
+
t.error = $(e), p.value = !1, y.value = !1, u.reset();
|
|
300
303
|
} finally {
|
|
301
|
-
|
|
304
|
+
E.value = !1;
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
}
|
|
305
|
-
function
|
|
306
|
-
|
|
308
|
+
function we() {
|
|
309
|
+
p.value && ne();
|
|
307
310
|
}
|
|
308
|
-
function
|
|
309
|
-
if (e.code !==
|
|
311
|
+
function ke(e) {
|
|
312
|
+
if (e.code !== se || !t.visible && !p.value) return;
|
|
310
313
|
e.preventDefault();
|
|
311
|
-
const
|
|
312
|
-
|
|
314
|
+
const n = p.value;
|
|
315
|
+
G(), n && ne();
|
|
313
316
|
}
|
|
314
|
-
function
|
|
315
|
-
if (e.code ===
|
|
316
|
-
|
|
317
|
+
function Pe(e) {
|
|
318
|
+
if (e.code === se) {
|
|
319
|
+
ye(e);
|
|
317
320
|
return;
|
|
318
321
|
}
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
function we() {
|
|
323
|
-
E.show();
|
|
322
|
+
const n = e.key.toLowerCase(), r = e.metaKey || e.ctrlKey;
|
|
323
|
+
S.avatarEnabled && r && n === "l" && (e.preventDefault(), B.toggle());
|
|
324
324
|
}
|
|
325
325
|
function Te() {
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
B.show();
|
|
327
|
+
}
|
|
328
|
+
function Ce() {
|
|
329
|
+
s.abort("escape").then(() => {
|
|
330
|
+
P.value = !1, b.value += 1, C(), c.reset(), t.showThinkingBar ? t.closeThinking() : t.visible && t.close();
|
|
328
331
|
});
|
|
329
332
|
}
|
|
330
|
-
function
|
|
333
|
+
function Le(e) {
|
|
331
334
|
if (!e) {
|
|
332
|
-
if (!
|
|
333
|
-
loading:
|
|
334
|
-
pipelinePhase:
|
|
335
|
+
if (!Xe({
|
|
336
|
+
loading: t.loading,
|
|
337
|
+
pipelinePhase: t.pipelinePhase
|
|
335
338
|
})) {
|
|
336
|
-
|
|
339
|
+
_();
|
|
337
340
|
return;
|
|
338
341
|
}
|
|
339
|
-
|
|
342
|
+
s.abort("panel_close"), _(), g.value && t.prepareLive2dVoiceChannel();
|
|
340
343
|
}
|
|
341
344
|
}
|
|
342
|
-
return
|
|
343
|
-
if (
|
|
345
|
+
return te(g, (e) => {
|
|
346
|
+
if (S.avatarEnabled) {
|
|
344
347
|
if (!e) {
|
|
345
|
-
|
|
348
|
+
P.value = !1, s.abort("avatar_close"), _(), C(), c.reset(), u.reset();
|
|
346
349
|
return;
|
|
347
350
|
}
|
|
348
|
-
|
|
351
|
+
t.visible || t.prepareLive2dVoiceChannel(), Je(), de();
|
|
349
352
|
}
|
|
350
|
-
}),
|
|
351
|
-
() =>
|
|
352
|
-
loading:
|
|
353
|
-
speaking:
|
|
354
|
-
toolRunning:
|
|
353
|
+
}), te(
|
|
354
|
+
() => Ze({
|
|
355
|
+
loading: t.loading,
|
|
356
|
+
speaking: s.phase === "speaking" || K.value,
|
|
357
|
+
toolRunning: t.agentSteps.some(
|
|
355
358
|
(e) => e.toolCalls?.some(
|
|
356
|
-
(
|
|
359
|
+
(n) => n.status === "running" || n.status === "pending"
|
|
357
360
|
)
|
|
358
361
|
),
|
|
359
|
-
interrupted:
|
|
362
|
+
interrupted: s.phase === "interrupted"
|
|
360
363
|
}),
|
|
361
364
|
(e) => {
|
|
362
|
-
|
|
365
|
+
s.phase === "interrupted" || s.phase === "error" || s.setPhase(e);
|
|
363
366
|
}
|
|
364
|
-
),
|
|
365
|
-
|
|
366
|
-
}),
|
|
367
|
-
|
|
368
|
-
}), (e,
|
|
369
|
-
|
|
370
|
-
"deck-kicker":
|
|
371
|
-
"voice-hold-active":
|
|
372
|
-
"speech-pending":
|
|
373
|
-
"voice-key-label":
|
|
374
|
-
"show-thinking":
|
|
375
|
-
"thinking-centered":
|
|
376
|
-
"on-escape":
|
|
377
|
-
"on-keydown":
|
|
378
|
-
"on-keyup":
|
|
379
|
-
onVisibleChange:
|
|
367
|
+
), He(() => {
|
|
368
|
+
S.avatarEnabled && F.initiallyVisible && B.show(), S.avatarEnabled && d.startPolling();
|
|
369
|
+
}), Ke(() => {
|
|
370
|
+
s.abort("session_end"), _(), C(), c.reset(), u.reset();
|
|
371
|
+
}), (e, n) => (N(), re(_e, null, [
|
|
372
|
+
Re(tn, {
|
|
373
|
+
"deck-kicker": ce.value,
|
|
374
|
+
"voice-hold-active": p.value,
|
|
375
|
+
"speech-pending": k.value,
|
|
376
|
+
"voice-key-label": cn,
|
|
377
|
+
"show-thinking": ue.value,
|
|
378
|
+
"thinking-centered": pe.value,
|
|
379
|
+
"on-escape": Ce,
|
|
380
|
+
"on-keydown": Pe,
|
|
381
|
+
"on-keyup": ke,
|
|
382
|
+
onVisibleChange: Le
|
|
380
383
|
}, null, 8, ["deck-kicker", "voice-hold-active", "speech-pending", "show-thinking", "thinking-centered"]),
|
|
381
|
-
O.avatarEnabled &&
|
|
384
|
+
O.avatarEnabled && l(g) ? (N(), Fe(rn, {
|
|
382
385
|
key: 0,
|
|
383
|
-
"voice-disabled":
|
|
384
|
-
"voice-error":
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
"voice-disabled": l(t).loading || k.value || E.value,
|
|
387
|
+
"voice-error": l(t).error,
|
|
388
|
+
"phone-pair-available": l(d).canShow.value,
|
|
389
|
+
"phone-pair-open": l(d).panelOpen.value,
|
|
390
|
+
"phone-pair-qr": l(d).qrSvg.value,
|
|
391
|
+
"phone-pair-url": l(d).pairUrl.value,
|
|
392
|
+
"phone-pair-error": l(d).pairError.value,
|
|
393
|
+
"phone-connected": l(d).phoneConnected.value,
|
|
394
|
+
onVoiceStart: Se,
|
|
395
|
+
onVoiceStop: we,
|
|
396
|
+
onPhonePair: l(d).openPanel,
|
|
397
|
+
onPhonePairClose: l(d).closePanel,
|
|
398
|
+
onDismissError: n[0] || (n[0] = (r) => l(t).error = ""),
|
|
399
|
+
onDismissPairError: l(d).clearPairError,
|
|
400
|
+
onClose: l(B).hide
|
|
401
|
+
}, null, 8, ["voice-disabled", "voice-error", "phone-pair-available", "phone-pair-open", "phone-pair-qr", "phone-pair-url", "phone-pair-error", "phone-connected", "onPhonePair", "onPhonePairClose", "onDismissPairError", "onClose"])) : O.avatarEnabled ? (N(), re("button", {
|
|
389
402
|
key: 1,
|
|
390
403
|
type: "button",
|
|
391
404
|
class: "spotlight-avatar-reopen",
|
|
392
405
|
"aria-label": "再次打开数字人小滴",
|
|
393
406
|
title: "再次打开小滴(Ctrl/Command + L)",
|
|
394
|
-
onClick:
|
|
395
|
-
}, [...
|
|
396
|
-
|
|
407
|
+
onClick: Te
|
|
408
|
+
}, [...n[1] || (n[1] = [
|
|
409
|
+
ie("span", {
|
|
397
410
|
class: "spotlight-avatar-reopen__drop",
|
|
398
411
|
"aria-hidden": "true"
|
|
399
412
|
}, null, -1),
|
|
400
|
-
|
|
401
|
-
])])) :
|
|
413
|
+
ie("span", { class: "spotlight-avatar-reopen__label" }, "小滴", -1)
|
|
414
|
+
])])) : Ie("", !0)
|
|
402
415
|
], 64));
|
|
403
416
|
}
|
|
404
417
|
});
|
|
405
418
|
export {
|
|
406
|
-
|
|
419
|
+
An as default
|
|
407
420
|
};
|