@inupedia/spotlight-vue 0.8.6 → 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/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 +40 -43
- 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/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/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/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/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 +20 -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 +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 +320 -217
- 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/node_modules/.pnpm/uqr@0.1.3/node_modules/uqr/dist/index.js +504 -0
- 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 +1 -0
- package/dist/remote/runPipeline.d.ts.map +1 -1
- package/dist/remote/runPipeline.js +83 -96
- package/dist/store/live2dSpeechStore.d.ts +2 -2
- package/dist/store/memoryPreferenceStore.d.ts +1 -1
- 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 +10 -10
- package/package.json +4 -3
|
@@ -1,317 +1,420 @@
|
|
|
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
|
-
|
|
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({
|
|
14
21
|
__name: "SpotlightShell",
|
|
15
22
|
props: {
|
|
16
23
|
avatarEnabled: { type: Boolean, default: !1 }
|
|
17
24
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const
|
|
20
|
-
() =>
|
|
21
|
-
),
|
|
22
|
-
() =>
|
|
23
|
-
),
|
|
25
|
+
setup(O) {
|
|
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(
|
|
24
31
|
() => Math.max(
|
|
25
32
|
0,
|
|
26
|
-
|
|
33
|
+
F.briefingKeepLastMs ?? 0
|
|
27
34
|
)
|
|
28
35
|
);
|
|
29
|
-
let
|
|
30
|
-
const
|
|
31
|
-
let H = Promise.resolve(),
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
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(
|
|
43
|
+
(e) => e.stopLive2dLipSync()
|
|
44
|
+
);
|
|
35
45
|
});
|
|
36
|
-
|
|
37
|
-
|
|
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;
|
|
49
|
+
});
|
|
50
|
+
function fe() {
|
|
51
|
+
P.value = !1, g.value && (t.showThinkingBar = !1);
|
|
38
52
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
53
|
+
function G() {
|
|
54
|
+
L.value != null && (window.clearTimeout(L.value), L.value = null);
|
|
41
55
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
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();
|
|
44
58
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
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(
|
|
47
61
|
(e) => e.stopLive2dLipSync()
|
|
48
62
|
);
|
|
49
63
|
}
|
|
50
|
-
function
|
|
51
|
-
return e <= 0 ? Promise.resolve() : new Promise((
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
}, e),
|
|
55
|
-
window.clearTimeout(
|
|
64
|
+
function ve(e, n) {
|
|
65
|
+
return e <= 0 ? Promise.resolve() : new Promise((r, i) => {
|
|
66
|
+
const a = window.setTimeout(() => {
|
|
67
|
+
n?.removeEventListener("abort", o), r();
|
|
68
|
+
}, e), o = () => {
|
|
69
|
+
window.clearTimeout(a), i(new DOMException("Aborted", "AbortError"));
|
|
56
70
|
};
|
|
57
|
-
if (
|
|
58
|
-
|
|
71
|
+
if (n?.aborted) {
|
|
72
|
+
o();
|
|
59
73
|
return;
|
|
60
74
|
}
|
|
61
|
-
|
|
75
|
+
n?.addEventListener("abort", o, { once: !0 });
|
|
62
76
|
});
|
|
63
77
|
}
|
|
64
|
-
async function
|
|
65
|
-
if (!
|
|
66
|
-
|
|
67
|
-
const e =
|
|
68
|
-
if (
|
|
69
|
-
|
|
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();
|
|
70
84
|
return;
|
|
71
85
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
const r = w.synthesize(
|
|
87
|
+
I.value,
|
|
88
|
+
n.signal
|
|
75
89
|
);
|
|
76
|
-
if (await
|
|
77
|
-
requestAnimationFrame(() =>
|
|
78
|
-
}), !!
|
|
90
|
+
if (await oe(), await new Promise((i) => {
|
|
91
|
+
requestAnimationFrame(() => i());
|
|
92
|
+
}), !!v(n, e))
|
|
79
93
|
try {
|
|
80
|
-
const { blob:
|
|
81
|
-
if (!
|
|
82
|
-
await
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
const { blob: i } = await r;
|
|
95
|
+
if (!v(n, e)) return;
|
|
96
|
+
await J(
|
|
97
|
+
I.value,
|
|
98
|
+
i,
|
|
99
|
+
n,
|
|
86
100
|
e,
|
|
87
101
|
{ instantText: !0, playHelloWithSpeech: !0 }
|
|
88
102
|
);
|
|
89
|
-
} catch (
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
|
|
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());
|
|
93
107
|
} finally {
|
|
94
|
-
|
|
108
|
+
T === n && (T = null);
|
|
95
109
|
}
|
|
96
110
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
111
|
+
function D() {
|
|
112
|
+
Ue();
|
|
113
|
+
}
|
|
114
|
+
function W() {
|
|
115
|
+
return globalThis.crypto?.randomUUID?.() ?? `turn-${Date.now()}-${Math.random()}`;
|
|
99
116
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
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();
|
|
123
|
+
}
|
|
124
|
+
return "";
|
|
125
|
+
}
|
|
126
|
+
function me(e) {
|
|
127
|
+
const n = Oe(e);
|
|
128
|
+
n.length !== 0 && (s.setPhase("speaking"), n.forEach((r, i) => {
|
|
129
|
+
j({ text: r });
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
function ge() {
|
|
133
|
+
C(), b.value += 1;
|
|
102
134
|
const e = new AbortController();
|
|
103
|
-
|
|
135
|
+
m.value = e, H = Promise.resolve(), M = 0, f = "", V = 0, P.value = !0, K.value = !0, W(), U = 0;
|
|
104
136
|
}
|
|
105
|
-
function
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
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(
|
|
143
|
+
(o) => ({ blob: o.blob, error: null }),
|
|
144
|
+
(o) => ({ blob: null, error: o })
|
|
111
145
|
);
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
M += 1, H = H.then(async () => {
|
|
147
|
+
const o = await a;
|
|
148
|
+
if (o.error) throw o.error;
|
|
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(
|
|
153
|
+
e,
|
|
154
|
+
o.blob,
|
|
155
|
+
n,
|
|
156
|
+
r,
|
|
120
157
|
{
|
|
121
158
|
instantText: !0,
|
|
122
|
-
hasFollowingClip:
|
|
159
|
+
hasFollowingClip: A
|
|
123
160
|
}
|
|
124
|
-
)
|
|
125
|
-
}).catch((
|
|
126
|
-
|
|
161
|
+
);
|
|
162
|
+
}).catch((o) => {
|
|
163
|
+
n.signal.aborted || (t.error = o instanceof Error ? o.message : "数字人语音播放失败,请稍后重试。");
|
|
127
164
|
});
|
|
128
165
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
166
|
+
function Q() {
|
|
167
|
+
if (!f) return;
|
|
168
|
+
const e = ae(f, { force: !0 });
|
|
169
|
+
f = "";
|
|
170
|
+
for (const n of e.ready) Y(n);
|
|
171
|
+
}
|
|
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);
|
|
180
|
+
}
|
|
181
|
+
async function be() {
|
|
182
|
+
const e = m.value;
|
|
183
|
+
if (!e) {
|
|
184
|
+
K.value = !1;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
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)
|
|
135
190
|
try {
|
|
136
|
-
await
|
|
191
|
+
await ve(z.value, e.signal);
|
|
137
192
|
} catch {
|
|
138
193
|
}
|
|
139
|
-
|
|
194
|
+
v(e, n) && c.reset();
|
|
140
195
|
}
|
|
141
|
-
|
|
196
|
+
m.value === e && (m.value = null), K.value = !1;
|
|
142
197
|
}
|
|
143
|
-
function
|
|
144
|
-
return !e.signal.aborted &&
|
|
198
|
+
function v(e, n) {
|
|
199
|
+
return !e.signal.aborted && b.value === n;
|
|
145
200
|
}
|
|
146
|
-
async function
|
|
147
|
-
if (!
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (await Te(A, i.signal), R.stopLive2dLipSync(), V(), !!c(i, a)) {
|
|
163
|
-
if (L) {
|
|
164
|
-
o.finish();
|
|
165
|
-
return;
|
|
201
|
+
async function J(e, n, r, i, a) {
|
|
202
|
+
if (!v(r, i)) return;
|
|
203
|
+
const o = a?.hasFollowingClip ?? !1;
|
|
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)
|
|
212
|
+
);
|
|
213
|
+
try {
|
|
214
|
+
await ze(Be, r.signal, {
|
|
215
|
+
onStart: (q) => {
|
|
216
|
+
A.bindLive2dLipSyncToClock(q, Ve);
|
|
166
217
|
}
|
|
167
|
-
|
|
168
|
-
|
|
218
|
+
});
|
|
219
|
+
} catch (q) {
|
|
220
|
+
throw A.stopLive2dLipSync(), D(), q;
|
|
169
221
|
}
|
|
222
|
+
o || A.stopLive2dLipSync(), D(), v(r, i) && (o || c.reset());
|
|
170
223
|
}
|
|
171
|
-
function
|
|
172
|
-
return
|
|
224
|
+
function X() {
|
|
225
|
+
return !S.avatarEnabled || !g.value ? !1 : !t.loading && !E.value && !k.value;
|
|
173
226
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
227
|
+
function Z() {
|
|
228
|
+
return X() && !t.visible;
|
|
229
|
+
}
|
|
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;
|
|
180
235
|
try {
|
|
181
|
-
|
|
236
|
+
await t.submit({
|
|
237
|
+
interactionMode: "voice",
|
|
238
|
+
onVoiceSentence: j
|
|
239
|
+
});
|
|
240
|
+
} finally {
|
|
241
|
+
const a = !!r && v(r, i);
|
|
242
|
+
if (Q(), a && M === 0) {
|
|
243
|
+
const o = he();
|
|
244
|
+
o && me(o), Q();
|
|
245
|
+
}
|
|
246
|
+
await be(), a && (s.resetTo("idle"), u.reset());
|
|
247
|
+
}
|
|
248
|
+
}
|
|
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;
|
|
259
|
+
try {
|
|
260
|
+
const { text: r } = await w.stopAndTranscribe(n.signal), i = r.trim();
|
|
182
261
|
if (e) {
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
await n.submit({
|
|
187
|
-
interactionMode: "voice",
|
|
188
|
-
onVoiceSentence: ie
|
|
189
|
-
});
|
|
190
|
-
} finally {
|
|
191
|
-
await re();
|
|
262
|
+
if (y.value = !1, u.setTranscribing(!1), !i) {
|
|
263
|
+
t.error = "没识别到内容,请靠近麦克风再说一次。";
|
|
264
|
+
return;
|
|
192
265
|
}
|
|
266
|
+
await ee(i);
|
|
193
267
|
return;
|
|
194
268
|
}
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
} catch (
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
n.error = a;
|
|
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) || "语音识别失败,请重试。";
|
|
201
274
|
} finally {
|
|
202
|
-
|
|
275
|
+
x.value = null, k.value = !1, p.value = !1, y.value = !1, u.reset();
|
|
203
276
|
}
|
|
204
277
|
}
|
|
205
|
-
function
|
|
278
|
+
function ye(e) {
|
|
206
279
|
if (e.repeat || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
|
|
207
|
-
const
|
|
208
|
-
!
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
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))
|
|
212
285
|
try {
|
|
213
|
-
await
|
|
214
|
-
} catch (
|
|
215
|
-
|
|
216
|
-
n.error = r, l.value = !1, d.value = !1, s.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();
|
|
217
289
|
}
|
|
218
290
|
}, 450)));
|
|
219
291
|
}
|
|
220
|
-
async function
|
|
221
|
-
if (!(!
|
|
222
|
-
|
|
292
|
+
async function Se() {
|
|
293
|
+
if (!(!X() || E.value)) {
|
|
294
|
+
E.value = !0;
|
|
223
295
|
try {
|
|
224
|
-
if (
|
|
225
|
-
|
|
296
|
+
if (C(), await w.startRecording(), !g.value) {
|
|
297
|
+
w.cancel();
|
|
226
298
|
return;
|
|
227
299
|
}
|
|
228
|
-
|
|
300
|
+
p.value = !0, y.value = !0, u.setRecording(!0), t.error = "";
|
|
229
301
|
} catch (e) {
|
|
230
|
-
|
|
231
|
-
n.error = t, l.value = !1, d.value = !1, s.reset();
|
|
302
|
+
t.error = $(e), p.value = !1, y.value = !1, u.reset();
|
|
232
303
|
} finally {
|
|
233
|
-
|
|
304
|
+
E.value = !1;
|
|
234
305
|
}
|
|
235
306
|
}
|
|
236
307
|
}
|
|
237
|
-
function
|
|
238
|
-
|
|
308
|
+
function we() {
|
|
309
|
+
p.value && ne();
|
|
239
310
|
}
|
|
240
|
-
function
|
|
241
|
-
if (e.code !==
|
|
311
|
+
function ke(e) {
|
|
312
|
+
if (e.code !== se || !t.visible && !p.value) return;
|
|
242
313
|
e.preventDefault();
|
|
243
|
-
const
|
|
244
|
-
|
|
314
|
+
const n = p.value;
|
|
315
|
+
G(), n && ne();
|
|
245
316
|
}
|
|
246
|
-
function
|
|
247
|
-
if (e.code ===
|
|
248
|
-
|
|
317
|
+
function Pe(e) {
|
|
318
|
+
if (e.code === se) {
|
|
319
|
+
ye(e);
|
|
249
320
|
return;
|
|
250
321
|
}
|
|
251
|
-
const
|
|
252
|
-
|
|
322
|
+
const n = e.key.toLowerCase(), r = e.metaKey || e.ctrlKey;
|
|
323
|
+
S.avatarEnabled && r && n === "l" && (e.preventDefault(), B.toggle());
|
|
253
324
|
}
|
|
254
|
-
function
|
|
255
|
-
|
|
325
|
+
function Te() {
|
|
326
|
+
B.show();
|
|
256
327
|
}
|
|
257
|
-
function
|
|
258
|
-
|
|
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();
|
|
331
|
+
});
|
|
259
332
|
}
|
|
260
|
-
function
|
|
333
|
+
function Le(e) {
|
|
261
334
|
if (!e) {
|
|
262
|
-
|
|
263
|
-
|
|
335
|
+
if (!Xe({
|
|
336
|
+
loading: t.loading,
|
|
337
|
+
pipelinePhase: t.pipelinePhase
|
|
338
|
+
})) {
|
|
339
|
+
_();
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
s.abort("panel_close"), _(), g.value && t.prepareLive2dVoiceChannel();
|
|
264
343
|
}
|
|
265
344
|
}
|
|
266
|
-
return
|
|
267
|
-
if (
|
|
345
|
+
return te(g, (e) => {
|
|
346
|
+
if (S.avatarEnabled) {
|
|
268
347
|
if (!e) {
|
|
269
|
-
|
|
348
|
+
P.value = !1, s.abort("avatar_close"), _(), C(), c.reset(), u.reset();
|
|
270
349
|
return;
|
|
271
350
|
}
|
|
272
|
-
|
|
351
|
+
t.visible || t.prepareLive2dVoiceChannel(), Je(), de();
|
|
352
|
+
}
|
|
353
|
+
}), te(
|
|
354
|
+
() => Ze({
|
|
355
|
+
loading: t.loading,
|
|
356
|
+
speaking: s.phase === "speaking" || K.value,
|
|
357
|
+
toolRunning: t.agentSteps.some(
|
|
358
|
+
(e) => e.toolCalls?.some(
|
|
359
|
+
(n) => n.status === "running" || n.status === "pending"
|
|
360
|
+
)
|
|
361
|
+
),
|
|
362
|
+
interrupted: s.phase === "interrupted"
|
|
363
|
+
}),
|
|
364
|
+
(e) => {
|
|
365
|
+
s.phase === "interrupted" || s.phase === "error" || s.setPhase(e);
|
|
273
366
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}),
|
|
277
|
-
|
|
278
|
-
}), (e,
|
|
279
|
-
|
|
280
|
-
"deck-kicker":
|
|
281
|
-
"voice-hold-active":
|
|
282
|
-
"speech-pending":
|
|
283
|
-
"voice-key-label":
|
|
284
|
-
"show-thinking":
|
|
285
|
-
"thinking-centered":
|
|
286
|
-
"on-escape":
|
|
287
|
-
"on-keydown":
|
|
288
|
-
"on-keyup":
|
|
289
|
-
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
|
|
290
383
|
}, null, 8, ["deck-kicker", "voice-hold-active", "speech-pending", "show-thinking", "thinking-centered"]),
|
|
291
|
-
|
|
384
|
+
O.avatarEnabled && l(g) ? (N(), Fe(rn, {
|
|
292
385
|
key: 0,
|
|
293
|
-
"voice-disabled":
|
|
294
|
-
"voice-error":
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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", {
|
|
299
402
|
key: 1,
|
|
300
403
|
type: "button",
|
|
301
404
|
class: "spotlight-avatar-reopen",
|
|
302
405
|
"aria-label": "再次打开数字人小滴",
|
|
303
406
|
title: "再次打开小滴(Ctrl/Command + L)",
|
|
304
|
-
onClick:
|
|
305
|
-
}, [...
|
|
306
|
-
|
|
407
|
+
onClick: Te
|
|
408
|
+
}, [...n[1] || (n[1] = [
|
|
409
|
+
ie("span", {
|
|
307
410
|
class: "spotlight-avatar-reopen__drop",
|
|
308
411
|
"aria-hidden": "true"
|
|
309
412
|
}, null, -1),
|
|
310
|
-
|
|
311
|
-
])])) :
|
|
413
|
+
ie("span", { class: "spotlight-avatar-reopen__label" }, "小滴", -1)
|
|
414
|
+
])])) : Ie("", !0)
|
|
312
415
|
], 64));
|
|
313
416
|
}
|
|
314
417
|
});
|
|
315
418
|
export {
|
|
316
|
-
|
|
419
|
+
An as default
|
|
317
420
|
};
|