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