dsh-voice-mode 0.7.25 → 0.7.26
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/README.en.md +15 -11
- package/README.md +16 -12
- package/lib/client.js +957 -338
- package/lib/index.js +363 -76
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -440,6 +440,7 @@ var LEVEL_CEILING = 0.25;
|
|
|
440
440
|
var MAX_SEGMENT_MS = 3e4;
|
|
441
441
|
var MIN_SPEECH_MS = 250;
|
|
442
442
|
var PRE_PAD_MS = 250;
|
|
443
|
+
var PRE_ROLL_MS = 2e3;
|
|
443
444
|
var PARTIAL_INTERVAL_MS = 100;
|
|
444
445
|
var PARTIAL_MIN_S = 0.4;
|
|
445
446
|
var PARTIAL_MAX_S = 30;
|
|
@@ -461,6 +462,7 @@ function createAsrEngine(config, sessionId) {
|
|
|
461
462
|
};
|
|
462
463
|
const transcriptListeners = /* @__PURE__ */ new Set();
|
|
463
464
|
const partialListeners = /* @__PURE__ */ new Set();
|
|
465
|
+
const noticeListeners = /* @__PURE__ */ new Set();
|
|
464
466
|
const levelListeners = /* @__PURE__ */ new Set();
|
|
465
467
|
const telemetryListeners = /* @__PURE__ */ new Set();
|
|
466
468
|
let utteranceEndAt = null;
|
|
@@ -502,6 +504,16 @@ function createAsrEngine(config, sessionId) {
|
|
|
502
504
|
let detectSent = 0;
|
|
503
505
|
let detectInFlight = false;
|
|
504
506
|
let detectGeneration = 0;
|
|
507
|
+
const salvageEnabled = config.bargeInSalvage !== false;
|
|
508
|
+
let preRoll = [];
|
|
509
|
+
let preRollMs = 0;
|
|
510
|
+
let preRollStartWall = 0;
|
|
511
|
+
let preRollSeedWall = null;
|
|
512
|
+
let wasPlaying = false;
|
|
513
|
+
let partialFailStreak = 0;
|
|
514
|
+
let detectFailStreak = 0;
|
|
515
|
+
let salvagedSegment = false;
|
|
516
|
+
let yieldedSegment = false;
|
|
505
517
|
const asrUrl = (final, offset, epoch) => `${location.origin}${config.basePath.replace(/\/+$/, "")}/asr?sessionId=${encodeURIComponent(sessionId)}&final=${final ? 1 : 0}` + (offset !== void 0 ? `&offset=${offset}` : "") + (epoch !== void 0 ? `&epoch=${epoch}` : "") + // 批 7N(ADR-0006):manual 模式下上传带 &manual=1,host 服务端据此放行(防御性守卫)。
|
|
506
518
|
// handleAudio 入口已先在 manual + !holdActive 时 early return,所以能到这儿的帧必然
|
|
507
519
|
// holdActive=true;带 manual=1 仅是冗余信号(host 拿不到 holdActive 状态)。
|
|
@@ -526,6 +538,10 @@ function createAsrEngine(config, sessionId) {
|
|
|
526
538
|
}
|
|
527
539
|
}
|
|
528
540
|
};
|
|
541
|
+
const resetFailStreaks = () => {
|
|
542
|
+
partialFailStreak = 0;
|
|
543
|
+
detectFailStreak = 0;
|
|
544
|
+
};
|
|
529
545
|
const sliceChunks = (chunks, from) => {
|
|
530
546
|
let total = 0;
|
|
531
547
|
for (const c of chunks) total += c.length;
|
|
@@ -560,17 +576,20 @@ function createAsrEngine(config, sessionId) {
|
|
|
560
576
|
let res = await fetch(asrUrl(false, from, epoch), {
|
|
561
577
|
method: "POST",
|
|
562
578
|
headers: { "content-type": "application/octet-stream" },
|
|
563
|
-
body: samples.buffer
|
|
579
|
+
body: samples.buffer,
|
|
580
|
+
signal: AbortSignal.timeout(5e3)
|
|
564
581
|
});
|
|
565
582
|
if (res.status === 202) {
|
|
566
|
-
setState("loading-model");
|
|
583
|
+
if (state !== "wake") setState("loading-model");
|
|
567
584
|
const retry = await new Promise((resolve) => {
|
|
568
585
|
setTimeout(async () => {
|
|
569
586
|
try {
|
|
570
587
|
const r2 = await fetch(asrUrl(false, from, epoch), {
|
|
571
588
|
method: "POST",
|
|
572
589
|
headers: { "content-type": "application/octet-stream" },
|
|
573
|
-
body: samples.buffer
|
|
590
|
+
body: samples.buffer,
|
|
591
|
+
signal: AbortSignal.timeout(5e3)
|
|
592
|
+
// I1:重试同样要超时(否则重试挂起仍锁死 partialInFlight)
|
|
574
593
|
});
|
|
575
594
|
resolve(r2);
|
|
576
595
|
} catch {
|
|
@@ -588,14 +607,19 @@ function createAsrEngine(config, sessionId) {
|
|
|
588
607
|
res = await fetch(asrUrl(false, 0, epoch), {
|
|
589
608
|
method: "POST",
|
|
590
609
|
headers: { "content-type": "application/octet-stream" },
|
|
591
|
-
body: sliceSince(0).buffer
|
|
610
|
+
body: sliceSince(0).buffer,
|
|
611
|
+
signal: AbortSignal.timeout(5e3)
|
|
612
|
+
// I1:恢复重发同样要超时(挂起不 reject 会锁死 partialInFlight)
|
|
592
613
|
});
|
|
593
614
|
} catch {
|
|
594
615
|
}
|
|
595
616
|
}
|
|
596
617
|
}
|
|
597
618
|
if (epoch !== segmentEpoch) return;
|
|
598
|
-
if (!res.ok)
|
|
619
|
+
if (!res.ok) {
|
|
620
|
+
if (res.status !== 202 && ++partialFailStreak >= 3) emit(noticeListeners, "partialFail");
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
599
623
|
const out = await res.json();
|
|
600
624
|
if (epoch !== segmentEpoch) return;
|
|
601
625
|
if (state === "wake" && wakeEnabled) {
|
|
@@ -612,13 +636,16 @@ function createAsrEngine(config, sessionId) {
|
|
|
612
636
|
if (out.isSpeech !== void 0) config.onIsSpeech?.(out.isSpeech);
|
|
613
637
|
if (state === "loading-model") setState("speech");
|
|
614
638
|
uploadedSamples = Math.max(uploadedSamples, from + samples.length);
|
|
639
|
+
partialFailStreak = 0;
|
|
615
640
|
emit(partialListeners, wakeConsumed ? stripWakePrefix(out.text ?? "", wakeWord) : out.text ?? "");
|
|
616
641
|
if (config.backchannelYield !== false && // 默认 true(I10 豁免);显式 false 时跳过
|
|
617
642
|
speechActive && (config.isPlaying?.() ?? false) && matchBackchannel(out.text ?? "")) {
|
|
643
|
+
yieldedSegment = true;
|
|
618
644
|
config.onBackchannel?.();
|
|
619
645
|
}
|
|
620
646
|
if (out.endpoint && active && speechActive && !holdActive) finalizeSegment();
|
|
621
647
|
} catch {
|
|
648
|
+
if (++partialFailStreak >= 3) emit(noticeListeners, "partialFail");
|
|
622
649
|
} finally {
|
|
623
650
|
partialInFlight = false;
|
|
624
651
|
}
|
|
@@ -641,6 +668,7 @@ function createAsrEngine(config, sessionId) {
|
|
|
641
668
|
const gen = detectGeneration;
|
|
642
669
|
detectInFlight = true;
|
|
643
670
|
const sentAt = Date.now();
|
|
671
|
+
const reqBodyStartWall = sentAt - samples.length / SAMPLE_RATE2 * 1e3;
|
|
644
672
|
let rttMs = -1;
|
|
645
673
|
try {
|
|
646
674
|
const res = await fetch(asrUrl(false, detectSent, epoch) + "&vadOnly=1", {
|
|
@@ -656,12 +684,15 @@ function createAsrEngine(config, sessionId) {
|
|
|
656
684
|
const out = await res.json();
|
|
657
685
|
if (epoch !== segmentEpoch || gen !== detectGeneration) return;
|
|
658
686
|
if (out.isSpeech !== void 0) config.onIsSpeech?.(out.isSpeech);
|
|
687
|
+
if (out.isSpeech === true && preRollSeedWall === null) preRollSeedWall = reqBodyStartWall - 250;
|
|
688
|
+
detectFailStreak = 0;
|
|
659
689
|
detectSent += samples.length;
|
|
660
690
|
while (detectChunks.length > 0 && detectSent >= detectChunks[0].length) {
|
|
661
691
|
detectSent -= detectChunks[0].length;
|
|
662
692
|
detectChunks.shift();
|
|
663
693
|
}
|
|
664
694
|
} catch {
|
|
695
|
+
if (++detectFailStreak >= 3) emit(noticeListeners, "detectFail");
|
|
665
696
|
} finally {
|
|
666
697
|
detectInFlight = false;
|
|
667
698
|
if (fixtureRecorder.isActive) {
|
|
@@ -697,6 +728,8 @@ function createAsrEngine(config, sessionId) {
|
|
|
697
728
|
if (cut > 0) prePad = prePad.slice(cut);
|
|
698
729
|
};
|
|
699
730
|
const clearWakeSegment = () => {
|
|
731
|
+
partialFailStreak = 0;
|
|
732
|
+
detectFailStreak = 0;
|
|
700
733
|
segmentEpoch++;
|
|
701
734
|
segment = [];
|
|
702
735
|
segmentMs = 0;
|
|
@@ -704,6 +737,8 @@ function createAsrEngine(config, sessionId) {
|
|
|
704
737
|
silenceMs = 0;
|
|
705
738
|
wakeSilenceMs = 0;
|
|
706
739
|
wakeConsumed = false;
|
|
740
|
+
salvagedSegment = false;
|
|
741
|
+
yieldedSegment = false;
|
|
707
742
|
prePad = [];
|
|
708
743
|
uploadedSamples = 0;
|
|
709
744
|
void resetHostStream();
|
|
@@ -724,6 +759,10 @@ function createAsrEngine(config, sessionId) {
|
|
|
724
759
|
const meta = { force: forcePending };
|
|
725
760
|
const consumedWake = wakeConsumed;
|
|
726
761
|
wakeConsumed = false;
|
|
762
|
+
const wasSalvaged = salvagedSegment;
|
|
763
|
+
salvagedSegment = false;
|
|
764
|
+
const wasYielded = yieldedSegment;
|
|
765
|
+
yieldedSegment = false;
|
|
727
766
|
forcePending = false;
|
|
728
767
|
speechMs = 0;
|
|
729
768
|
uploadedSamples = 0;
|
|
@@ -748,13 +787,13 @@ function createAsrEngine(config, sessionId) {
|
|
|
748
787
|
let res;
|
|
749
788
|
try {
|
|
750
789
|
res = await fetch(asrUrl(true, off, epochSnapshot), {
|
|
751
|
-
signal: AbortSignal.timeout(
|
|
790
|
+
signal: AbortSignal.timeout(25e3),
|
|
791
|
+
// Issue #15 批 4:对齐 host SenseVoice race 上限 20s(asr-host.ts:598-606)——原 10s 必触发一次空转重试
|
|
752
792
|
method: "POST",
|
|
753
793
|
headers: { "content-type": "application/octet-stream" },
|
|
754
794
|
body
|
|
755
795
|
});
|
|
756
796
|
} catch {
|
|
757
|
-
restoreState();
|
|
758
797
|
if (attempt === MAX_FINAL_ATTEMPTS - 1) console.warn("[dsh-voice-mode] finalize fetch failed (retries exhausted)");
|
|
759
798
|
continue;
|
|
760
799
|
}
|
|
@@ -765,7 +804,8 @@ function createAsrEngine(config, sessionId) {
|
|
|
765
804
|
try {
|
|
766
805
|
resolve(
|
|
767
806
|
await fetch(asrUrl(true, off, epochSnapshot), {
|
|
768
|
-
signal: AbortSignal.timeout(
|
|
807
|
+
signal: AbortSignal.timeout(25e3),
|
|
808
|
+
// Issue #15 批 4:对齐 host SenseVoice race 上限 20s(asr-host.ts:598-606)——原 10s 必触发一次空转重试
|
|
769
809
|
method: "POST",
|
|
770
810
|
headers: { "content-type": "application/octet-stream" },
|
|
771
811
|
body
|
|
@@ -786,7 +826,8 @@ function createAsrEngine(config, sessionId) {
|
|
|
786
826
|
if (recovered && segmentEpoch === epochSnapshot + 1) {
|
|
787
827
|
try {
|
|
788
828
|
res = await fetch(asrUrl(true, 0, epochSnapshot), {
|
|
789
|
-
signal: AbortSignal.timeout(
|
|
829
|
+
signal: AbortSignal.timeout(25e3),
|
|
830
|
+
// Issue #15 批 4:对齐 host SenseVoice race 上限 20s(asr-host.ts:598-606)——原 10s 必触发一次空转重试
|
|
790
831
|
method: "POST",
|
|
791
832
|
headers: { "content-type": "application/octet-stream" },
|
|
792
833
|
body: sliceChunks(recoverySegment, 0).buffer
|
|
@@ -795,7 +836,6 @@ function createAsrEngine(config, sessionId) {
|
|
|
795
836
|
}
|
|
796
837
|
}
|
|
797
838
|
}
|
|
798
|
-
restoreState();
|
|
799
839
|
if (!res.ok) {
|
|
800
840
|
if (attempt === MAX_FINAL_ATTEMPTS - 1) console.warn("[dsh-voice-mode] finalize 5xx (retries exhausted)");
|
|
801
841
|
continue;
|
|
@@ -808,15 +848,23 @@ function createAsrEngine(config, sessionId) {
|
|
|
808
848
|
continue;
|
|
809
849
|
}
|
|
810
850
|
if (segmentEpoch !== epochSnapshot + 1) return;
|
|
851
|
+
resetFailStreaks();
|
|
852
|
+
restoreState();
|
|
811
853
|
const rawText = out.text ?? "";
|
|
812
854
|
const finalText = consumedWake ? stripWakePrefix(rawText, wakeWord) : rawText;
|
|
813
855
|
if (finalText) {
|
|
856
|
+
if ((wasSalvaged || wasYielded) && matchBackchannel(finalText)) {
|
|
857
|
+
emit(noticeListeners, "backchannelDropped");
|
|
858
|
+
if (active && wakeEnabled) setState("listening");
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
814
861
|
emit(transcriptListeners, finalText, meta);
|
|
815
862
|
} else if (consumedWake && active && !speechActive && !holdActive) {
|
|
816
863
|
setState("listening");
|
|
817
864
|
}
|
|
818
865
|
return;
|
|
819
866
|
}
|
|
867
|
+
restoreState();
|
|
820
868
|
emitError("recognitionFail");
|
|
821
869
|
})();
|
|
822
870
|
};
|
|
@@ -871,7 +919,29 @@ function createAsrEngine(config, sessionId) {
|
|
|
871
919
|
playingTail: playingNow
|
|
872
920
|
});
|
|
873
921
|
}
|
|
874
|
-
if (playingNow && !holdActive && config.mode !== "hold")
|
|
922
|
+
if (playingNow && !holdActive && config.mode !== "hold") {
|
|
923
|
+
detectChunks.push(data);
|
|
924
|
+
if (salvageEnabled) {
|
|
925
|
+
if (preRoll.length === 0) preRollStartWall = Date.now();
|
|
926
|
+
preRoll.push(data);
|
|
927
|
+
preRollMs += durationMs;
|
|
928
|
+
while (preRollMs > PRE_ROLL_MS && preRoll.length > 1) {
|
|
929
|
+
const dropped = preRoll.shift();
|
|
930
|
+
const droppedMs = dropped.length / SAMPLE_RATE2 * 1e3;
|
|
931
|
+
preRollMs -= droppedMs;
|
|
932
|
+
preRollStartWall += droppedMs;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
if (playingNow && !wasPlaying) {
|
|
937
|
+
wasPlaying = true;
|
|
938
|
+
preRollSeedWall = null;
|
|
939
|
+
preRoll = [];
|
|
940
|
+
preRollMs = 0;
|
|
941
|
+
preRollStartWall = 0;
|
|
942
|
+
} else if (!playingNow && wasPlaying) {
|
|
943
|
+
wasPlaying = false;
|
|
944
|
+
}
|
|
875
945
|
if (holdActive) {
|
|
876
946
|
if (!speechActive) {
|
|
877
947
|
speechActive = true;
|
|
@@ -940,6 +1010,9 @@ function createAsrEngine(config, sessionId) {
|
|
|
940
1010
|
segmentEpoch++;
|
|
941
1011
|
segment = [];
|
|
942
1012
|
speechActive = false;
|
|
1013
|
+
salvagedSegment = false;
|
|
1014
|
+
yieldedSegment = false;
|
|
1015
|
+
resetFailStreaks();
|
|
943
1016
|
speechMs = 0;
|
|
944
1017
|
silenceMs = 0;
|
|
945
1018
|
segmentMs = 0;
|
|
@@ -969,9 +1042,21 @@ function createAsrEngine(config, sessionId) {
|
|
|
969
1042
|
}
|
|
970
1043
|
}
|
|
971
1044
|
};
|
|
1045
|
+
const abandonStart = async (myStream, myCtx) => {
|
|
1046
|
+
try {
|
|
1047
|
+
myStream.getTracks().forEach((t3) => t3.stop());
|
|
1048
|
+
} catch {
|
|
1049
|
+
}
|
|
1050
|
+
if (stream === myStream) stream = null;
|
|
1051
|
+
try {
|
|
1052
|
+
await myCtx.close();
|
|
1053
|
+
} catch {
|
|
1054
|
+
}
|
|
1055
|
+
if (audioCtx === myCtx) audioCtx = null;
|
|
1056
|
+
};
|
|
972
1057
|
const startRecorder = async () => {
|
|
973
1058
|
const mySeq = startSeq;
|
|
974
|
-
|
|
1059
|
+
const myStream = await navigator.mediaDevices.getUserMedia({
|
|
975
1060
|
audio: {
|
|
976
1061
|
channelCount: 1,
|
|
977
1062
|
echoCancellation: true,
|
|
@@ -984,10 +1069,10 @@ function createAsrEngine(config, sessionId) {
|
|
|
984
1069
|
}
|
|
985
1070
|
});
|
|
986
1071
|
if (stopRequested || mySeq !== startSeq) {
|
|
987
|
-
|
|
988
|
-
stream = null;
|
|
1072
|
+
myStream.getTracks().forEach((t3) => t3.stop());
|
|
989
1073
|
return;
|
|
990
1074
|
}
|
|
1075
|
+
stream = myStream;
|
|
991
1076
|
const aecOn = stream.getAudioTracks()[0]?.getSettings().echoCancellation === true;
|
|
992
1077
|
if (!aecOn) {
|
|
993
1078
|
console.warn("[dsh-voice-mode] native browser echoCancellation is not in effect (speakers may self-interrupt); use headphones or manual barge-in");
|
|
@@ -997,34 +1082,48 @@ function createAsrEngine(config, sessionId) {
|
|
|
997
1082
|
}
|
|
998
1083
|
config.onAecState?.(aecOn);
|
|
999
1084
|
const AC = window.AudioContext ?? window.webkitAudioContext;
|
|
1000
|
-
|
|
1085
|
+
const myCtx = new AC({ sampleRate: SAMPLE_RATE2 });
|
|
1086
|
+
audioCtx = myCtx;
|
|
1001
1087
|
try {
|
|
1002
1088
|
await audioCtx.resume?.();
|
|
1003
1089
|
} catch {
|
|
1004
1090
|
}
|
|
1091
|
+
if (stopRequested || mySeq !== startSeq) {
|
|
1092
|
+
await abandonStart(myStream, myCtx);
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1005
1095
|
ctxRate = audioCtx.sampleRate;
|
|
1006
1096
|
const source = audioCtx.createMediaStreamSource(stream);
|
|
1007
1097
|
if (audioCtx.audioWorklet) {
|
|
1098
|
+
let myWorkletNode = null;
|
|
1008
1099
|
try {
|
|
1009
1100
|
if (!workletBlobUrl) {
|
|
1010
1101
|
workletBlobUrl = URL.createObjectURL(new Blob(['"use strict";\n(() => {\n // src/resample.ts\n function resampleLinear(src, srcRate, dstRate) {\n if (srcRate === dstRate) return src;\n if (src.length === 0) return src;\n const ratio = srcRate / dstRate;\n const outLen = Math.max(1, Math.floor(src.length / ratio));\n const out = new Float32Array(outLen);\n for (let i = 0; i < outLen; i++) {\n const pos = i * ratio;\n const i0 = Math.floor(pos);\n const i1 = Math.min(i0 + 1, src.length - 1);\n const frac = pos - i0;\n out[i] = src[i0] + (src[i1] - src[i0]) * frac;\n }\n return out;\n }\n\n // src/audio-worklet.ts\n var TARGET_RATE = 16e3;\n var CHUNK = 1024;\n var RATIO = sampleRate / TARGET_RATE;\n var NEED = Math.ceil(CHUNK * RATIO);\n var VoiceCaptureProcessor = class extends AudioWorkletProcessor {\n acc = new Float32Array(0);\n accLen = 0;\n process(inputs) {\n const ch = inputs[0]?.[0];\n if (ch && ch.length > 0) this.push(ch);\n this.drain();\n return true;\n }\n push(ch) {\n if (this.accLen + ch.length > this.acc.length) {\n let cap = this.acc.length > 0 ? this.acc.length : NEED * 2;\n while (cap < this.accLen + ch.length) cap *= 2;\n const next = new Float32Array(cap);\n next.set(this.acc.subarray(0, this.accLen));\n this.acc = next;\n }\n this.acc.set(ch, this.accLen);\n this.accLen += ch.length;\n }\n drain() {\n while (this.accLen >= NEED) {\n const src = sampleRate === TARGET_RATE ? this.acc.subarray(0, CHUNK) : resampleLinear(this.acc.subarray(0, NEED), sampleRate, TARGET_RATE);\n const chunk = new Float32Array(CHUNK);\n chunk.set(src.length >= CHUNK ? src.subarray(0, CHUNK) : src);\n this.port.postMessage(chunk, [chunk.buffer]);\n this.acc.copyWithin(0, NEED, this.accLen);\n this.accLen -= NEED;\n }\n }\n };\n registerProcessor("voice-capture", VoiceCaptureProcessor);\n})();\n'], { type: "text/javascript" }));
|
|
1011
1102
|
}
|
|
1012
1103
|
await audioCtx.audioWorklet.addModule(workletBlobUrl);
|
|
1013
|
-
|
|
1014
|
-
|
|
1104
|
+
if (stopRequested || mySeq !== startSeq) {
|
|
1105
|
+
await abandonStart(myStream, myCtx);
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
myWorkletNode = new AudioWorkletNode(audioCtx, "voice-capture", { numberOfInputs: 1, numberOfOutputs: 1, outputChannelCount: [1] });
|
|
1109
|
+
myWorkletNode.port.onmessage = (e) => {
|
|
1015
1110
|
handleAudio(e.data);
|
|
1016
1111
|
};
|
|
1017
|
-
source.connect(
|
|
1018
|
-
|
|
1112
|
+
source.connect(myWorkletNode);
|
|
1113
|
+
myWorkletNode.connect(audioCtx.destination);
|
|
1114
|
+
workletNode = myWorkletNode;
|
|
1019
1115
|
ctxRate = SAMPLE_RATE2;
|
|
1020
1116
|
active = true;
|
|
1021
1117
|
return;
|
|
1022
1118
|
} catch {
|
|
1023
1119
|
try {
|
|
1024
|
-
|
|
1120
|
+
myWorkletNode?.disconnect();
|
|
1025
1121
|
} catch {
|
|
1026
1122
|
}
|
|
1027
|
-
|
|
1123
|
+
if (stopRequested || mySeq !== startSeq) {
|
|
1124
|
+
await abandonStart(myStream, myCtx);
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1028
1127
|
}
|
|
1029
1128
|
}
|
|
1030
1129
|
processor = audioCtx.createScriptProcessor(BUFFER_SIZE, 1, 1);
|
|
@@ -1036,6 +1135,7 @@ function createAsrEngine(config, sessionId) {
|
|
|
1036
1135
|
active = true;
|
|
1037
1136
|
};
|
|
1038
1137
|
const stopRecorder = async () => {
|
|
1138
|
+
const myCtx = audioCtx;
|
|
1039
1139
|
inFlush = true;
|
|
1040
1140
|
segmentEpoch++;
|
|
1041
1141
|
forcePending = false;
|
|
@@ -1047,11 +1147,18 @@ function createAsrEngine(config, sessionId) {
|
|
|
1047
1147
|
speechMs = 0;
|
|
1048
1148
|
wakeSilenceMs = 0;
|
|
1049
1149
|
wakeConsumed = false;
|
|
1150
|
+
yieldedSegment = false;
|
|
1050
1151
|
uploadedSamples = 0;
|
|
1051
1152
|
prePad = [];
|
|
1052
1153
|
detectChunks = [];
|
|
1053
1154
|
detectSent = 0;
|
|
1054
1155
|
detectGeneration++;
|
|
1156
|
+
preRoll = [];
|
|
1157
|
+
preRollMs = 0;
|
|
1158
|
+
preRollStartWall = 0;
|
|
1159
|
+
preRollSeedWall = null;
|
|
1160
|
+
wasPlaying = false;
|
|
1161
|
+
salvagedSegment = false;
|
|
1055
1162
|
utteranceEndAt = null;
|
|
1056
1163
|
try {
|
|
1057
1164
|
processor?.disconnect();
|
|
@@ -1069,11 +1176,13 @@ function createAsrEngine(config, sessionId) {
|
|
|
1069
1176
|
}
|
|
1070
1177
|
stream = null;
|
|
1071
1178
|
try {
|
|
1072
|
-
await
|
|
1179
|
+
await myCtx?.close();
|
|
1073
1180
|
} catch {
|
|
1074
1181
|
}
|
|
1075
|
-
audioCtx
|
|
1076
|
-
|
|
1182
|
+
if (audioCtx === myCtx) {
|
|
1183
|
+
audioCtx = null;
|
|
1184
|
+
ctxRate = SAMPLE_RATE2;
|
|
1185
|
+
}
|
|
1077
1186
|
inFlush = false;
|
|
1078
1187
|
};
|
|
1079
1188
|
return {
|
|
@@ -1095,22 +1204,37 @@ function createAsrEngine(config, sessionId) {
|
|
|
1095
1204
|
if (active) return;
|
|
1096
1205
|
stopRequested = false;
|
|
1097
1206
|
startSeq++;
|
|
1207
|
+
const myStartSeq = startSeq;
|
|
1098
1208
|
segmentEpoch++;
|
|
1209
|
+
partialFailStreak = 0;
|
|
1210
|
+
detectFailStreak = 0;
|
|
1099
1211
|
lastPollAt = 0;
|
|
1100
1212
|
holdActive = false;
|
|
1101
1213
|
detectChunks = [];
|
|
1102
1214
|
detectSent = 0;
|
|
1103
1215
|
detectGeneration++;
|
|
1216
|
+
preRoll = [];
|
|
1217
|
+
preRollMs = 0;
|
|
1218
|
+
preRollStartWall = 0;
|
|
1219
|
+
preRollSeedWall = null;
|
|
1220
|
+
wasPlaying = false;
|
|
1221
|
+
salvagedSegment = false;
|
|
1222
|
+
yieldedSegment = false;
|
|
1223
|
+
latestResidualRms = 0;
|
|
1224
|
+
echoFloorRms = 0;
|
|
1225
|
+
echoPeak = 0;
|
|
1104
1226
|
setState(wakeEnabled ? "wake" : "listening");
|
|
1105
1227
|
try {
|
|
1106
1228
|
await startRecorder();
|
|
1107
1229
|
} catch (error) {
|
|
1108
|
-
setState("idle");
|
|
1230
|
+
if (startSeq === myStartSeq) setState("idle");
|
|
1109
1231
|
throw error;
|
|
1110
1232
|
}
|
|
1111
1233
|
},
|
|
1112
1234
|
async stop() {
|
|
1113
1235
|
stopRequested = true;
|
|
1236
|
+
startSeq++;
|
|
1237
|
+
const myStopSeq = startSeq;
|
|
1114
1238
|
const wasActive = active;
|
|
1115
1239
|
active = false;
|
|
1116
1240
|
if (!wasActive) {
|
|
@@ -1118,11 +1242,10 @@ function createAsrEngine(config, sessionId) {
|
|
|
1118
1242
|
return;
|
|
1119
1243
|
}
|
|
1120
1244
|
await stopRecorder();
|
|
1121
|
-
setState("idle");
|
|
1245
|
+
if (startSeq === myStopSeq) setState("idle");
|
|
1122
1246
|
},
|
|
1123
1247
|
forceSend() {
|
|
1124
|
-
|
|
1125
|
-
if (speechActive && speechS >= 0.25) {
|
|
1248
|
+
if (speechActive && speechMs >= MIN_SPEECH_MS) {
|
|
1126
1249
|
forcePending = true;
|
|
1127
1250
|
lastPollAt = 0;
|
|
1128
1251
|
finalizeSegment();
|
|
@@ -1133,6 +1256,9 @@ function createAsrEngine(config, sessionId) {
|
|
|
1133
1256
|
holdActive = true;
|
|
1134
1257
|
segmentEpoch++;
|
|
1135
1258
|
wakeConsumed = false;
|
|
1259
|
+
salvagedSegment = false;
|
|
1260
|
+
yieldedSegment = false;
|
|
1261
|
+
resetFailStreaks();
|
|
1136
1262
|
utteranceEndAt = null;
|
|
1137
1263
|
segment = [];
|
|
1138
1264
|
segmentMs = 0;
|
|
@@ -1149,12 +1275,16 @@ function createAsrEngine(config, sessionId) {
|
|
|
1149
1275
|
},
|
|
1150
1276
|
discardSegment() {
|
|
1151
1277
|
segmentEpoch++;
|
|
1278
|
+
partialFailStreak = 0;
|
|
1279
|
+
detectFailStreak = 0;
|
|
1152
1280
|
segment = [];
|
|
1153
1281
|
segmentMs = 0;
|
|
1154
1282
|
speechMs = 0;
|
|
1155
1283
|
silenceMs = 0;
|
|
1156
1284
|
wakeSilenceMs = 0;
|
|
1157
1285
|
wakeConsumed = false;
|
|
1286
|
+
salvagedSegment = false;
|
|
1287
|
+
yieldedSegment = false;
|
|
1158
1288
|
speechActive = false;
|
|
1159
1289
|
prePad = [];
|
|
1160
1290
|
uploadedSamples = 0;
|
|
@@ -1164,8 +1294,37 @@ function createAsrEngine(config, sessionId) {
|
|
|
1164
1294
|
utteranceEndAt = null;
|
|
1165
1295
|
forcePending = false;
|
|
1166
1296
|
lastPollAt = 0;
|
|
1297
|
+
let salvaged = false;
|
|
1298
|
+
if (salvageEnabled && preRoll.length > 0) {
|
|
1299
|
+
const seedFromWall = Math.max(preRollSeedWall ?? preRollStartWall, preRollStartWall);
|
|
1300
|
+
let acc = 0;
|
|
1301
|
+
let i = 0;
|
|
1302
|
+
for (; i < preRoll.length; i++) {
|
|
1303
|
+
const frameMs = preRoll[i].length / SAMPLE_RATE2 * 1e3;
|
|
1304
|
+
if (preRollStartWall + acc + frameMs > seedFromWall) break;
|
|
1305
|
+
acc += frameMs;
|
|
1306
|
+
}
|
|
1307
|
+
const seeded = preRoll.slice(i);
|
|
1308
|
+
const seededMs = seeded.reduce((n, c) => n + c.length / SAMPLE_RATE2 * 1e3, 0);
|
|
1309
|
+
if (seeded.length > 0 && seededMs > 0) {
|
|
1310
|
+
for (const c of seeded) segment.push(c);
|
|
1311
|
+
segmentMs = seededMs;
|
|
1312
|
+
speechMs = seededMs;
|
|
1313
|
+
silenceMs = 0;
|
|
1314
|
+
speechActive = true;
|
|
1315
|
+
uploadedSamples = 0;
|
|
1316
|
+
salvagedSegment = true;
|
|
1317
|
+
salvaged = true;
|
|
1318
|
+
if (wakeEnabled) wakeConsumed = true;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
preRoll = [];
|
|
1322
|
+
preRollMs = 0;
|
|
1323
|
+
preRollStartWall = 0;
|
|
1324
|
+
preRollSeedWall = null;
|
|
1325
|
+
if (salvaged && active) setState("speech");
|
|
1167
1326
|
return resetHostStream().then(() => {
|
|
1168
|
-
if (active) setState(wakeEnabled ? "wake" : "listening");
|
|
1327
|
+
if (active && !salvaged) setState(wakeEnabled ? "wake" : "listening");
|
|
1169
1328
|
});
|
|
1170
1329
|
},
|
|
1171
1330
|
endHeld(cancel = false) {
|
|
@@ -1174,10 +1333,14 @@ function createAsrEngine(config, sessionId) {
|
|
|
1174
1333
|
if (cancel) {
|
|
1175
1334
|
segmentEpoch++;
|
|
1176
1335
|
segment = [];
|
|
1336
|
+
salvagedSegment = false;
|
|
1337
|
+
yieldedSegment = false;
|
|
1338
|
+
resetFailStreaks();
|
|
1177
1339
|
segmentMs = 0;
|
|
1178
1340
|
silenceMs = 0;
|
|
1179
1341
|
prePad = [];
|
|
1180
1342
|
speechActive = false;
|
|
1343
|
+
utteranceEndAt = null;
|
|
1181
1344
|
forcePending = false;
|
|
1182
1345
|
setState(wakeEnabled ? "wake" : "listening");
|
|
1183
1346
|
return;
|
|
@@ -1188,6 +1351,7 @@ function createAsrEngine(config, sessionId) {
|
|
|
1188
1351
|
finalizeSegment();
|
|
1189
1352
|
} else {
|
|
1190
1353
|
forcePending = false;
|
|
1354
|
+
speechActive = false;
|
|
1191
1355
|
setState(wakeEnabled ? "wake" : "listening");
|
|
1192
1356
|
}
|
|
1193
1357
|
},
|
|
@@ -1197,6 +1361,12 @@ function createAsrEngine(config, sessionId) {
|
|
|
1197
1361
|
transcriptListeners.delete(fn);
|
|
1198
1362
|
};
|
|
1199
1363
|
},
|
|
1364
|
+
onNotice(fn) {
|
|
1365
|
+
noticeListeners.add(fn);
|
|
1366
|
+
return () => {
|
|
1367
|
+
noticeListeners.delete(fn);
|
|
1368
|
+
};
|
|
1369
|
+
},
|
|
1200
1370
|
onError(fn) {
|
|
1201
1371
|
errorListeners.add(fn);
|
|
1202
1372
|
return () => {
|
|
@@ -1402,17 +1572,23 @@ var zh = {
|
|
|
1402
1572
|
disabled: "\u8BED\u97F3\u6A21\u5F0F\u5DF2\u7981\u7528\uFF08\u63D2\u4EF6 enabled=false\uFF09",
|
|
1403
1573
|
sendFailKept: "\u53D1\u9001\u5931\u8D25\uFF0C\u5DF2\u4FDD\u7559\u5728\u8349\u7A3F",
|
|
1404
1574
|
micDenied: "\u9EA6\u514B\u98CE\u88AB\u62D2\u7EDD\uFF1A\u8BF7\u5728\u6D4F\u89C8\u5668\u5730\u5740\u680F\u5141\u8BB8\u9EA6\u514B\u98CE\u6743\u9650",
|
|
1575
|
+
micBusy: "\u9EA6\u514B\u98CE\u88AB\u5176\u4ED6\u7A0B\u5E8F\u5360\u7528\uFF1A\u8BF7\u5173\u95ED\u5360\u7528\u7A0B\u5E8F\u540E\u91CD\u8BD5",
|
|
1405
1576
|
micUnavailable: "\u9EA6\u514B\u98CE\u4E0D\u53EF\u7528",
|
|
1406
1577
|
recognizing: "\u8BC6\u522B\u4E2D\u2026",
|
|
1578
|
+
// UX-I1 联动态:纠错在途 / 纠错放弃回退 / 附和词忽略 / 语音按钮态文案。
|
|
1579
|
+
correctFixing: "\u7EA0\u9519\u4E2D\u2026",
|
|
1580
|
+
correctAbandoned: "\u5DF2\u4FDD\u7559\u539F\u6587\u5728\u8349\u7A3F",
|
|
1581
|
+
backchannelDropped: "\u5DF2\u5FFD\u7565\u9644\u548C\u8BCD\uFF0C\u4E0D\u53D1\u9001",
|
|
1582
|
+
buttonLoading: "\u52A0\u8F7D\u4E2D\u2026",
|
|
1583
|
+
buttonListening: "\u8046\u542C\u4E2D",
|
|
1407
1584
|
holdToTalk: "\u6309\u4F4F\u8BF4\u8BDD",
|
|
1408
1585
|
releaseToSend: "\u677E\u5F00\u53D1\u9001",
|
|
1409
|
-
voiceDetected: "\u8BED\u97F3\u4E2D",
|
|
1410
1586
|
entering: "\u8FDB\u5165\u4E2D\u2026",
|
|
1411
1587
|
voiceBtn: "\u8BED\u97F3",
|
|
1412
1588
|
ariaActive: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D",
|
|
1413
1589
|
ariaEnter: "\u8FDB\u5165\u8BED\u97F3\u5BF9\u8BDD\u6A21\u5F0F",
|
|
1414
1590
|
titleHold: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D \xB7 \u6309\u4F4F\u8BF4\u8BDD\u3001\u677E\u624B\u53D1\u9001\uFF1B\u77ED\u6309\u9000\u51FA\uFF1BEsc/\u5931\u53BB\u7126\u70B9\u653E\u5F03\uFF1BCtrl+Shift+V \u9000\u51FA",
|
|
1415
|
-
titleToggle: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D \xB7 \u70B9\u51FB\u9000\u51FA\uFF08Ctrl+Shift+V\uFF09\xB7 \u6309\u4F4F Ctrl \u7ACB\u5373\u53D1\u9001",
|
|
1591
|
+
titleToggle: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D \xB7 \u70B9\u51FB\u9000\u51FA\uFF08Ctrl+Shift+V\uFF09\xB7 \u8BF4\u8BDD\u65F6\u6309\u4F4F Ctrl \u7ACB\u5373\u53D1\u9001",
|
|
1416
1592
|
titleEnter: "\u8FDB\u5165\u8BED\u97F3\u5BF9\u8BDD\u6A21\u5F0F\uFF08Ctrl+Shift+V\uFF09",
|
|
1417
1593
|
loadingModel: "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u2026",
|
|
1418
1594
|
listening: "\u8046\u542C\u4E2D\u2026",
|
|
@@ -1423,13 +1599,18 @@ var zh = {
|
|
|
1423
1599
|
sayWake: "\u8BF4\u300C{wake}\u300D\u5F00\u59CB",
|
|
1424
1600
|
reading: "\u6717\u8BFB\u4E2D\u2026",
|
|
1425
1601
|
recognitionFail: "\u8BC6\u522B\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
1602
|
+
partialFail: "\u5B9E\u65F6\u5B57\u5E55\u6682\u65F6\u4E0D\u53EF\u7528\uFF08\u8BC6\u522B\u901A\u9053\u5F02\u5E38\uFF0C\u91CD\u8BD5\u4E2D\uFF09",
|
|
1603
|
+
detectFail: "\u6253\u65AD\u68C0\u6D4B\u6682\u65F6\u4E0D\u53EF\u7528\uFF08\u68C0\u6D4B\u901A\u9053\u5F02\u5E38\uFF0C\u91CD\u8BD5\u4E2D\uFF09",
|
|
1604
|
+
sseReconnect: "\u72B6\u6001\u540C\u6B65\u65AD\u8FDE\uFF0C\u91CD\u8FDE\u4E2D\u2026",
|
|
1605
|
+
diagCopy: "\u590D\u5236\u8BCA\u65AD",
|
|
1606
|
+
diagCopied: "\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",
|
|
1607
|
+
diagCopyFailed: "\u590D\u5236\u5931\u8D25\uFF08\u6D4F\u89C8\u5668\u62D2\u7EDD\u4E86\u526A\u8D34\u677F\uFF09",
|
|
1426
1608
|
sessionExpired: "\u8BED\u97F3\u4F1A\u8BDD\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u91CD\u8FDE\u2026",
|
|
1427
1609
|
sessionExpiredFail: "\u8BED\u97F3\u4F1A\u8BDD\u91CD\u8FDE\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u5F00\u542F\u8BED\u97F3\u6A21\u5F0F",
|
|
1428
1610
|
modelDownloadFail: "\u8BED\u97F3\u6A21\u578B\u4E0B\u8F7D\u5931\u8D25\uFF08{file}\uFF09\uFF1A\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u65B0\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u91CD\u8BD5",
|
|
1429
1611
|
startFail: "\u8BED\u97F3\u6A21\u5F0F\u542F\u52A8\u5931\u8D25\uFF1A{err}",
|
|
1430
1612
|
holdDots: "\u6309\u4F4F\u8BF4\u8BDD\u2026",
|
|
1431
1613
|
exit: "\u9000\u51FA",
|
|
1432
|
-
skip: "\u8DF3\u8FC7",
|
|
1433
1614
|
configUnavailableNote: "\uFF08\u8BBE\u7F6E\u6587\u6863\u672A\u5C31\u7EEA\uFF0C\u9762\u677F\u5C31\u7EEA\u540E\u4F1A\u81EA\u52A8\u51FA\u73B0\uFF09\u3002",
|
|
1434
1615
|
// settings-form
|
|
1435
1616
|
previewNameFirst: "\u8BF7\u5148\u586B\u5199\u97F3\u8272\u540D\uFF08ShortName\uFF09",
|
|
@@ -1458,7 +1639,7 @@ var zh = {
|
|
|
1458
1639
|
descVoiceKokoro: "Kokoro \u4E2D\u82F1\u97F3\u8272\uFF08103 \u4E2A\u5168\u90E8\u5217\u51FA\uFF0C\u4E0B\u62C9\u9009\u6216 \u25C0\u25B6 \u5207\u6362\uFF1B48-51 \u4E2D\u6587\u540D\uFF0C\u5176\u4F59\u6309\u7F16\u53F7+\u5B9E\u6D4B\u6027\u522B\u6807\u6CE8\uFF0C\u4E2D\u82F1\u6DF7\u8BFB\u5747\u53EF\uFF09",
|
|
1459
1640
|
descRate: "\u6717\u8BFB\u8BED\u901F\u500D\u7387\uFF080.5 \u6162\u901F \uFF5E 2.0 \u5FEB\u901F\uFF0C1.1 \u9ED8\u8BA4\uFF1B\u8BA9\u56DE\u590D\u66F4\u7D27\u51D1\uFF09",
|
|
1460
1641
|
descInterrupt: "\u53D1\u58F0\u6253\u65AD\u7075\u654F\u5EA6\uFF080 \u9AD8\u95E8\u69DB \u22480.3s \u786E\u8BA4 / 1 \u4E2D\u95E8\u69DB \u22480.2s / 2 \u4F4E\u95E8\u69DB \u22480.1s\uFF0C\u6700\u7075\u654F\uFF09\uFF1B\u503C\u8D8A\u4F4E\u95E8\u69DB\u8D8A\u9AD8\uFF0C\u8D8A\u96BE\u6253\u65AD",
|
|
1461
|
-
descBargeIn: "\u6253\u65AD\u65B9\u5F0F\uFF08detect \u81EA\u52A8\u63A2\u6D4B\u672C\u673A\u56DE\u58F0\u6D88\u9664\u72B6\u6001\u3001\u672A\u751F\u6548\u65F6\u5207\u4E3A\u957F\u6309\u6253\u65AD\uFF0C\u9ED8\u8BA4\uFF1Bauto \u5F3A\u5236\u81EA\u52A8\u6253\u65AD\uFF1A\u5F00\u53E3\u5373\u6253\u65AD\uFF0C\u8033\u673A/\u5B89\u9759\u73AF\u5883\u63A8\u8350\uFF1Bmanual \u624B\u52A8\u6253\u65AD\uFF1A\u5916\u653E\u63A8\u8350\u2014\u2014\u56DE\u58F0\u4E0D\u4F1A\u8BEF\u89E6\u53D1\u81EA\u6253\u65AD\uFF0C\u6309\u4F4F\u9EA6\u514B\u98CE/Ctrl \u663E\u5F0F\u6253\u65AD\uFF09",
|
|
1642
|
+
descBargeIn: "\u6253\u65AD\u65B9\u5F0F\uFF08detect \u81EA\u52A8\u63A2\u6D4B\u672C\u673A\u56DE\u58F0\u6D88\u9664\u72B6\u6001\u3001\u672A\u751F\u6548\u65F6\u5207\u4E3A\u957F\u6309\u6253\u65AD\uFF0C\u9ED8\u8BA4\uFF1Bauto \u5F3A\u5236\u81EA\u52A8\u6253\u65AD\uFF1A\u5F00\u53E3\u5373\u6253\u65AD\uFF0C\u8033\u673A/\u5B89\u9759\u73AF\u5883\u63A8\u8350\uFF1Bmanual \u624B\u52A8\u6253\u65AD\uFF1A\u5916\u653E\u63A8\u8350\u2014\u2014\u56DE\u58F0\u4E0D\u4F1A\u8BEF\u89E6\u53D1\u81EA\u6253\u65AD\uFF0C\u6309\u4F4F\u9EA6\u514B\u98CE/Ctrl \u663E\u5F0F\u6253\u65AD\uFF09\u3002\u6CE8\u610F\uFF1Amanual\uFF08detect \u5728\u65E0\u539F\u751F\u56DE\u58F0\u6D88\u9664\u7684\u673A\u5668\u4E0A\u4E5F\u4F1A\u81EA\u52A8\u843D\u5165\uFF09\u4E0B\u975E\u6309\u538B\u671F\u7684\u8BED\u97F3\u4E0D\u88AB\u8BC6\u522B\u2014\u2014toggle \u6A21\u5F0F\u4EC5\u64AD\u653E\u4E2D\u53EF\u957F\u6309\u8BF4\u8BDD\uFF0C\u5F85\u673A\u65F6\u65E0\u6CD5\u8BED\u97F3\u8F93\u5165\uFF0C\u8BF7\u6539\u7528 hold \u6A21\u5F0F\u6216 auto/detect",
|
|
1462
1643
|
bargeInDetect: "\u81EA\u52A8\u63A2\u6D4B",
|
|
1463
1644
|
bargeInAuto: "\u81EA\u52A8",
|
|
1464
1645
|
bargeInManual: "\u624B\u52A8",
|
|
@@ -1469,22 +1650,29 @@ var zh = {
|
|
|
1469
1650
|
aecOffHint: "\u6D4F\u89C8\u5668\u539F\u751F\u56DE\u58F0\u6D88\u9664\u672A\u751F\u6548\uFF08\u5916\u653E\u53EF\u80FD\u81EA\u6253\u65AD\uFF09\uFF0C\u5EFA\u8BAE\u7528\u8033\u673A\u6216\u5207\u6362\u300C\u624B\u52A8\u6253\u65AD\u300D",
|
|
1470
1651
|
// 批 7O(ADR-0006):detect 模式第一级探测降级提示(状态条)。
|
|
1471
1652
|
bargeInDetectFallback: "\u672C\u673A\u56DE\u58F0\u6D88\u9664\u672A\u751F\u6548\uFF0C\u5DF2\u5207\u4E3A\u957F\u6309\u6253\u65AD",
|
|
1653
|
+
// R1 收尾(fix-client 直连 tk() 调用):连续 3 次回声拒断的解释出口 + 快捷键非法停用提示。
|
|
1654
|
+
echoRejectHint: "\u56DE\u58F0\u8F83\u5F3A\uFF0C\u6253\u65AD\u53EF\u80FD\u4E0D\u7075\u654F\u2014\u2014\u8FD9\u662F\u56DE\u58F0\u9632\u62A4\u5728\u751F\u6548\uFF0C\u53EF\u6234\u8033\u673A\u6216\u6539\u7528\u300C\u624B\u52A8\u6253\u65AD\u300D",
|
|
1655
|
+
shortcutInvalid: "\u5FEB\u6377\u952E\u65E0\u6548\uFF0C\u5DF2\u505C\u7528\uFF08\u53EF\u5728\u8BBE\u7F6E\u91CC\u6539\u4E3A\u5982 Ctrl+Shift+V\uFF1B\u7559\u7A7A\u8868\u793A\u53EA\u7528\u9EA6\u514B\u98CE\u6309\u94AE\uFF09",
|
|
1472
1656
|
elapsedHint: "\u5F53\u524D\u8BED\u97F3\u4F1A\u8BDD\u5DF2\u7528\u65F6\u957F",
|
|
1473
1657
|
botLevelsHint: "AI \u6717\u8BFB\u97F3\u91CF\uFF08\u84DD\u8272\u6761 = \u6717\u8BFB\uFF0C\u7EFF\u8272\u6761 = \u9EA6\u514B\u98CE\uFF09",
|
|
1474
1658
|
interruptConfirm: "\u6253\u65AD\u786E\u8BA4",
|
|
1475
1659
|
sev0: "0 \u9AD8\u95E8\u69DB",
|
|
1476
1660
|
sev1: "1 \u4E2D",
|
|
1477
1661
|
sev2: "2 \u4F4E",
|
|
1662
|
+
// 数值单位(设置卡片「当前生效值」用:中文汉字单位、英文国际缩写,避免「1500 ms」直出)
|
|
1663
|
+
unitMs: "\u6BEB\u79D2",
|
|
1664
|
+
unitMin: "\u5206\u949F",
|
|
1665
|
+
unitDb: "\u5206\u8D1D",
|
|
1478
1666
|
descSilence: "\u8BF4\u5B8C\u6574\u4E00\u53E5\u7684\u9759\u97F3\u505C\u987F\u6BEB\u79D2\u6570\uFF08\u9ED8\u8BA4 1500 \u6BEB\u79D2\uFF0C\u7ED9\u601D\u8003\u505C\u987F\u7559\u7A7A\u95F4\uFF1B\u81F3\u5C11 250ms \u8BED\u97F3\u624D\u5224\u53E5\uFF0C\u9632\u77ED\u4FC3\u566A\u58F0\u8BEF\u89E6\u53D1\uFF09",
|
|
1479
|
-
descIdle: "\u65E0\u6D3B\u52A8\u81EA\u52A8\u9000\u51FA\u8BED\u97F3\u6A21\u5F0F\u7684\u5206\u949F\u6570\uFF08\u9ED8\u8BA4 5\uFF1B\
|
|
1667
|
+
descIdle: "\u65E0\u6D3B\u52A8\u81EA\u52A8\u9000\u51FA\u8BED\u97F3\u6A21\u5F0F\u7684\u5206\u949F\u6570\uFF08\u9ED8\u8BA4 5\uFF1B\u9000\u51FA\u524D 30 \u79D2\u4F1A\u6709\u5012\u6570\u9884\u8B66\uFF09",
|
|
1480
1668
|
descModelHost: "ASR \u6A21\u578B\u4E0B\u8F7D\u6E90\uFF08\u5B98\u65B9\u6E90 / \u56FD\u5185\u955C\u50CF\uFF0C\u6216\u9009\u300C\u81EA\u5B9A\u4E49\u300D\u586B\u4EFB\u610F\u955C\u50CF\uFF09",
|
|
1481
|
-
descAutoSend: "\u9759\u97F3\u5230\u70B9\u81EA\u52A8\u53D1\u9001\uFF08\u8FDE\u7EED\u591A\u6BB5\u62FC\u6210\u4E00\u6761\uFF1B\u5173=\u53EA\u8FDB\u8349\u7A3F\uFF1B\u6309\u4F4F Ctrl
|
|
1669
|
+
descAutoSend: "\u9759\u97F3\u5230\u70B9\u81EA\u52A8\u53D1\u9001\uFF08\u8FDE\u7EED\u591A\u6BB5\u62FC\u6210\u4E00\u6761\uFF1B\u5173=\u53EA\u8FDB\u8349\u7A3F\uFF1B\u8BF4\u8BDD\u8FC7\u7A0B\u4E2D\u6309\u4F4F Ctrl \u53EF\u7ACB\u5373\u53D1\u9001\uFF0Chold \u6A21\u5F0F\u677E\u624B\u5373\u53D1\u9001\uFF09",
|
|
1482
1670
|
// 批 7N 重做 5/5:明确「开启后下次进入语音会话即生效」——消除「点完为何不立即恢复」的预期差。
|
|
1483
1671
|
descAutoResume: "\u5207\u6362\u56DE\u4E0A\u6B21\u8BED\u97F3\u4F1A\u8BDD\u65F6\u81EA\u52A8\u6062\u590D\u8BED\u97F3\u6A21\u5F0F\uFF08\u9ED8\u8BA4\u5173\uFF1B\u5F00\u542F\u540E\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u4F1A\u8BDD\u5373\u751F\u6548\u2014\u2014\u81EA\u52A8\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F + \u6062\u590D\u4E0A\u6B21\u4F1A\u8BDD\uFF1B\u5173\u95ED\u5219\u9700\u624B\u52A8\u6309 Ctrl+Shift+V \u91CD\u65B0\u8FDB\u5165\uFF09",
|
|
1484
1672
|
descSpokenFormat: "\u8BED\u97F3\u4F1A\u8BDD\u6CE8\u5165\u53E3\u8BED\u5316\u63D0\u793A\u8BCD\uFF08\u56DE\u590D\u53E3\u8BED\u5316\u3001\u77ED\u53E5\u3001\u4E0D\u7528 Markdown \u6392\u7248\u7B26\u53F7\uFF0C\u6717\u8BFB\u66F4\u987A\u66F4\u5FEB\uFF1B\u9ED8\u8BA4\u5F00\uFF0C\u6539\u52A8\u5373\u65F6\u751F\u6548\uFF09",
|
|
1485
|
-
descSenseVoice: "\
|
|
1673
|
+
descSenseVoice: "\u8BC6\u522B\u6A21\u5F0F\uFF1A\u5F00 = \u51C6\u786E\u6A21\u5F0F\uFF08SenseVoice \u5B9A\u7A3F\uFF0C\u5E26\u6807\u70B9+\u6570\u5B57\u5F52\u4E00\u5316\uFF0C\u957F\u53E5\u5728 CPU \u4E0A\u53EF\u80FD\u7B49\u6570\u79D2\uFF09\uFF1B\u5173 = \u5FEB\u901F\u6A21\u5F0F\uFF08\u6D41\u5F0F\u7ED3\u679C\u76F4\u63A5\u5B9A\u7A3F\uFF0C\u4E0D\u7B49 228MB \u91CD\u8BD1\u6A21\u578B\uFF0C\u51C6\u786E\u5EA6\u7565\u964D\uFF09",
|
|
1674
|
+
recognizingSec: "\u8BC6\u522B\u4E2D\u2026 {sec}s",
|
|
1486
1675
|
descToolBeep: '\u5DE5\u5177\u8C03\u7528\u63D0\u793A\u97F3\uFF08\u9ED8\u8BA4\u5173\uFF09\uFF1AAI \u601D\u8003/\u8C03\u7528\u5DE5\u5177\u65F6"\u6EF4"\u4E00\u58F0\uFF1B\u5ACC\u5435\u5C31\u4FDD\u6301\u5173\u95ED',
|
|
1487
|
-
senseITN: "\u9006\u6587\u672C\u5F52\u4E00\u5316",
|
|
1488
1676
|
descSenseITN: "SenseVoice \u6570\u5B57/\u65E5\u671F/\u683C\u5F0F\u89C4\u8303\u5316\uFF08\u9ED8\u8BA4\u5F00\uFF1B\u5173\u95ED\u540E\u8F93\u51FA\u66F4\u63A5\u8FD1\u53E3\u8BED\u539F\u6587\uFF09",
|
|
1489
1677
|
descCaptionFontSize: "\u6D6E\u5C42\u5B57\u5E55\u5B57\u53F7\u6863\u4F4D\uFF08\u5C0F 12 / \u6807\u51C6 14 / \u5927 18 / \u7279\u5927 24 px\uFF1B\u9ED8\u8BA4\u5C0F\u4E0E\u73B0\u72B6\u5B57\u8282\u7B49\u4EF7\uFF09",
|
|
1490
1678
|
descCaptionMaxWidth: "\u6D6E\u5C42\u5B57\u5E55\u5BBD\u5EA6\u6863\u4F4D\uFF0850vw / 70vw / 90vw\uFF1B\u9ED8\u8BA4 70vw\uFF1B24px \u591A\u884C\u65F6\u53D7 30vh \u9AD8\u5EA6\u7EA6\u675F\u4E0D\u76D6\u8F93\u5165\u6846\uFF09",
|
|
@@ -1495,19 +1683,26 @@ var zh = {
|
|
|
1495
1683
|
captionWidth50: "\u7A84",
|
|
1496
1684
|
captionWidth70: "\u4E2D",
|
|
1497
1685
|
captionWidth90: "\u5BBD",
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
descBackchannelYield: "\u6717\u8BFB\u671F\u7528\u6237\u8BF4\u300C\u55EF/\u5BF9\u300D\u7B49\u77ED\u5E94\u7B54\u65F6\u81EA\u52A8\u8BA9\u4F4D\uFF08\u8DF3\u8FC7\u5F53\u524D TTS \u53E5 + \u77ED\u6682\u4E22\u5E27 1.5s\uFF1B\u771F\u8981\u8BF4\u5219\u539F hardBreak \u63A5\u7BA1\uFF1B\u5173 = \u4E0D\u8BA9\u4F4D\uFF0C\u884C\u4E3A\u7B49\u540C\u6539\u9020\u524D\uFF09",
|
|
1501
|
-
// 批
|
|
1502
|
-
|
|
1503
|
-
|
|
1686
|
+
// 跳过按钮:只跳当前 TTS 句(非整段朗读)——UX 审查歧义修正。
|
|
1687
|
+
skipReading: "\u8DF3\u8FC7\u672C\u53E5",
|
|
1688
|
+
descBackchannelYield: "\u6717\u8BFB\u671F\u7528\u6237\u8BF4\u300C\u55EF/\u5BF9\u300D\u7B49\u77ED\u5E94\u7B54\u65F6\u81EA\u52A8\u8BA9\u4F4D\uFF08\u8DF3\u8FC7\u5F53\u524D TTS \u53E5 + \u77ED\u6682\u4E22\u5E27 1.5s\uFF1B\u771F\u8981\u8BF4\u5219\u539F hardBreak \u63A5\u7BA1\uFF1B\u5173 = \u4E0D\u8BA9\u4F4D\uFF0C\u884C\u4E3A\u7B49\u540C\u6539\u9020\u524D\uFF09\u3002\u4EC5\u300C\u6309\u4F4F\u8BF4\u8BDD\u300D\u6A21\u5F0F\u64AD\u653E\u671F\u53EF\u89E6\u53D1\uFF1A\u300C\u6301\u7EED\u8046\u542C\u300D\u6A21\u5F0F\u64AD\u653E\u671F\u4E0D\u8BC6\u522B\u8BED\u97F3\uFF0C\u5F00\u53E3\u8BF4\u8BDD\u6309\u6253\u65AD\u5904\u7406",
|
|
1689
|
+
// Issue #15 批 1 / ADR-0012:打断语音抢救。
|
|
1690
|
+
descBargeInSalvage: "AI \u6717\u8BFB\u65F6\u4F60\u5F00\u53E3\u6253\u65AD\uFF1A\u81EA\u52A8\u4FDD\u7559\u4ECE\u5F00\u53E3\u5230\u6253\u65AD\u751F\u6548\u4E4B\u95F4\u4F60\u8BF4\u7684\u8BDD\uFF0C\u5E76\u5165\u8BC6\u522B\u7EE7\u7EED\u53D1\u9001\uFF08\u4FEE\u300C\u6253\u65AD\u5403\u53E5\u300D\uFF1B\u5173 = \u4E22\u5F03\u6253\u65AD\u524D\u8BED\u97F3\u2014\u2014\u4EC5\u5916\u653E\u4E14\u65E0\u56DE\u58F0\u6D88\u9664\u7684\u73AF\u5883\u5EFA\u8BAE\u5173\uFF09",
|
|
1691
|
+
descLlmCorrect: "\u53D1\u9001\u524D\u7528\u5927\u6A21\u578B\u5BF9\u6574\u6761\u8BED\u97F3\u6587\u672C\u505A\u4E00\u6B21\u7EA0\u9519\uFF08\u53EA\u6539\u9519\u522B\u5B57/\u540C\u97F3\u5B57/\u6807\u70B9\uFF0C\u4FDD\u6301\u539F\u610F\uFF1B\u9700\u5BBF\u4E3B\u5DF2\u914D\u7F6E\u9ED8\u8BA4\u6A21\u578B\uFF0C\u672A\u914D\u7F6E\u5219\u81EA\u52A8\u7528\u539F\u6587\uFF09\u3002\u5F00 = \u6BCF\u6761\u6D88\u606F\u591A\u4E00\u6B21\u7EA0\u9519\u7B49\u5F85\uFF1A\u901A\u5E38 1 \u79D2\u5185\uFF0C\u6700\u957F\u7EA6 10 \u79D2\uFF1B\u6BCF\u5206\u949F\u6700\u591A 10 \u6B21\uFF0C\u8BED\u97F3\u6A21\u5F0F\u5173\u95ED\u6216\u89E6\u53D1\u9650\u6D41\u65F6\u6309\u539F\u6587\u53D1\u9001\u3002\u7EA0\u9519\u5931\u8D25\u6216\u8F93\u51FA\u5F02\u5E38\u540C\u6837\u81EA\u52A8\u7528\u539F\u6587",
|
|
1692
|
+
descYieldMs: "\u8BA9\u4F4D\u8BED\u4E49\u89E6\u53D1\u540E\u7B49\u5F85\u65F6\u957F\uFF08\u6BEB\u79D2\uFF0C500-3000\uFF0C\u9ED8\u8BA4 1500\uFF1B\u7A97\u53E3\u5185\u7528\u6237\u771F\u8981\u8BF4\u5219\u539F hardBreak \u63A5\u7BA1\uFF0C\u7A97\u53E3\u5230\u70B9\u81EA\u52A8\u6062\u590D\u64AD\u653E\uFF09\u3002\u4EC5\u300C\u6309\u4F4F\u8BF4\u8BDD\u300D\u6A21\u5F0F\u64AD\u653E\u671F\u53EF\u89E6\u53D1",
|
|
1504
1693
|
descMode: "\u4EA4\u4E92\u6A21\u5F0F\uFF08toggle \u6301\u7EED\u8046\u542C+\u9759\u97F3\u65AD\u53E5 / hold \u6309\u4F4F\u8BF4\u8BDD\uFF09",
|
|
1505
1694
|
modeToggle: "\u6301\u7EED\u8046\u542C",
|
|
1506
1695
|
modeHold: "\u6309\u4F4F\u8BF4\u8BDD",
|
|
1507
|
-
descWakeWord: "\u5524\u9192\u8BCD\uFF08\u9ED8\u8BA4\u5173\uFF1B\u5982\u300C\u4F60\u597D\u5C0FD\u300D\uFF09\uFF1A\u8BF4\u51FA\u8BCD\u5934\u624D\u8FDB\u5165\u8BC6\u522B\uFF0C\u907F\u514D\u8BEF\u89E6\u3002\u53EF\u4E0E\u547D\u4EE4\u8FDE\u8BF4\uFF08\u300C\u4F60\u597D\u5C0FD\uFF0C\u5E2E\u6211\u67E5\u5929\u6C14\u300D\u2014\u2014\u8BCD\u5934\u4F1A\u81EA\u52A8\u5265\u6389\u3001\u4E0D\u8FDB\u6D88\u606F\uFF09\uFF1B\u6BCF\u53E5\u65AD\u53E5\u6216\u6253\u65AD\u540E\u9700\u91CD\u8BF4\uFF1B\u4EC5 toggle \u6A21\u5F0F\u751F\u6548\uFF08hold / \u624B\u52A8\u6253\u65AD\u4E0B\u4E0D\u751F\u6548\uFF09\uFF1B\u6717\u8BFB\u671F\u8BF4\u5524\u9192\u8BCD\u4E0D\u89E6\u53D1\uFF08\u6253\u65AD\u4ECD\u6309 VAD \u5F00\u53E3\u5373\u6253\u65AD\uFF09\u3002\u5339\u914D\u5E26\u5BB9\u9519\uFF08\u540C\u97F3\u5B57 / \u524D\u5BFC\u8BED\u6C14\u8BCD\uFF09\uFF0C\u5EFA\u8BAE 3-4 \u5B57\uFF1B\u975E\u4E13\u7528 KWS \u5F15\u64CE\uFF0C\u5608\u6742\u73AF\u5883\u53EF\u80FD\u5EF6\u8FDF\u6216\u8BEF\u6FC0\u6D3B",
|
|
1696
|
+
descWakeWord: "\u5524\u9192\u8BCD\uFF08\u9ED8\u8BA4\u5173\uFF1B\u5982\u300C\u4F60\u597D\u5C0FD\u300D\uFF09\uFF1A\u8BF4\u51FA\u8BCD\u5934\u624D\u8FDB\u5165\u8BC6\u522B\uFF0C\u907F\u514D\u8BEF\u89E6\u3002\u53EF\u4E0E\u547D\u4EE4\u8FDE\u8BF4\uFF08\u300C\u4F60\u597D\u5C0FD\uFF0C\u5E2E\u6211\u67E5\u5929\u6C14\u300D\u2014\u2014\u8BCD\u5934\u4F1A\u81EA\u52A8\u5265\u6389\u3001\u4E0D\u8FDB\u6D88\u606F\uFF09\uFF1B\u6BCF\u53E5\u65AD\u53E5\u6216\u6253\u65AD\u540E\u9700\u91CD\u8BF4\uFF1B\u4EC5 toggle \u6A21\u5F0F\u751F\u6548\uFF08hold / \u624B\u52A8\u6253\u65AD\u4E0B\u4E0D\u751F\u6548\uFF1Bdetect \u81EA\u52A8\u63A2\u6D4B\u672A\u751F\u6548\u3001\u56DE\u843D manual \u65F6\u540C\u6837\u4E0D\u751F\u6548\u2014\u2014Safari \u7B49\u65E0\u539F\u751F\u56DE\u58F0\u6D88\u9664\u7684\u673A\u5668\u4F1A\u9ED8\u8BA4\u843D\u5230\u8FD9\u4E00\u6863\uFF09\uFF1B\u6717\u8BFB\u671F\u8BF4\u5524\u9192\u8BCD\u4E0D\u89E6\u53D1\uFF08\u6253\u65AD\u4ECD\u6309 VAD \u5F00\u53E3\u5373\u6253\u65AD\uFF09\u3002\u5339\u914D\u5E26\u5BB9\u9519\uFF08\u540C\u97F3\u5B57 / \u524D\u5BFC\u8BED\u6C14\u8BCD\uFF09\uFF0C\u5EFA\u8BAE 3-4 \u5B57\uFF1B\u975E\u4E13\u7528 KWS \u5F15\u64CE\uFF0C\u5608\u6742\u73AF\u5883\u53EF\u80FD\u5EF6\u8FDF\u6216\u8BEF\u6FC0\u6D3B",
|
|
1508
1697
|
wakePlaceholder: "\u5982\uFF1A\u4F60\u597D\u5C0FD",
|
|
1509
|
-
settingsCardDesc: "\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / \u6253\u65AD\u7075\u654F\u5EA6 / \u6253\u65AD\u65B9\u5F0F / \u56DE\u58F0\u95E8\u63A7 / \u9759\u97F3\u505C\u987F / \u7A7A\u95F2\u8D85\u65F6 / \u6A21\u578B\u955C\u50CF / \u81EA\u52A8\u53D1\u9001 / \u81EA\u52A8\u6062\u590D / \u4EA4\u4E92\u6A21\u5F0F / \u5524\u9192\u8BCD / \u5DE5\u5177\u63D0\u793A\u97F3 / \u9006\u6587\u672C\u5F52\u4E00\u5316 / \u5B57\u5E55\u5B57\u53F7 / \u5B57\u5E55\u5BBD\u5EA6 / \u77ED\u5E94\u7B54\u8BA9\u4F4D / \u8BA9\u4F4D\u7A97\u53E3",
|
|
1510
|
-
settingsEffectiveNote: "\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / \u6A21\u578B\u7CBE\u5EA6
|
|
1698
|
+
settingsCardDesc: "\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / \u6253\u65AD\u7075\u654F\u5EA6 / \u6253\u65AD\u65B9\u5F0F / \u56DE\u58F0\u95E8\u63A7 / \u9759\u97F3\u505C\u987F / \u7A7A\u95F2\u8D85\u65F6 / \u6A21\u578B\u955C\u50CF / \u81EA\u52A8\u53D1\u9001 / \u81EA\u52A8\u6062\u590D / \u4EA4\u4E92\u6A21\u5F0F / \u5524\u9192\u8BCD / \u5DE5\u5177\u63D0\u793A\u97F3 / \u9006\u6587\u672C\u5F52\u4E00\u5316 / \u5B57\u5E55\u5B57\u53F7 / \u5B57\u5E55\u5BBD\u5EA6 / \u77ED\u5E94\u7B54\u8BA9\u4F4D / \u8BA9\u4F4D\u7A97\u53E3 / \u6253\u65AD\u8BED\u97F3\u62A2\u6551 / LLM \u7EA0\u9519",
|
|
1699
|
+
settingsEffectiveNote: "\u751F\u6548\u65F6\u673A\u5206\u56DB\u6863\uFF1A\u2460 \u5373\u65F6\u2014\u2014\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / Kokoro \u6A21\u578B\u7CBE\u5EA6\uFF08\u5DF2\u7F13\u5B58\u5219\u5373\u65F6\uFF0C\u5426\u5219\u4E0B\u6B21\u4E0B\u8F7D\uFF09/ \u53E3\u8BED\u5316\u63D0\u793A\u8BCD\uFF08\u5BF9\u540E\u7EED\u56DE\u590D\u751F\u6548\uFF09/ \u6A21\u578B\u955C\u50CF\uFF08\u4E0B\u6B21\u4E0B\u8F7D\u5C1D\u8BD5\u5373\u751F\u6548\uFF09\uFF1B\u2461 \u4E0B\u6B21\u8BC6\u522B\u65F6\u2014\u2014\u5B9A\u7A3F\u91CD\u8BD1\uFF08SenseVoice\uFF09/ \u9006\u6587\u672C\u5F52\u4E00\u5316\uFF1B\u2462 \u4E0B\u4E00\u6BB5\u8BDD\u2014\u2014\u9759\u97F3\u5224\u5B9A\u65F6\u957F\uFF08\u65AD\u53E5\u7AEF\u70B9\uFF1B\u53D1\u9001\u7B49\u5F85\u56FA\u5B9A 1.2 \u79D2\u4E0D\u53D7\u5F71\u54CD\uFF09\uFF1B\u2463 \u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u2014\u2014\u6253\u65AD\u7075\u654F\u5EA6 / \u6253\u65AD\u65B9\u5F0F / \u56DE\u58F0\u95E8\u63A7 / \u5FEB\u6377\u952E / \u81EA\u52A8\u53D1\u9001 / \u81EA\u52A8\u6062\u590D / \u4EA4\u4E92\u6A21\u5F0F / \u5524\u9192\u8BCD / \u5DE5\u5177\u63D0\u793A\u97F3 / \u5B57\u5E55\u5B57\u53F7 / \u5B57\u5E55\u5BBD\u5EA6 / \u77ED\u5E94\u7B54\u8BA9\u4F4D / \u8BA9\u4F4D\u7A97\u53E3 / \u6253\u65AD\u8BED\u97F3\u62A2\u6551 / LLM \u7EA0\u9519 / \u7A7A\u95F2\u65F6\u957F\u3002\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u624D\u751F\u6548\u7684\u9879\u4F1A\u5217\u5728\u5361\u7247\u9876\u90E8\uFF08\u542B\u5F53\u524D\u751F\u6548\u503C\uFF09\u3002",
|
|
1700
|
+
effectivePending: "\u6709 {count} \u9879\u4FEE\u6539\u5C06\u5728\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u65F6\u751F\u6548\uFF1A{items}",
|
|
1701
|
+
valueOn: "\u5F00",
|
|
1702
|
+
valueOff: "\u5173",
|
|
1703
|
+
valueQuoted: "\u300C{value}\u300D",
|
|
1704
|
+
effectiveItem: "{label}\uFF08\u5F53\u524D\u751F\u6548 {value}\uFF09",
|
|
1705
|
+
effectiveItemSep: "\u3001",
|
|
1511
1706
|
configUnavailable: "\u914D\u7F6E\u6682\u4E0D\u53EF\u7528",
|
|
1512
1707
|
// telemetry(P1-5 开发模式延迟埋点状态条:各段耗时标签)
|
|
1513
1708
|
telUtteranceEnd: "\u8BF4\u5B8C",
|
|
@@ -1544,7 +1739,6 @@ var zh = {
|
|
|
1544
1739
|
ttsDownloadHint: "\u4E0B\u8F7D\u8BE5\u5F15\u64CE\u7684\u672C\u5730\u6A21\u578B\uFF1B\u4E0B\u8F7D\u5B8C\u6210\u540E\u7ACB\u5373\u5C31\u7EEA\uFF0C\u53EF\u8BD5\u542C/\u6717\u8BFB",
|
|
1545
1740
|
ttsDeleteHint: "\u5220\u9664\u672C\u5730\u6A21\u578B\uFF08\u91CA\u653E\u7A7A\u95F4\uFF1B\u4E0B\u6B21\u4F7F\u7528\u4F1A\u81EA\u52A8\u91CD\u65B0\u4E0B\u8F7D\uFF09",
|
|
1546
1741
|
dataFlowHint: "\u6570\u636E\u6D41\u5411\uFF1AASR \u8BC6\u522B\uFF08zipformer2+SenseVoice\uFF09\u59CB\u7EC8\u672C\u5730\uFF1BTTS \u6717\u8BFB\u53D6\u51B3\u4E8E\u5F15\u64CE\uFF08edge=\u5FAE\u8F6F\u4E91\u7AEF\uFF0Cvits/kokoro=\u672C\u5730\uFF09",
|
|
1547
|
-
kokoroModel: "Kokoro \u6A21\u578B\u7CBE\u5EA6",
|
|
1548
1742
|
kokoroModelInt8: "int8\uFF08\u9ED8\u8BA4\uFF09",
|
|
1549
1743
|
kokoroModelFp32: "fp32\uFF08\u97F3\u8D28\u66F4\u597D\uFF09",
|
|
1550
1744
|
descKokoroModel: "Kokoro \u6A21\u578B\u7CBE\u5EA6\uFF1Aint8 \u4F53\u79EF\u5C0F/\u52A0\u8F7D\u5FEB\uFF08\u7EAF CPU \u670D\u52A1\u5668\u6216\u4F4E\u5E26\u5BBD\u63A8\u8350\uFF0C\u9ED8\u8BA4\uFF09\uFF1Bfp32 \u97F3\u8D28\u66F4\u597D\u4F46\u7EA6 311MB\u3001\u66F4\u6162\uFF08\u6709\u72EC\u7ACB\u663E\u5361\u6216\u5927\u5185\u5B58\u673A\u5668\u63A8\u8350\uFF09\u3002\u4E24\u6863\u5171\u7528\u540C\u4E00\u5957 103 \u97F3\u8272\uFF0C\u5207\u6362\u5373\u65F6\u751F\u6548\u3002",
|
|
@@ -1555,14 +1749,17 @@ var zh = {
|
|
|
1555
1749
|
secRecognition: "\u8BC6\u522B\u4E0E\u53E3\u8BED",
|
|
1556
1750
|
secModel: "\u6A21\u578B\u4E0E\u955C\u50CF",
|
|
1557
1751
|
telTotal: "\u5408\u8BA1",
|
|
1558
|
-
//
|
|
1559
|
-
//
|
|
1560
|
-
//
|
|
1752
|
+
// 字段标题镜像键(*Label 后缀):设置行标题经 settings-form 的 tr(`${name}Label`) 取值。
|
|
1753
|
+
// 批 C 曾与 settings-form 的 FIELD_LABELS 中文双轨并行;整合批已删 FIELD_LABELS,
|
|
1754
|
+
// *Label 键现在是行标题唯一真源(R1 M-2:孪生 base 键已删,防双轨漂移复发)。
|
|
1561
1755
|
senseITNLabel: "\u9006\u6587\u672C\u5F52\u4E00\u5316",
|
|
1562
1756
|
captionFontSizeLabel: "\u5B57\u5E55\u5B57\u53F7",
|
|
1563
1757
|
captionMaxWidthLabel: "\u5B57\u5E55\u5BBD\u5EA6",
|
|
1564
1758
|
backchannelYieldLabel: "\u77ED\u5E94\u7B54\u8BA9\u4F4D",
|
|
1565
|
-
//
|
|
1759
|
+
// Issue #15 批 1 / ADR-0012:打断语音抢救(行标题键)。
|
|
1760
|
+
bargeInSalvageLabel: "\u6253\u65AD\u8BED\u97F3\u62A2\u6551",
|
|
1761
|
+
llmCorrectLabel: "LLM \u7EA0\u9519",
|
|
1762
|
+
// 让位窗口(行标题键)。
|
|
1566
1763
|
yieldMsLabel: "\u8BA9\u4F4D\u7A97\u53E3",
|
|
1567
1764
|
// 批 G 任务 2:空闲预警 + 退出提示文案。
|
|
1568
1765
|
idleWarn30s: "30 \u79D2\u540E\u81EA\u52A8\u9000\u51FA\uFF08\u8BBE\u7F6E\u91CC\u53EF\u8C03\u7A7A\u95F2\u65F6\u957F\uFF09",
|
|
@@ -1638,17 +1835,23 @@ var en = {
|
|
|
1638
1835
|
disabled: "Voice mode disabled (plugin enabled=false)",
|
|
1639
1836
|
sendFailKept: "Send failed; text kept in draft",
|
|
1640
1837
|
micDenied: "Microphone denied: allow mic access for this site",
|
|
1838
|
+
micBusy: "Microphone is in use by another program \u2014 close it and retry",
|
|
1641
1839
|
micUnavailable: "Microphone unavailable",
|
|
1642
1840
|
recognizing: "Recognizing\u2026",
|
|
1841
|
+
// UX-I1 联动态:纠错在途 / 纠错放弃回退 / 附和词忽略 / 语音按钮态文案。
|
|
1842
|
+
correctFixing: "Correcting\u2026",
|
|
1843
|
+
correctAbandoned: "Original text kept in draft",
|
|
1844
|
+
backchannelDropped: "Backchannel ignored, not sent",
|
|
1845
|
+
buttonLoading: "Loading\u2026",
|
|
1846
|
+
buttonListening: "Listening",
|
|
1643
1847
|
holdToTalk: "Hold to talk",
|
|
1644
1848
|
releaseToSend: "Release to send",
|
|
1645
|
-
voiceDetected: "Voice active",
|
|
1646
1849
|
entering: "Entering\u2026",
|
|
1647
1850
|
voiceBtn: "Voice",
|
|
1648
1851
|
ariaActive: "Voice mode active",
|
|
1649
1852
|
ariaEnter: "Enter voice mode",
|
|
1650
1853
|
titleHold: "Voice mode \xB7 hold to talk, release to send; tap to exit; Esc/blur cancels; Ctrl+Shift+V exits",
|
|
1651
|
-
titleToggle: "Voice mode \xB7 click to exit (Ctrl+Shift+V) \xB7 hold Ctrl to send now",
|
|
1854
|
+
titleToggle: "Voice mode \xB7 click to exit (Ctrl+Shift+V) \xB7 hold Ctrl while speaking to send now",
|
|
1652
1855
|
titleEnter: "Enter voice mode (Ctrl+Shift+V)",
|
|
1653
1856
|
loadingModel: "Loading model\u2026",
|
|
1654
1857
|
listening: "Listening\u2026",
|
|
@@ -1659,13 +1862,18 @@ var en = {
|
|
|
1659
1862
|
sayWake: 'Say "{wake}" to start',
|
|
1660
1863
|
reading: "Reading aloud\u2026",
|
|
1661
1864
|
recognitionFail: "Recognition failed, try again",
|
|
1865
|
+
partialFail: "Live captions temporarily unavailable (recognition channel error, retrying)",
|
|
1866
|
+
detectFail: "Break-in detection temporarily unavailable (detect channel error, retrying)",
|
|
1867
|
+
sseReconnect: "State sync disconnected, reconnecting\u2026",
|
|
1868
|
+
diagCopy: "Copy diagnostics",
|
|
1869
|
+
diagCopied: "Diagnostics copied",
|
|
1870
|
+
diagCopyFailed: "Copy failed (clipboard rejected by browser)",
|
|
1662
1871
|
sessionExpired: "Voice session expired, reconnecting\u2026",
|
|
1663
1872
|
sessionExpiredFail: "Voice session reconnect failed; please re-enter voice mode",
|
|
1664
1873
|
modelDownloadFail: "Model download failed ({file}): check network and re-enter voice mode",
|
|
1665
1874
|
startFail: "Voice mode failed to start: {err}",
|
|
1666
1875
|
holdDots: "Hold to talk\u2026",
|
|
1667
1876
|
exit: "Exit",
|
|
1668
|
-
skip: "Skip",
|
|
1669
1877
|
configUnavailableNote: " (settings document not ready; the panel will appear when it is).",
|
|
1670
1878
|
previewNameFirst: "Enter a voice ShortName first",
|
|
1671
1879
|
previewDisabled: "Voice mode disabled (plugin enabled=false); preview unavailable",
|
|
@@ -1692,7 +1900,7 @@ var en = {
|
|
|
1692
1900
|
descVoiceKokoro: "Kokoro zh-en voices (103; \u25C0\u25B6 to cycle; 48-51 named Chinese, others numbered with measured gender; mixed zh-en supported)",
|
|
1693
1901
|
descRate: "Speech rate (0.5 slow \u2013 2.0 fast, 1.1 default; more compact replies)",
|
|
1694
1902
|
descInterrupt: "Interrupt sensitivity (0 high \u22480.3 s confirm / 1 medium \u22480.2 s / 2 low \u22480.1 s, most responsive); lower = higher barrier = harder to interrupt",
|
|
1695
|
-
descBargeIn: "Barge-in mode (detect: auto-probe native echo cancellation, fall back to hold-to-talk when inactive \u2014 default; auto: force interrupt by speaking \u2014 headphones/quiet; manual: for loudspeaker, no echo-triggered self-interrupt \u2014 hold mic/Ctrl to interrupt)",
|
|
1903
|
+
descBargeIn: "Barge-in mode (detect: auto-probe native echo cancellation, fall back to hold-to-talk when inactive \u2014 default; auto: force interrupt by speaking \u2014 headphones/quiet; manual: for loudspeaker, no echo-triggered self-interrupt \u2014 hold mic/Ctrl to interrupt). Note: in manual mode (including detect falling back to manual on machines without native echo cancellation) audio outside a press is not recognized \u2014 in toggle mode you can long-press to speak only while the agent is playing; when idle there is no voice input, so use hold mode or switch to auto/detect",
|
|
1696
1904
|
bargeInDetect: "Auto-detect",
|
|
1697
1905
|
bargeInAuto: "Auto",
|
|
1698
1906
|
bargeInManual: "Manual",
|
|
@@ -1703,22 +1911,29 @@ var en = {
|
|
|
1703
1911
|
aecOffHint: "Native echo cancellation is not active (speaker echo may self-interrupt); use headphones or Manual barge-in",
|
|
1704
1912
|
// 批 7O(ADR-0006):detect 模式第一级探测降级提示(英文)。
|
|
1705
1913
|
bargeInDetectFallback: "Native echo cancellation is off \u2014 switched to hold-to-talk barge-in",
|
|
1914
|
+
// R1 收尾(fix-client 直连 tk() 调用):连续 3 次回声拒断的解释出口 + 快捷键非法停用提示。
|
|
1915
|
+
echoRejectHint: "Strong echo detected \u2014 barge-in is limited by echo protection. Use headphones or switch to manual barge-in",
|
|
1916
|
+
shortcutInvalid: "Invalid shortcut, disabled. Fix it in settings (e.g. Ctrl+Shift+V); leave empty to use the mic button only",
|
|
1706
1917
|
elapsedHint: "Current voice session duration",
|
|
1707
1918
|
botLevelsHint: "AI playback level (blue bar = TTS playback, green bar = microphone)",
|
|
1708
1919
|
interruptConfirm: "interrupt confirm",
|
|
1709
1920
|
sev0: "0 high",
|
|
1710
1921
|
sev1: "1 medium",
|
|
1711
1922
|
sev2: "2 low",
|
|
1923
|
+
// 数值单位(设置卡片「当前生效值」用:中文汉字单位、英文国际缩写,避免「1500 ms」直出)
|
|
1924
|
+
unitMs: "ms",
|
|
1925
|
+
unitMin: "min",
|
|
1926
|
+
unitDb: "dB",
|
|
1712
1927
|
descSilence: "Silence pause before a sentence is committed (default 1500 ms; at least 250 ms of speech required, guards against noise triggers)",
|
|
1713
|
-
descIdle: "Auto-exit voice mode after idle minutes (default 5;
|
|
1928
|
+
descIdle: "Auto-exit voice mode after idle minutes (default 5; a 30-second countdown warning appears before exit)",
|
|
1714
1929
|
descModelHost: "ASR model download source (official source / mirror, or any custom URL)",
|
|
1715
|
-
descAutoSend: "Auto-send once quiet (consecutive segments join into one message; off = draft only; Ctrl
|
|
1930
|
+
descAutoSend: "Auto-send once quiet (consecutive segments join into one message; off = draft only; holding Ctrl while speaking sends immediately; in hold mode, releasing sends)",
|
|
1716
1931
|
// 批 7N 重做 5/5:clarify that toggling takes effect on next session entry (not the current one).
|
|
1717
1932
|
descAutoResume: "Auto-resume voice mode when switching back to the last voice session (default off; takes effect on next session entry \u2014 auto-enters voice mode and restores the last session; when disabled, you must press Ctrl+Shift+V to re-enter)",
|
|
1718
1933
|
descSpokenFormat: "Inject spoken-format prompt into voice replies (colloquial, short sentences, no Markdown; default on, live)",
|
|
1719
|
-
descSenseVoice: "
|
|
1934
|
+
descSenseVoice: "Recognition mode: on = accurate mode (SenseVoice finalization with punctuation + ITN; long utterances may take seconds on CPU); off = fast mode (streaming result finalized directly, skips the 228 MB re-transcription model, slightly less accurate)",
|
|
1935
|
+
recognizingSec: "Recognizing\u2026 {sec}s",
|
|
1720
1936
|
descToolBeep: "Tool-call beep (default off): beep when the agent is thinking/calling tools; keep off if it annoys you",
|
|
1721
|
-
senseITN: "Inverse text normalization",
|
|
1722
1937
|
descSenseITN: "SenseVoice number/date/format normalization (default on; turn off to keep raw spoken form)",
|
|
1723
1938
|
descCaptionFontSize: "Caption font size (Small 12 / Standard 14 / Large 18 / X-Large 24 px; default Small matches current behavior)",
|
|
1724
1939
|
descCaptionMaxWidth: "Caption width (50vw / 70vw / 90vw; default 70vw; capped at 30vh height so multi-line 24px never overlaps the input box)",
|
|
@@ -1729,19 +1944,25 @@ var en = {
|
|
|
1729
1944
|
captionWidth50: "Narrow",
|
|
1730
1945
|
captionWidth70: "Medium",
|
|
1731
1946
|
captionWidth90: "Wide",
|
|
1732
|
-
skipReading: "Skip
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
descYieldMs: "How long (ms) to drop frames after a yield trigger (500-3000, default 1500; within the window the existing hardBreak takes over if the user really wants to speak; auto-resume after the window expires)",
|
|
1947
|
+
skipReading: "Skip this sentence",
|
|
1948
|
+
descBackchannelYield: 'When the user says a short answer like "mm-hmm/right" while the agent is reading aloud, yield automatically (skip the current TTS sentence + drop frames for 1.5s; if the user really wants to speak, the existing hardBreak takes over; off = no yielding, behavior matches before this change). Only triggers in hold-to-talk mode: in continuous-listening mode speech is not recognized during playback (speaking is treated as an interrupt)',
|
|
1949
|
+
// Issue #15 batch 1 / ADR-0012: barge-in speech salvage.
|
|
1950
|
+
descBargeInSalvage: "When you speak to interrupt while the agent is reading aloud, keep what you said from speech onset to break confirmation and merge it into recognition (fixes swallowed break-in speech; off = discard pre-break audio; recommended off only on speakers without echo cancellation)",
|
|
1951
|
+
descLlmCorrect: "Before sending, run one LLM pass over the whole transcribed text (typos/homophones/punctuation only, meaning preserved; requires a default model configured in the host \u2014 otherwise the original text is sent as-is). On = one extra correction round trip per message: usually under 1 second, at most ~10 seconds; at most 10 times per minute \u2014 when voice mode is off or the limit is hit, the original text is sent. Failed or abnormal output also falls back to the original text",
|
|
1952
|
+
descYieldMs: "How long (ms) to drop frames after a yield trigger (500-3000, default 1500; within the window the existing hardBreak takes over if the user really wants to speak; auto-resume after the window expires). Hold-to-talk mode only, during playback",
|
|
1738
1953
|
descMode: "Interaction mode (toggle: continuous listen + auto-send / hold: press to talk)",
|
|
1739
1954
|
modeToggle: "Continuous listening",
|
|
1740
1955
|
modeHold: "Hold to talk",
|
|
1741
|
-
descWakeWord: 'Wake word (default off; e.g. "Hey D"): recognition starts only after you say it, to avoid accidental triggers. You may say it together with your command ("Hey D, check the weather" \u2014 the wake word is stripped and never sent); it must be repeated after each utterance split or barge-in; toggle mode only (inactive in hold / manual barge-in); saying it while the agent is reading does not trigger (barge-in stays VAD-based). Fault-tolerant matching (homophones / leading fillers); 3-4 characters recommended; not a dedicated KWS engine \u2014 noisy environments may delay or falsely trigger',
|
|
1956
|
+
descWakeWord: 'Wake word (default off; e.g. "Hey D"): recognition starts only after you say it, to avoid accidental triggers. You may say it together with your command ("Hey D, check the weather" \u2014 the wake word is stripped and never sent); it must be repeated after each utterance split or barge-in; toggle mode only (inactive in hold / manual barge-in \u2014 and equally inactive when the detect probe fails and falls back to manual, the default on machines without native echo cancellation such as Safari); saying it while the agent is reading does not trigger (barge-in stays VAD-based). Fault-tolerant matching (homophones / leading fillers); 3-4 characters recommended; not a dedicated KWS engine \u2014 noisy environments may delay or falsely trigger',
|
|
1742
1957
|
wakePlaceholder: "e.g. Hey D",
|
|
1743
|
-
settingsCardDesc: "Engine / voice / rate / interrupt / barge-in / echo gate / silence / idle / model host / auto-send / auto-resume / mode / wake word / tool beep / ITN / caption font / caption width / yielding / yield window",
|
|
1744
|
-
settingsEffectiveNote: "
|
|
1958
|
+
settingsCardDesc: "Engine / voice / rate / interrupt / barge-in / echo gate / silence / idle / model host / auto-send / auto-resume / mode / wake word / tool beep / ITN / caption font / caption width / yielding / yield window / barge-in salvage / LLM correction",
|
|
1959
|
+
settingsEffectiveNote: "When settings apply, in four tiers: \u2460 immediately \u2014 engine / voice / rate / Kokoro model precision (immediate when cached, else next download) / spoken format (applies to later replies) / model mirror (next download attempt); \u2461 next recognition \u2014 finalization re-transcription (SenseVoice) / ITN; \u2462 next utterance \u2014 silence threshold (endpoint; the send wait stays a fixed 1.2s); \u2463 next time you enter voice mode \u2014 interrupt sensitivity / barge-in mode / echo gate / shortcut / auto-send / auto-resume / interaction mode / wake word / tool beep / caption font / caption width / backchannel yielding / yield window / barge-in salvage / LLM correction / idle timeout. Items that take effect next time you enter voice mode are listed at the top of this card with their current effective values.",
|
|
1960
|
+
effectivePending: "{count} change(s) will apply next time you enter voice mode: {items}",
|
|
1961
|
+
valueOn: "On",
|
|
1962
|
+
valueOff: "Off",
|
|
1963
|
+
valueQuoted: '"{value}"',
|
|
1964
|
+
effectiveItem: "{label} (currently effective: {value})",
|
|
1965
|
+
effectiveItemSep: ", ",
|
|
1745
1966
|
configUnavailable: "Configuration unavailable",
|
|
1746
1967
|
telUtteranceEnd: "end",
|
|
1747
1968
|
telEndpoint: "endpoint",
|
|
@@ -1775,7 +1996,6 @@ var en = {
|
|
|
1775
1996
|
ttsDownloadHint: "Download this engine's local model; becomes ready immediately after",
|
|
1776
1997
|
dataFlowHint: "Data flow: ASR recognition (zipformer2+SenseVoice) is always local; TTS playback depends on engine (edge=Microsoft cloud, vits/kokoro=local)",
|
|
1777
1998
|
ttsDeleteHint: "Delete local models (frees space; auto re-downloads on next use)",
|
|
1778
|
-
kokoroModel: "Kokoro model precision",
|
|
1779
1999
|
kokoroModelInt8: "int8 (default)",
|
|
1780
2000
|
kokoroModelFp32: "fp32 (better quality)",
|
|
1781
2001
|
descKokoroModel: "Kokoro model precision: int8 is smaller/faster (CPU server or low bandwidth; default); fp32 sounds better but ~311MB and slower (GPU or large memory). Both share the same 103 voices; switches live.",
|
|
@@ -1790,7 +2010,10 @@ var en = {
|
|
|
1790
2010
|
captionFontSizeLabel: "Caption size",
|
|
1791
2011
|
captionMaxWidthLabel: "Caption width",
|
|
1792
2012
|
backchannelYieldLabel: "Short-reply yielding",
|
|
1793
|
-
//
|
|
2013
|
+
// Issue #15 batch 1 / ADR-0012: barge-in speech salvage (row title key).
|
|
2014
|
+
bargeInSalvageLabel: "Barge-in speech salvage",
|
|
2015
|
+
llmCorrectLabel: "LLM correction",
|
|
2016
|
+
// Yield window (row title key).
|
|
1794
2017
|
yieldMsLabel: "Yield window",
|
|
1795
2018
|
// 批 G 任务 2:空闲预警 + 退出提示文案。
|
|
1796
2019
|
idleWarn30s: "Auto-exit in 30 seconds (adjustable in settings)",
|
|
@@ -1941,6 +2164,42 @@ function errorText(body, fallback) {
|
|
|
1941
2164
|
return t(isHostErrorCode(code) ? ERROR_I18N_KEY[code] : fallback);
|
|
1942
2165
|
}
|
|
1943
2166
|
|
|
2167
|
+
// src/steer-submit.ts
|
|
2168
|
+
function shouldSteerSubmit(running, draft) {
|
|
2169
|
+
return running === true && !draft.trim().startsWith("/");
|
|
2170
|
+
}
|
|
2171
|
+
async function trySteerSubmit(session, text) {
|
|
2172
|
+
if (typeof session?.prompt !== "function") return false;
|
|
2173
|
+
try {
|
|
2174
|
+
const r = await session.prompt([{ type: "text", text }], "steer");
|
|
2175
|
+
return !(r && r.ok === false);
|
|
2176
|
+
} catch {
|
|
2177
|
+
return false;
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
// src/draft-compose.ts
|
|
2182
|
+
function composeDraft(current, tail, addition) {
|
|
2183
|
+
const cur = String(current ?? "");
|
|
2184
|
+
const t3 = String(tail ?? "");
|
|
2185
|
+
const base = t3 && cur.endsWith(t3) ? cur.slice(0, cur.length - t3.length).replace(/\s+$/, "") : cur.trim();
|
|
2186
|
+
const add = String(addition ?? "").trim();
|
|
2187
|
+
if (!add) return base;
|
|
2188
|
+
return base ? `${base} ${add}` : add;
|
|
2189
|
+
}
|
|
2190
|
+
function shouldWritePartial(state) {
|
|
2191
|
+
return state !== "wake";
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
// src/runtime-boot.ts
|
|
2195
|
+
var runtimeBoot = null;
|
|
2196
|
+
function setRuntimeBoot(boot) {
|
|
2197
|
+
runtimeBoot = boot;
|
|
2198
|
+
}
|
|
2199
|
+
function getRuntimeBoot() {
|
|
2200
|
+
return runtimeBoot;
|
|
2201
|
+
}
|
|
2202
|
+
|
|
1944
2203
|
// src/settings-form.tsx
|
|
1945
2204
|
var import_react2 = require("react");
|
|
1946
2205
|
|
|
@@ -2630,6 +2889,34 @@ function Row({ name: name2, desc, children }) {
|
|
|
2630
2889
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { flexShrink: 0, maxWidth: 300 }, children })
|
|
2631
2890
|
] });
|
|
2632
2891
|
}
|
|
2892
|
+
var NEXT_ENTRY_FIELDS = [
|
|
2893
|
+
{ key: "interruptLevel", label: "interruptLevelLabel", fmt: (v) => t(v === 1 ? "sev1" : v === 2 ? "sev2" : "sev0") },
|
|
2894
|
+
{ key: "bargeInMode", label: "bargeInModeLabel", fmt: (v) => t(v === "auto" ? "bargeInAuto" : v === "manual" ? "bargeInManual" : "bargeInDetect") },
|
|
2895
|
+
{ key: "echoGateDb", label: "echoGateDbLabel", fmt: (v) => `${v} ${t("unitDb")}` },
|
|
2896
|
+
{ key: "autoSend", label: "autoSendLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
|
|
2897
|
+
{ key: "autoResume", label: "autoResumeLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
|
|
2898
|
+
{ key: "mode", label: "modeLabel", fmt: (v) => t(v === "hold" ? "modeHold" : "modeToggle") },
|
|
2899
|
+
{ key: "wakeWord", label: "wakeWordLabel", fmt: (v) => v ? t("valueQuoted").replace("{value}", String(v)) : t("valueOff") },
|
|
2900
|
+
{ key: "toolBeep", label: "toolBeepLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
|
|
2901
|
+
{ key: "captionFontSize", label: "captionFontSizeLabel", fmt: (v) => t(v === 1 ? "captionSizeM" : v === 2 ? "captionSizeL" : v === 3 ? "captionSizeXL" : "captionSizeS") },
|
|
2902
|
+
{ key: "captionMaxWidth", label: "captionMaxWidthLabel", fmt: (v) => t(v === 0 ? "captionWidth50" : v === 2 ? "captionWidth90" : "captionWidth70") },
|
|
2903
|
+
{ key: "backchannelYield", label: "backchannelYieldLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
|
|
2904
|
+
{ key: "yieldMs", label: "yieldMsLabel", fmt: (v) => `${v} ${t("unitMs")}` },
|
|
2905
|
+
{ key: "bargeInSalvage", label: "bargeInSalvageLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
|
|
2906
|
+
{ key: "llmCorrect", label: "llmCorrectLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
|
|
2907
|
+
{ key: "idleTimeoutMinutes", label: "idleTimeoutMinutesLabel", fmt: (v) => `${v} ${t("unitMin")}` },
|
|
2908
|
+
{ key: "shortcut", label: "shortcutLabel", fmt: (v) => v ? String(v) : t("valueOff") }
|
|
2909
|
+
];
|
|
2910
|
+
function EffectivePending({ effective, value, ready }) {
|
|
2911
|
+
if (!ready || !effective) return null;
|
|
2912
|
+
const pending = NEXT_ENTRY_FIELDS.filter((f) => effective[f.key] !== void 0 && effective[f.key] !== value[f.key]);
|
|
2913
|
+
if (pending.length === 0) return null;
|
|
2914
|
+
const items = pending.map((f) => {
|
|
2915
|
+
const eff = f.fmt ? f.fmt(effective[f.key]) : String(effective[f.key]);
|
|
2916
|
+
return t("effectiveItem").replace("{label}", t(f.label)).replace("{value}", eff);
|
|
2917
|
+
}).join(t("effectiveItemSep"));
|
|
2918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-dshvm-settings": "effective-pending", style: { fontSize: 12, color: "var(--dsw-alias-label-tertiary)", padding: "8px 2px 4px", lineHeight: 1.6 }, children: t("effectivePending").replace("{count}", String(pending.length)).replace("{items}", items) });
|
|
2919
|
+
}
|
|
2633
2920
|
function Section({ title, children }) {
|
|
2634
2921
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 2 }, children: [
|
|
2635
2922
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "10px 0 2px" }, children: [
|
|
@@ -2889,148 +3176,153 @@ function VoiceSettingsCard({ scope, defaultOpen = false }) {
|
|
|
2889
3176
|
] }),
|
|
2890
3177
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { ...setChevron, transform: collapsed ? "rotate(0deg)" : "rotate(180deg)" }, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 16 16", width: 14, height: 14, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "currentColor", d: "M4 6l4 4 4-4z" }) }) })
|
|
2891
3178
|
] }),
|
|
2892
|
-
!collapsed && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
2893
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
{
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
3179
|
+
!collapsed && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { id: "dshvm-settings-card-body", style: setBody, children: [
|
|
3180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(EffectivePending, { effective: getRuntimeBoot(), value, ready: snap?.status === "ready" }),
|
|
3181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 4 }, children: [
|
|
3182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secRead"), children: [
|
|
3183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "ttsEngine", desc: t("descTtsEngine"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3184
|
+
SegGroup,
|
|
3185
|
+
{
|
|
3186
|
+
score: scope,
|
|
3187
|
+
field: "ttsEngine",
|
|
3188
|
+
value: engine,
|
|
3189
|
+
options: [
|
|
3190
|
+
{ v: "vits", label: t("engineVits") },
|
|
3191
|
+
{ v: "kokoro", label: t("engineKokoro") },
|
|
3192
|
+
{ v: "edge", label: t("engineEdge") }
|
|
3193
|
+
],
|
|
3194
|
+
onSelect: (v) => {
|
|
3195
|
+
if (v !== engine) {
|
|
3196
|
+
void scope.set("voice", ENGINE_DEFAULT_VOICE[String(v)] ?? "zh-CN-XiaoxiaoNeural");
|
|
3197
|
+
}
|
|
2908
3198
|
}
|
|
2909
3199
|
}
|
|
2910
|
-
}
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
}
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
}
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
}
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
}
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3200
|
+
) }),
|
|
3201
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(EngineStatusInline, {}),
|
|
3202
|
+
engine === "kokoro" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "kokoroModel", desc: t("descKokoroModel"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3203
|
+
SegGroup,
|
|
3204
|
+
{
|
|
3205
|
+
score: scope,
|
|
3206
|
+
field: "kokoroModel",
|
|
3207
|
+
value: value.kokoroModel,
|
|
3208
|
+
options: [
|
|
3209
|
+
{ v: "int8", label: t("kokoroModelInt8") },
|
|
3210
|
+
{ v: "fp32", label: t("kokoroModelFp32") }
|
|
3211
|
+
]
|
|
3212
|
+
}
|
|
3213
|
+
) }),
|
|
3214
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3215
|
+
Row,
|
|
3216
|
+
{
|
|
3217
|
+
name: "voice",
|
|
3218
|
+
desc: (engine === "edge" ? t("descVoice") : engine === "kokoro" ? t("descVoiceKokoro") : t("descVoiceLocal")) + voiceLangHint(engine, String(value.voice ?? "")),
|
|
3219
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3220
|
+
VoiceSelect,
|
|
3221
|
+
{
|
|
3222
|
+
score: scope,
|
|
3223
|
+
field: "voice",
|
|
3224
|
+
value: value.voice ?? "",
|
|
3225
|
+
options: voiceOptions,
|
|
3226
|
+
placeholder: ENGINE_DEFAULT_VOICE[engine] ?? "zh-CN-XiaoxiaoNeural",
|
|
3227
|
+
showCustom: engine === "edge",
|
|
3228
|
+
footer: (v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePreviewButton, { voice: v, rate: Number(value.rate ?? 1.1) })
|
|
3229
|
+
}
|
|
3230
|
+
)
|
|
3231
|
+
}
|
|
3232
|
+
),
|
|
3233
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "rate", desc: t("descRate"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "rate", value: value.rate ?? 1.1, min: 0.5, max: 2, step: 0.1 }) })
|
|
3234
|
+
] }),
|
|
3235
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secInterrupt"), children: [
|
|
3236
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "interruptLevel", desc: t("descInterrupt"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3237
|
+
SegGroup,
|
|
3238
|
+
{
|
|
3239
|
+
score: scope,
|
|
3240
|
+
field: "interruptLevel",
|
|
3241
|
+
value: value.interruptLevel,
|
|
3242
|
+
options: [
|
|
3243
|
+
{ v: 0, label: t("sev0") },
|
|
3244
|
+
{ v: 1, label: t("sev1") },
|
|
3245
|
+
{ v: 2, label: t("sev2") }
|
|
3246
|
+
]
|
|
3247
|
+
}
|
|
3248
|
+
) }),
|
|
3249
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "bargeInMode", desc: t("descBargeIn"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3250
|
+
SegGroup,
|
|
3251
|
+
{
|
|
3252
|
+
score: scope,
|
|
3253
|
+
field: "bargeInMode",
|
|
3254
|
+
value: value.bargeInMode,
|
|
3255
|
+
options: [
|
|
3256
|
+
{ v: "detect", label: t("bargeInDetect") },
|
|
3257
|
+
{ v: "auto", label: t("bargeInAuto") },
|
|
3258
|
+
{ v: "manual", label: t("bargeInManual") }
|
|
3259
|
+
]
|
|
3260
|
+
}
|
|
3261
|
+
) }),
|
|
3262
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "echoGateDb", desc: t("descEchoGate"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "echoGateDb", value: value.echoGateDb ?? 6, min: 3, max: 12, step: 1 }) })
|
|
3263
|
+
] }),
|
|
3264
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secInteraction"), children: [
|
|
3265
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "mode", desc: t("descMode"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3266
|
+
SegGroup,
|
|
3267
|
+
{
|
|
3268
|
+
score: scope,
|
|
3269
|
+
field: "mode",
|
|
3270
|
+
value: value.mode,
|
|
3271
|
+
options: [
|
|
3272
|
+
{ v: "toggle", label: t("modeToggle") },
|
|
3273
|
+
{ v: "hold", label: t("modeHold") }
|
|
3274
|
+
]
|
|
3275
|
+
}
|
|
3276
|
+
) }),
|
|
3277
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "shortcut", desc: t("descShortcut"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextField, { score: scope, field: "shortcut", value: value.shortcut ?? "Ctrl+Shift+V", placeholder: "Ctrl+Shift+V" }) }),
|
|
3278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "wakeWord", desc: t("descWakeWord"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextField, { score: scope, field: "wakeWord", value: value.wakeWord ?? "", placeholder: t("wakePlaceholder") }) }),
|
|
3279
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "toolBeep", desc: t("descToolBeep"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.toolBeep), onChange: (e) => void scope.set("toolBeep", e.target.checked) }) }),
|
|
3280
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "autoSend", desc: t("descAutoSend"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.autoSend), onChange: (e) => void scope.set("autoSend", e.target.checked) }) }),
|
|
3281
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "autoResume", desc: t("descAutoResume"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.autoResume), onChange: (e) => void scope.set("autoResume", e.target.checked) }) }),
|
|
3282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "captionFontSize", desc: t("descCaptionFontSize"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3283
|
+
SegGroup,
|
|
3284
|
+
{
|
|
3285
|
+
score: scope,
|
|
3286
|
+
field: "captionFontSize",
|
|
3287
|
+
value: value.captionFontSize ?? 0,
|
|
3288
|
+
options: [
|
|
3289
|
+
{ v: 0, label: t("captionSizeS") },
|
|
3290
|
+
{ v: 1, label: t("captionSizeM") },
|
|
3291
|
+
{ v: 2, label: t("captionSizeL") },
|
|
3292
|
+
{ v: 3, label: t("captionSizeXL") }
|
|
3293
|
+
]
|
|
3294
|
+
}
|
|
3295
|
+
) }),
|
|
3296
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "captionMaxWidth", desc: t("descCaptionMaxWidth"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3297
|
+
SegGroup,
|
|
3298
|
+
{
|
|
3299
|
+
score: scope,
|
|
3300
|
+
field: "captionMaxWidth",
|
|
3301
|
+
value: value.captionMaxWidth ?? 1,
|
|
3302
|
+
options: [
|
|
3303
|
+
{ v: 0, label: t("captionWidth50") },
|
|
3304
|
+
{ v: 1, label: t("captionWidth70") },
|
|
3305
|
+
{ v: 2, label: t("captionWidth90") }
|
|
3306
|
+
]
|
|
3307
|
+
}
|
|
3308
|
+
) }),
|
|
3309
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "backchannelYield", desc: t("descBackchannelYield"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.backchannelYield !== false, onChange: (e) => void scope.set("backchannelYield", e.target.checked) }) }),
|
|
3310
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "bargeInSalvage", desc: t("descBargeInSalvage"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.bargeInSalvage !== false, onChange: (e) => void scope.set("bargeInSalvage", e.target.checked) }) }),
|
|
3311
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "llmCorrect", desc: t("descLlmCorrect"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.llmCorrect === true, onChange: (e) => void scope.set("llmCorrect", e.target.checked) }) }),
|
|
3312
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "yieldMs", desc: t("descYieldMs"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "yieldMs", value: value.yieldMs ?? 1500, min: 500, max: 3e3, step: 100 }) })
|
|
3313
|
+
] }),
|
|
3314
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secRecognition"), children: [
|
|
3315
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "senseVoice", desc: t("descSenseVoice"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.senseVoice), onChange: (e) => void scope.set("senseVoice", e.target.checked) }) }),
|
|
3316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "senseITN", desc: t("descSenseITN"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.senseITN !== false, onChange: (e) => void scope.set("senseITN", e.target.checked) }) }),
|
|
3317
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "spokenFormat", desc: t("descSpokenFormat"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.spokenFormat), onChange: (e) => void scope.set("spokenFormat", e.target.checked) }) }),
|
|
3318
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "silenceMs", desc: t("descSilence"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "silenceMs", value: value.silenceMs ?? 1500, min: 500, max: 3e4, step: 100 }) }),
|
|
3319
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "idleTimeoutMinutes", desc: t("descIdle"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "idleTimeoutMinutes", value: value.idleTimeoutMinutes ?? 5, min: 1, max: 120, step: 1 }) })
|
|
3320
|
+
] }),
|
|
3321
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t("secModel"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "modelHost", desc: t("descModelHost"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectField, { score: scope, field: "modelHost", value: value.modelHost ?? "", options: hostOptions(), placeholder: "https://..." }) }) }),
|
|
3322
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 12, color: t2.term, lineHeight: "18px", padding: "4px 0 8px" }, children: t("settingsEffectiveNote") }),
|
|
3323
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModelStatusView, {})
|
|
3324
|
+
] })
|
|
3325
|
+
] })
|
|
3034
3326
|
] });
|
|
3035
3327
|
}
|
|
3036
3328
|
|
|
@@ -3103,7 +3395,21 @@ var TELEMETRY_VIEW = [
|
|
|
3103
3395
|
{ stage: "first-tts-chunk", key: "telFirstChunk" },
|
|
3104
3396
|
{ stage: "first-audio-played", key: "telFirstPlayed" }
|
|
3105
3397
|
];
|
|
3106
|
-
|
|
3398
|
+
function telemetryDeltas(tel) {
|
|
3399
|
+
const out = [];
|
|
3400
|
+
let prev;
|
|
3401
|
+
for (const { stage } of TELEMETRY_VIEW) {
|
|
3402
|
+
const at = tel[stage];
|
|
3403
|
+
if (typeof at !== "number") {
|
|
3404
|
+
prev = void 0;
|
|
3405
|
+
continue;
|
|
3406
|
+
}
|
|
3407
|
+
if (prev !== void 0) out.push(`${stage}=${Math.round(at - prev)}ms`);
|
|
3408
|
+
prev = at;
|
|
3409
|
+
}
|
|
3410
|
+
return out;
|
|
3411
|
+
}
|
|
3412
|
+
var BUILD_TAG = "823302d";
|
|
3107
3413
|
var TELEMETRY_FLAG = "dsh-voice-mode.telemetry";
|
|
3108
3414
|
var telemetryEnabled = typeof localStorage !== "undefined" && localStorage.getItem(TELEMETRY_FLAG) === "1";
|
|
3109
3415
|
console.log("[dsh-voice] build=" + BUILD_TAG);
|
|
@@ -3115,6 +3421,7 @@ var debugLog = (event, fields = {}) => {
|
|
|
3115
3421
|
}
|
|
3116
3422
|
console.log("[dsh-voice]", event, JSON.stringify(out));
|
|
3117
3423
|
};
|
|
3424
|
+
var tk = (key) => t(key);
|
|
3118
3425
|
var beepCtx = null;
|
|
3119
3426
|
function playToolBeep() {
|
|
3120
3427
|
try {
|
|
@@ -3134,6 +3441,7 @@ function playToolBeep() {
|
|
|
3134
3441
|
}
|
|
3135
3442
|
var SAMPLE_RATE_16K = 16e3;
|
|
3136
3443
|
var ECHO_DELAY_MS = 0;
|
|
3444
|
+
var AUTO_SEND_EXTRA_MS = 1200;
|
|
3137
3445
|
var ECHO_TAIL_MS = 400;
|
|
3138
3446
|
var HOLD_CLEAR_FRAMES = 2;
|
|
3139
3447
|
var WAVE_BARS = 14;
|
|
@@ -3239,7 +3547,9 @@ function apply(ctx) {
|
|
|
3239
3547
|
id: "voice-mode",
|
|
3240
3548
|
key: "voice-mode",
|
|
3241
3549
|
order: 100,
|
|
3242
|
-
|
|
3550
|
+
// M13:函数形式(与下方 settings.section 注册一致)——注册时求值会把
|
|
3551
|
+
// 切换语言前的旧文案冻在菜单里;函数形式每次渲染读当前语言。
|
|
3552
|
+
label: () => t("stateVoiceMode")
|
|
3243
3553
|
},
|
|
3244
3554
|
() => React.createElement(VoiceSettingsCard, { scope })
|
|
3245
3555
|
)
|
|
@@ -3433,11 +3743,15 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3433
3743
|
captionFontSize: 0,
|
|
3434
3744
|
captionMaxWidth: 1,
|
|
3435
3745
|
backchannelYield: true,
|
|
3746
|
+
// Issue #15 批 1 / ADR-0012:打断语音抢救默认 true(与 VOICE_SETTINGS_DEFAULTS 对齐)。
|
|
3747
|
+
bargeInSalvage: true,
|
|
3748
|
+
llmCorrect: false,
|
|
3436
3749
|
yieldMs: 1500,
|
|
3437
3750
|
// 批 B:5 ASR 字段默认值,与 src/index.ts VOICE_SETTINGS_DEFAULTS 对齐(plan §12 批 B 周全修复)。
|
|
3438
3751
|
senseITN: true,
|
|
3439
3752
|
senseVoice: true
|
|
3440
3753
|
};
|
|
3754
|
+
let noticeTimer = null;
|
|
3441
3755
|
const ui = {
|
|
3442
3756
|
state: "idle",
|
|
3443
3757
|
partial: "",
|
|
@@ -3454,7 +3768,8 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3454
3768
|
turn: "idle",
|
|
3455
3769
|
wakeWord: "",
|
|
3456
3770
|
// 批 H 任务 4:autoResume 引导提示(一次会话内一次)。
|
|
3457
|
-
notice: null
|
|
3771
|
+
notice: null,
|
|
3772
|
+
sseDown: false
|
|
3458
3773
|
};
|
|
3459
3774
|
const listeners = /* @__PURE__ */ new Set();
|
|
3460
3775
|
const audioListeners = /* @__PURE__ */ new Set();
|
|
@@ -3475,7 +3790,6 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3475
3790
|
}
|
|
3476
3791
|
};
|
|
3477
3792
|
const resetTelemetry = () => {
|
|
3478
|
-
if (!telemetryEnabled) return;
|
|
3479
3793
|
for (const k of Object.keys(telemetryStages)) delete telemetryStages[k];
|
|
3480
3794
|
ui.telemetry = null;
|
|
3481
3795
|
ui.interruptConfirmMs = void 0;
|
|
@@ -3592,11 +3906,13 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3592
3906
|
// A2.5 双讲冻结:用户说话时暂停 NLMS 自适应。
|
|
3593
3907
|
setFrozen: (frozen) => aec.setFrozen(frozen)
|
|
3594
3908
|
};
|
|
3909
|
+
const setUi = (patch) => {
|
|
3910
|
+
if (patch.playing === false && ui.playing === true) playingEndAt = Date.now();
|
|
3911
|
+
Object.assign(ui, patch);
|
|
3912
|
+
notify();
|
|
3913
|
+
};
|
|
3595
3914
|
const engine = createAudioEngine(
|
|
3596
|
-
|
|
3597
|
-
Object.assign(ui, patch);
|
|
3598
|
-
notify();
|
|
3599
|
-
},
|
|
3915
|
+
setUi,
|
|
3600
3916
|
() => stampTelemetry("first-audio-played"),
|
|
3601
3917
|
(pcm, sampleRate, wallMs) => {
|
|
3602
3918
|
pushRef(pcm, sampleRate, wallMs);
|
|
@@ -3623,6 +3939,20 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3623
3939
|
source.addEventListener("open", () => {
|
|
3624
3940
|
rejectSeqUpTo.clear();
|
|
3625
3941
|
lastFinalSeq.clear();
|
|
3942
|
+
curSentenceId = null;
|
|
3943
|
+
curChunks = [];
|
|
3944
|
+
curBytes = 0;
|
|
3945
|
+
curChunkCount = 0;
|
|
3946
|
+
if (ui.sseDown) {
|
|
3947
|
+
ui.sseDown = false;
|
|
3948
|
+
notify();
|
|
3949
|
+
}
|
|
3950
|
+
});
|
|
3951
|
+
source.addEventListener("error", () => {
|
|
3952
|
+
if (!ui.sseDown) {
|
|
3953
|
+
ui.sseDown = true;
|
|
3954
|
+
notify();
|
|
3955
|
+
}
|
|
3626
3956
|
});
|
|
3627
3957
|
source.addEventListener("mode", (e) => {
|
|
3628
3958
|
try {
|
|
@@ -3688,6 +4018,7 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3688
4018
|
source.addEventListener("asr-error", (e) => {
|
|
3689
4019
|
try {
|
|
3690
4020
|
const p = JSON.parse(e.data);
|
|
4021
|
+
if (!activeSessionId) return;
|
|
3691
4022
|
ui.error = t("modelDownloadFail").replace("{file}", p.file ?? "");
|
|
3692
4023
|
ui.model = null;
|
|
3693
4024
|
notify();
|
|
@@ -3829,16 +4160,24 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3829
4160
|
ui,
|
|
3830
4161
|
subscribe(fn) {
|
|
3831
4162
|
listeners.add(fn);
|
|
3832
|
-
fn({ active: activeSessionId, ui: { ...ui, levels: [...ui.levels] } });
|
|
4163
|
+
fn({ active: activeSessionId, ui: { ...ui, levels: [...ui.levels], botLevels: [...ui.botLevels] } });
|
|
3833
4164
|
return () => {
|
|
3834
4165
|
listeners.delete(fn);
|
|
3835
4166
|
};
|
|
3836
4167
|
},
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
Object.assign(ui, patch);
|
|
4168
|
+
setNotice(hint) {
|
|
4169
|
+
ui.notice = hint;
|
|
3840
4170
|
notify();
|
|
4171
|
+
if (noticeTimer) clearTimeout(noticeTimer);
|
|
4172
|
+
noticeTimer = setTimeout(() => {
|
|
4173
|
+
noticeTimer = null;
|
|
4174
|
+
if (ui.notice === hint) {
|
|
4175
|
+
ui.notice = null;
|
|
4176
|
+
notify();
|
|
4177
|
+
}
|
|
4178
|
+
}, 5e3);
|
|
3841
4179
|
},
|
|
4180
|
+
setUi,
|
|
3842
4181
|
/** isPlaying 尾音截止墙钟:playing 或尾音宽限期内均视为「AI 正在朗读」。 */
|
|
3843
4182
|
playingTailUntil() {
|
|
3844
4183
|
return playingEndAt + ECHO_TAIL_MS + refDelaySamples / SAMPLE_RATE_16K * 1e3;
|
|
@@ -3852,6 +4191,7 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3852
4191
|
});
|
|
3853
4192
|
const out = await res.json();
|
|
3854
4193
|
activeSessionId = out.active === sessionId ? sessionId : null;
|
|
4194
|
+
playingEndAt = 0;
|
|
3855
4195
|
notify();
|
|
3856
4196
|
if (!res.ok) return { ok: false, error: errorText(out, "enterFail") };
|
|
3857
4197
|
if (out.active === sessionId) setLastVoiceSession(sessionId);
|
|
@@ -3864,10 +4204,12 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3864
4204
|
return { ok: false, error: t("enterFail") };
|
|
3865
4205
|
}
|
|
3866
4206
|
},
|
|
3867
|
-
async exit(sessionId) {
|
|
4207
|
+
async exit(sessionId, keepAudio) {
|
|
3868
4208
|
resetTelemetry();
|
|
3869
4209
|
ui.turn = "idle";
|
|
3870
|
-
|
|
4210
|
+
if (!keepAudio) {
|
|
4211
|
+
doSkipAudio();
|
|
4212
|
+
}
|
|
3871
4213
|
try {
|
|
3872
4214
|
const res = await fetch(`${location.origin}${basePath}/toggle`, {
|
|
3873
4215
|
method: "POST",
|
|
@@ -3911,6 +4253,14 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
|
|
|
3911
4253
|
} catch {
|
|
3912
4254
|
}
|
|
3913
4255
|
},
|
|
4256
|
+
steerSubmit(sessionId, text) {
|
|
4257
|
+
try {
|
|
4258
|
+
const session = ctx?.sessions?.binding?.(sessionId)?.session;
|
|
4259
|
+
return trySteerSubmit(session, text);
|
|
4260
|
+
} catch {
|
|
4261
|
+
return Promise.resolve(false);
|
|
4262
|
+
}
|
|
4263
|
+
},
|
|
3914
4264
|
stampTelemetry,
|
|
3915
4265
|
resetTelemetry,
|
|
3916
4266
|
warmAudio() {
|
|
@@ -3957,6 +4307,7 @@ function MicButton({
|
|
|
3957
4307
|
const localRef = (0, import_react3.useRef)("off");
|
|
3958
4308
|
const sidRef = (0, import_react3.useRef)(sessionId);
|
|
3959
4309
|
const engineRef = (0, import_react3.useRef)(null);
|
|
4310
|
+
const micReadyRef = (0, import_react3.useRef)(false);
|
|
3960
4311
|
const actionsRef = (0, import_react3.useRef)(inputActions);
|
|
3961
4312
|
const submitTimerRef = (0, import_react3.useRef)(null);
|
|
3962
4313
|
const autoSendTimerRef = (0, import_react3.useRef)(null);
|
|
@@ -3987,6 +4338,9 @@ function MicButton({
|
|
|
3987
4338
|
captionFontSize: 0,
|
|
3988
4339
|
captionMaxWidth: 1,
|
|
3989
4340
|
backchannelYield: true,
|
|
4341
|
+
// Issue #15 批 1 / ADR-0012:打断语音抢救默认 true。
|
|
4342
|
+
bargeInSalvage: true,
|
|
4343
|
+
llmCorrect: false,
|
|
3990
4344
|
yieldMs: 1500,
|
|
3991
4345
|
// 批 B:5 ASR 字段默认值,与 src/index.ts VOICE_SETTINGS_DEFAULTS 对齐(plan §12 批 B 周全修复)。
|
|
3992
4346
|
senseITN: true,
|
|
@@ -3994,8 +4348,12 @@ function MicButton({
|
|
|
3994
4348
|
};
|
|
3995
4349
|
useVoiceCss();
|
|
3996
4350
|
const [, bumpUi] = (0, import_react3.useState)(0);
|
|
4351
|
+
const uiKeyRef = (0, import_react3.useRef)("");
|
|
3997
4352
|
(0, import_react3.useEffect)(
|
|
3998
|
-
() => bus.subscribe(() => {
|
|
4353
|
+
() => bus.subscribe(({ active, ui: u }) => {
|
|
4354
|
+
const key = `${active}|${u.state}|${u.error ?? ""}|${u.notice ?? ""}|${u.mode}|${u.wakeWord}|${u.ttsNotice ?? ""}`;
|
|
4355
|
+
if (key === uiKeyRef.current) return;
|
|
4356
|
+
uiKeyRef.current = key;
|
|
3999
4357
|
bumpUi((t3) => t3 + 1);
|
|
4000
4358
|
}),
|
|
4001
4359
|
[bus]
|
|
@@ -4028,6 +4386,9 @@ function MicButton({
|
|
|
4028
4386
|
captionMaxWidth: c.captionMaxWidth === 0 || c.captionMaxWidth === 2 ? c.captionMaxWidth : 1,
|
|
4029
4387
|
// 批 5:同模式(plan §7.2 表漏列 fetchConfig 字段透传,类批 3 captionFontSize 集成层补丁)
|
|
4030
4388
|
backchannelYield: c.backchannelYield !== false,
|
|
4389
|
+
// Issue #15 批 1 / ADR-0012:打断语音抢救透传(同 backchannelYield 模式)。
|
|
4390
|
+
bargeInSalvage: c.bargeInSalvage !== false,
|
|
4391
|
+
llmCorrect: c.llmCorrect === true,
|
|
4031
4392
|
// 批 G 任务 3:让位窗口时长(500-3000ms);类型校验严格 + 默认值兜底。
|
|
4032
4393
|
yieldMs: typeof c.yieldMs === "number" && c.yieldMs >= 500 && c.yieldMs <= 3e3 ? c.yieldMs : 1500,
|
|
4033
4394
|
// 批 B:5 ASR 字段透传(host /config handler 在 c2120d9 已透传 4 字段,本批补 senseVoice + 客户端白名单对齐)。
|
|
@@ -4035,7 +4396,9 @@ function MicButton({
|
|
|
4035
4396
|
senseITN: c.senseITN === false ? false : true,
|
|
4036
4397
|
senseVoice: c.senseVoice === false ? false : true
|
|
4037
4398
|
};
|
|
4399
|
+
if (next.shortcut && !parseShortcut(next.shortcut)) bus.setNotice(tk("shortcutInvalid"));
|
|
4038
4400
|
bus.setUi({ boot: next, mode: next.mode, wakeWord: next.wakeWord });
|
|
4401
|
+
setRuntimeBoot(next);
|
|
4039
4402
|
return next;
|
|
4040
4403
|
} catch {
|
|
4041
4404
|
return bootNow();
|
|
@@ -4074,16 +4437,16 @@ function MicButton({
|
|
|
4074
4437
|
const sid = sidRef.current;
|
|
4075
4438
|
if (localRef.current === "on" && sid) {
|
|
4076
4439
|
const quitMsg = t("idleTimeoutQuit");
|
|
4077
|
-
|
|
4078
|
-
error: bus.ui.error ?? quitMsg
|
|
4440
|
+
void exitModeRef.current("idle").then(() => {
|
|
4441
|
+
bus.setUi({ error: bus.ui.error ?? quitMsg });
|
|
4442
|
+
const prevClearError = idleClearErrorRef.current;
|
|
4443
|
+
if (prevClearError) clearTimeout(prevClearError);
|
|
4444
|
+
idleClearErrorRef.current = setTimeout(() => {
|
|
4445
|
+
idleClearErrorRef.current = null;
|
|
4446
|
+
if (bus.ui.error === quitMsg) bus.setUi({ error: null });
|
|
4447
|
+
}, 3e3);
|
|
4448
|
+
}).catch(() => {
|
|
4079
4449
|
});
|
|
4080
|
-
const prevClearError = idleClearErrorRef.current;
|
|
4081
|
-
if (prevClearError) clearTimeout(prevClearError);
|
|
4082
|
-
idleClearErrorRef.current = setTimeout(() => {
|
|
4083
|
-
idleClearErrorRef.current = null;
|
|
4084
|
-
if (bus.ui.error === quitMsg) bus.setUi({ error: null });
|
|
4085
|
-
}, 3e3);
|
|
4086
|
-
void exitModeRef.current("idle");
|
|
4087
4450
|
}
|
|
4088
4451
|
}, idleMs);
|
|
4089
4452
|
};
|
|
@@ -4097,13 +4460,21 @@ function MicButton({
|
|
|
4097
4460
|
cancelPendingSubmit();
|
|
4098
4461
|
cancelAutoSend();
|
|
4099
4462
|
clearBreakTimer();
|
|
4463
|
+
if (breakDotsTimerRef.current) {
|
|
4464
|
+
clearTimeout(breakDotsTimerRef.current);
|
|
4465
|
+
breakDotsTimerRef.current = null;
|
|
4466
|
+
}
|
|
4100
4467
|
setHolding(false);
|
|
4101
4468
|
isSpeechTrueCount = 0;
|
|
4469
|
+
isSpeechFalseRun = 0;
|
|
4470
|
+
submitInFlightRef.current = false;
|
|
4471
|
+
correctCycleRef.current++;
|
|
4102
4472
|
breakRef.current = null;
|
|
4103
4473
|
manualHoldRef.current = false;
|
|
4104
4474
|
holdCtrlRef.current = false;
|
|
4105
4475
|
const engine = engineRef.current;
|
|
4106
4476
|
engineRef.current = null;
|
|
4477
|
+
micReadyRef.current = false;
|
|
4107
4478
|
if (engine) void engine.stop();
|
|
4108
4479
|
bus.resetTelemetry();
|
|
4109
4480
|
bus.setUi({ state: "idle", partial: "", levels: [], botLevels: [], error: null, model: null, ttsNotice: null, isSpeech: void 0 });
|
|
@@ -4122,40 +4493,110 @@ function MicButton({
|
|
|
4122
4493
|
autoSendTimerRef.current = null;
|
|
4123
4494
|
}
|
|
4124
4495
|
};
|
|
4496
|
+
const correctDraft = async (text) => {
|
|
4497
|
+
const hint = t("correctFixing");
|
|
4498
|
+
bus.setUi({ notice: hint });
|
|
4499
|
+
try {
|
|
4500
|
+
const r = await fetch(`${location.origin}${BASE_PATH2}/correct`, {
|
|
4501
|
+
method: "POST",
|
|
4502
|
+
headers: { "content-type": "application/json" },
|
|
4503
|
+
body: JSON.stringify({ text, lang: activeLocale() === "en" ? "en" : "zh" }),
|
|
4504
|
+
signal: AbortSignal.timeout(12e3)
|
|
4505
|
+
// 上限 12s——超时按原文发,不等纠错
|
|
4506
|
+
});
|
|
4507
|
+
if (bus.ui.notice === hint) bus.setUi({ notice: null });
|
|
4508
|
+
if (!r.ok) return text;
|
|
4509
|
+
const out = await r.json();
|
|
4510
|
+
const corrected = typeof out.text === "string" ? out.text.trim() : "";
|
|
4511
|
+
return corrected || text;
|
|
4512
|
+
} catch (e) {
|
|
4513
|
+
if (bus.ui.notice === hint) bus.setUi({ notice: null });
|
|
4514
|
+
if (e instanceof DOMException && e.name === "TimeoutError") bus.setNotice(t("correctAbandoned"));
|
|
4515
|
+
return text;
|
|
4516
|
+
}
|
|
4517
|
+
};
|
|
4125
4518
|
const submitDraftNow = (expectedText) => {
|
|
4126
4519
|
cancelPendingSubmit();
|
|
4127
4520
|
const actions = actionsRef.current;
|
|
4128
4521
|
const submitFn = actions?.submit;
|
|
4129
|
-
if (typeof submitFn !== "function")
|
|
4522
|
+
if (typeof submitFn !== "function") {
|
|
4523
|
+
submitInFlightRef.current = false;
|
|
4524
|
+
return;
|
|
4525
|
+
}
|
|
4130
4526
|
const draftSnapshot = (expectedText ?? draftRef.current).trim();
|
|
4131
|
-
if (!draftSnapshot)
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4527
|
+
if (!draftSnapshot) {
|
|
4528
|
+
submitInFlightRef.current = false;
|
|
4529
|
+
return;
|
|
4530
|
+
}
|
|
4531
|
+
const runSubmit = (submitText) => {
|
|
4532
|
+
submitInFlightRef.current = true;
|
|
4533
|
+
const snapshot = submitText.trim() || draftSnapshot;
|
|
4534
|
+
let wroteBack = false;
|
|
4535
|
+
if (snapshot !== draftSnapshot && typeof actions?.setDraft === "function") {
|
|
4536
|
+
try {
|
|
4537
|
+
actions.setDraft(snapshot);
|
|
4538
|
+
wroteBack = true;
|
|
4539
|
+
} catch {
|
|
4139
4540
|
}
|
|
4140
|
-
} catch {
|
|
4141
|
-
bus.setUi({ error: t("sendFailKept") });
|
|
4142
4541
|
}
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4542
|
+
const submitViaQueue = () => {
|
|
4543
|
+
const doSubmit = () => {
|
|
4544
|
+
try {
|
|
4545
|
+
const r = submitFn();
|
|
4546
|
+
if (r && typeof r.then === "function") {
|
|
4547
|
+
r.catch(() => {
|
|
4548
|
+
bus.setUi({ error: t("sendFailKept") });
|
|
4549
|
+
});
|
|
4550
|
+
}
|
|
4551
|
+
} catch {
|
|
4552
|
+
bus.setUi({ error: t("sendFailKept") });
|
|
4553
|
+
}
|
|
4554
|
+
};
|
|
4555
|
+
doSubmit();
|
|
4556
|
+
let retryCount = 0;
|
|
4557
|
+
submitTimerRef.current = setInterval(() => {
|
|
4558
|
+
retryCount++;
|
|
4559
|
+
const phase = phaseRef.current;
|
|
4560
|
+
if (retryCount > 3 || phase === "submitting" || phase === "adjudicating" || draftRef.current.trim() !== (wroteBack ? snapshot : draftSnapshot)) {
|
|
4561
|
+
cancelPendingSubmit();
|
|
4562
|
+
return;
|
|
4563
|
+
}
|
|
4564
|
+
doSubmit();
|
|
4565
|
+
}, 500);
|
|
4566
|
+
};
|
|
4567
|
+
const sid = sidRef.current;
|
|
4568
|
+
if (sid && shouldSteerSubmit(runningRef.current, snapshot)) {
|
|
4569
|
+
void bus.steerSubmit(sid, snapshot).then((delivered) => {
|
|
4570
|
+
if (delivered) {
|
|
4571
|
+
if (draftRef.current.trim() === (wroteBack ? snapshot : draftSnapshot)) {
|
|
4572
|
+
try {
|
|
4573
|
+
actions?.setDraft?.("");
|
|
4574
|
+
} catch {
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
return;
|
|
4578
|
+
}
|
|
4579
|
+
submitViaQueue();
|
|
4580
|
+
}).catch(() => submitViaQueue());
|
|
4151
4581
|
return;
|
|
4152
4582
|
}
|
|
4153
|
-
|
|
4154
|
-
}
|
|
4583
|
+
submitViaQueue();
|
|
4584
|
+
};
|
|
4585
|
+
if (bootNow().llmCorrect === true && !draftSnapshot.startsWith("/")) {
|
|
4586
|
+
const myCycle = ++correctCycleRef.current;
|
|
4587
|
+
void correctDraft(draftSnapshot).then((finalText) => {
|
|
4588
|
+
if (correctCycleRef.current !== myCycle) return;
|
|
4589
|
+
if (submitInFlightRef.current) return;
|
|
4590
|
+
if (draftRef.current.trim() !== draftSnapshot) return;
|
|
4591
|
+
if (engineRef.current?.state === "speech") return;
|
|
4592
|
+
runSubmit(finalText);
|
|
4593
|
+
});
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
runSubmit(draftSnapshot);
|
|
4155
4597
|
};
|
|
4156
4598
|
const scheduleAutoSend = () => {
|
|
4157
4599
|
cancelAutoSend();
|
|
4158
|
-
const delay = bootNow().silenceMs;
|
|
4159
4600
|
autoSendTimerRef.current = setTimeout(() => {
|
|
4160
4601
|
autoSendTimerRef.current = null;
|
|
4161
4602
|
const eng = engineRef.current;
|
|
@@ -4163,15 +4604,22 @@ function MicButton({
|
|
|
4163
4604
|
if (bus.ui.playing) return;
|
|
4164
4605
|
if (bootNow().autoSend === false) return;
|
|
4165
4606
|
submitDraftNow();
|
|
4166
|
-
},
|
|
4607
|
+
}, AUTO_SEND_EXTRA_MS);
|
|
4167
4608
|
};
|
|
4168
|
-
const exitMode = async (
|
|
4609
|
+
const exitMode = async (reason) => {
|
|
4169
4610
|
if (localRef.current === "off") return;
|
|
4170
4611
|
setLocalMode("off");
|
|
4171
4612
|
clearIdle();
|
|
4172
4613
|
cancelPendingSubmit();
|
|
4173
4614
|
cancelAutoSend();
|
|
4615
|
+
submitInFlightRef.current = false;
|
|
4616
|
+
correctCycleRef.current++;
|
|
4174
4617
|
isSpeechTrueCount = 0;
|
|
4618
|
+
isSpeechFalseRun = 0;
|
|
4619
|
+
if (breakDotsTimerRef.current) {
|
|
4620
|
+
clearTimeout(breakDotsTimerRef.current);
|
|
4621
|
+
breakDotsTimerRef.current = null;
|
|
4622
|
+
}
|
|
4175
4623
|
fixtureRecorder.save("exit");
|
|
4176
4624
|
breakRef.current = null;
|
|
4177
4625
|
manualHoldRef.current = false;
|
|
@@ -4179,16 +4627,19 @@ function MicButton({
|
|
|
4179
4627
|
setHolding(false);
|
|
4180
4628
|
const engine = engineRef.current;
|
|
4181
4629
|
engineRef.current = null;
|
|
4630
|
+
micReadyRef.current = false;
|
|
4182
4631
|
if (engine) await engine.stop();
|
|
4183
4632
|
bus.resetTelemetry();
|
|
4184
4633
|
bus.setUi({ state: "idle", partial: "", levels: [], error: null, model: null, ttsNotice: null, isSpeech: void 0 });
|
|
4185
4634
|
const sid = sidRef.current;
|
|
4186
|
-
if (sid) await bus.exit(sid);
|
|
4635
|
+
if (sid) await bus.exit(sid, reason === "typing");
|
|
4187
4636
|
};
|
|
4188
4637
|
const enterMode = async () => {
|
|
4189
4638
|
const sid = sidRef.current;
|
|
4190
4639
|
if (!sid || localRef.current !== "off") return;
|
|
4191
4640
|
isSpeechTrueCount = 0;
|
|
4641
|
+
isSpeechFalseRun = 0;
|
|
4642
|
+
micReadyRef.current = false;
|
|
4192
4643
|
setLocalMode("pending");
|
|
4193
4644
|
try {
|
|
4194
4645
|
const entered = await bus.enter(sid);
|
|
@@ -4211,6 +4662,7 @@ function MicButton({
|
|
|
4211
4662
|
const interruptLevel = cfg.interruptLevel;
|
|
4212
4663
|
const confirmFrames = INT_CONFIRM_FRAMES[interruptLevel] ?? 2;
|
|
4213
4664
|
let bargeInMode = cfg.bargeInMode;
|
|
4665
|
+
let echoRejectStreak = 0;
|
|
4214
4666
|
debugLog("enter", {
|
|
4215
4667
|
build: BUILD_TAG,
|
|
4216
4668
|
mode: cfg.mode,
|
|
@@ -4223,6 +4675,9 @@ function MicButton({
|
|
|
4223
4675
|
const hardBreak = async () => {
|
|
4224
4676
|
bus.skipAudio();
|
|
4225
4677
|
bus.unduckAudio();
|
|
4678
|
+
cancelAutoSend();
|
|
4679
|
+
submitInFlightRef.current = false;
|
|
4680
|
+
correctCycleRef.current++;
|
|
4226
4681
|
bus.setBackchannelHold(0);
|
|
4227
4682
|
if (runningRef.current && sidRef.current) {
|
|
4228
4683
|
bus.cancelTurn(sidRef.current);
|
|
@@ -4238,6 +4693,11 @@ function MicButton({
|
|
|
4238
4693
|
if (engineRef.current && !engineRef.current.holding) await engineRef.current.discardSegment();
|
|
4239
4694
|
await cancelP;
|
|
4240
4695
|
bus.setUi({ partial: "\u2026" });
|
|
4696
|
+
if (breakDotsTimerRef.current) clearTimeout(breakDotsTimerRef.current);
|
|
4697
|
+
breakDotsTimerRef.current = setTimeout(() => {
|
|
4698
|
+
breakDotsTimerRef.current = null;
|
|
4699
|
+
if (bus.ui.partial === "\u2026") bus.setUi({ partial: "" });
|
|
4700
|
+
}, 3e3);
|
|
4241
4701
|
};
|
|
4242
4702
|
breakRef.current = hardBreak;
|
|
4243
4703
|
const engine = createAsrEngine(
|
|
@@ -4262,6 +4722,7 @@ function MicButton({
|
|
|
4262
4722
|
if (!bus.ui.playing) {
|
|
4263
4723
|
isSpeechTrueCount = 0;
|
|
4264
4724
|
interruptFirstAt = 0;
|
|
4725
|
+
echoRejectStreak = 0;
|
|
4265
4726
|
bus.setUi({ isSpeech: speech, echoDelayMs: bus.echoDelayMs(), echoLevels: engineRef.current?.echoLevels() });
|
|
4266
4727
|
return;
|
|
4267
4728
|
}
|
|
@@ -4291,6 +4752,7 @@ function MicButton({
|
|
|
4291
4752
|
});
|
|
4292
4753
|
isSpeechTrueCount = 0;
|
|
4293
4754
|
interruptFirstAt = 0;
|
|
4755
|
+
if (++echoRejectStreak === 3) bus.setNotice(tk("echoRejectHint"));
|
|
4294
4756
|
return;
|
|
4295
4757
|
}
|
|
4296
4758
|
const confirmMs = interruptFirstAt > 0 ? Date.now() - interruptFirstAt : 0;
|
|
@@ -4304,6 +4766,7 @@ function MicButton({
|
|
|
4304
4766
|
});
|
|
4305
4767
|
interruptFirstAt = 0;
|
|
4306
4768
|
isSpeechTrueCount = 0;
|
|
4769
|
+
echoRejectStreak = 0;
|
|
4307
4770
|
fixtureRecorder.mark("interrupt", `confirmMs=${confirmMs}`);
|
|
4308
4771
|
resetIdle();
|
|
4309
4772
|
bus.resetTelemetry();
|
|
@@ -4344,6 +4807,9 @@ function MicButton({
|
|
|
4344
4807
|
bus.setUi({ boot: { ...bus.ui.boot, bargeInMode }, bargeInDetectFallback: !on2 });
|
|
4345
4808
|
}
|
|
4346
4809
|
},
|
|
4810
|
+
// TODO(Issue #15 UX M10,产品决策待 PM 登记):待机期(非播放期)附和词
|
|
4811
|
+
// 无护栏——matchBackchannel 只在朗读期让位路径消费,待机期用户说「嗯/对」
|
|
4812
|
+
// 会正常入段累积发送。是否加待机期短应答护栏需产品决策,此处只登记不改行为。
|
|
4347
4813
|
// 批 5 / ADR-0008 Phase 1:backchannel 命中回调——
|
|
4348
4814
|
// 立即 skipAudio 终止当前朗读 + 置 cfg.yieldMs hold 窗口,期间 TTS 帧丢(字幕同帧丢)。
|
|
4349
4815
|
// 关 backchannelYield = 不挂回调,行为等同改造前(I10 豁免由 §7.0 ADR-0008 接受)。
|
|
@@ -4352,7 +4818,9 @@ function MicButton({
|
|
|
4352
4818
|
bus.setBackchannelHold(Date.now() + (cfg.yieldMs ?? 1500));
|
|
4353
4819
|
} : void 0,
|
|
4354
4820
|
// 批 F:传 backchannelYield 给 ASR 引擎,让 asr.ts:379 守卫短路 matchBackchannel。
|
|
4355
|
-
backchannelYield: cfg.backchannelYield
|
|
4821
|
+
backchannelYield: cfg.backchannelYield,
|
|
4822
|
+
// Issue #15 批 1 / ADR-0012:打断语音抢救透传给 ASR 引擎(预录环+hardBreak 并入)。
|
|
4823
|
+
bargeInSalvage: cfg.bargeInSalvage
|
|
4356
4824
|
},
|
|
4357
4825
|
sid
|
|
4358
4826
|
);
|
|
@@ -4380,24 +4848,57 @@ function MicButton({
|
|
|
4380
4848
|
engine.onError((key) => {
|
|
4381
4849
|
bus.setUi({ error: t(key) });
|
|
4382
4850
|
});
|
|
4851
|
+
engine.onNotice((key) => {
|
|
4852
|
+
if (engineRef.current !== engine) return;
|
|
4853
|
+
if (key === "backchannelDropped") {
|
|
4854
|
+
if (lastPartialRef.current) {
|
|
4855
|
+
const composed = composeDraft(draftRef.current, lastPartialRef.current, "");
|
|
4856
|
+
lastPartialRef.current = "";
|
|
4857
|
+
try {
|
|
4858
|
+
actionsRef.current?.setDraft?.(composed);
|
|
4859
|
+
} catch {
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
bus.setUi({ partial: "" });
|
|
4863
|
+
}
|
|
4864
|
+
bus.setNotice(t(key));
|
|
4865
|
+
});
|
|
4383
4866
|
engine.onLevel((l) => {
|
|
4384
4867
|
const cur = bus.ui.levels;
|
|
4385
4868
|
const next = cur.length < WAVE_BARS ? [...cur, l] : [...cur.slice(1), l];
|
|
4386
4869
|
bus.setUi({ levels: next });
|
|
4387
4870
|
});
|
|
4388
|
-
engine.onPartial((text) =>
|
|
4871
|
+
engine.onPartial((text) => {
|
|
4872
|
+
if (engineRef.current !== engine) return;
|
|
4873
|
+
bus.setUi({ partial: text });
|
|
4874
|
+
if (!text) return;
|
|
4875
|
+
if (submitInFlightRef.current) {
|
|
4876
|
+
if (draftRef.current === "") submitInFlightRef.current = false;
|
|
4877
|
+
else return;
|
|
4878
|
+
}
|
|
4879
|
+
if (!shouldWritePartial(engineRef.current?.state ?? "")) return;
|
|
4880
|
+
cancelAutoSend();
|
|
4881
|
+
const partialActions = actionsRef.current;
|
|
4882
|
+
if (typeof partialActions?.setDraft !== "function") return;
|
|
4883
|
+
const composed = composeDraft(draftRef.current, lastPartialRef.current, text);
|
|
4884
|
+
if (!composed) return;
|
|
4885
|
+
lastPartialRef.current = text.trim();
|
|
4886
|
+
try {
|
|
4887
|
+
partialActions.setDraft(composed);
|
|
4888
|
+
} catch {
|
|
4889
|
+
}
|
|
4890
|
+
});
|
|
4389
4891
|
engine.onSegment((text, meta) => {
|
|
4390
4892
|
resetIdle();
|
|
4893
|
+
submitInFlightRef.current = false;
|
|
4391
4894
|
bus.setUi({ partial: "" });
|
|
4392
4895
|
const actions = actionsRef.current;
|
|
4393
4896
|
const trimmed = text.trim();
|
|
4394
4897
|
if (!trimmed) return;
|
|
4395
|
-
let nextDraft = trimmed;
|
|
4898
|
+
let nextDraft = composeDraft(draftRef.current, lastPartialRef.current, trimmed);
|
|
4899
|
+
lastPartialRef.current = "";
|
|
4396
4900
|
try {
|
|
4397
|
-
const curText = draftRef.current;
|
|
4398
|
-
nextDraft = curText ? `${curText} ${trimmed}` : trimmed;
|
|
4399
4901
|
if (typeof actions?.setDraft === "function") actions.setDraft(nextDraft);
|
|
4400
|
-
else if (typeof actions?.setDraft === "function") actions.setDraft(nextDraft);
|
|
4401
4902
|
} catch {
|
|
4402
4903
|
try {
|
|
4403
4904
|
actions?.setDraft?.(trimmed);
|
|
@@ -4429,14 +4930,20 @@ function MicButton({
|
|
|
4429
4930
|
}
|
|
4430
4931
|
if (bus.activeSessionId !== sid) {
|
|
4431
4932
|
engineRef.current = null;
|
|
4933
|
+
micReadyRef.current = false;
|
|
4432
4934
|
await engine.stop();
|
|
4433
4935
|
return;
|
|
4434
4936
|
}
|
|
4937
|
+
micReadyRef.current = true;
|
|
4435
4938
|
setLocalMode("on");
|
|
4436
4939
|
resetIdle();
|
|
4437
4940
|
} catch (e) {
|
|
4438
4941
|
setLocalMode("off");
|
|
4439
|
-
const msg = e instanceof DOMException ? e.name === "NotAllowedError" ? t("micDenied") :
|
|
4942
|
+
const msg = e instanceof DOMException ? e.name === "NotAllowedError" ? t("micDenied") : (
|
|
4943
|
+
// UX:NotReadableError = 麦克风被占用(其他程序/标签页)——与「不可用」
|
|
4944
|
+
// 混同时用户无从下手,分原因给可行动文案。
|
|
4945
|
+
e.name === "NotReadableError" ? t("micBusy") : t("micUnavailable")
|
|
4946
|
+
) : t("startFail").replace("{err}", String(e instanceof Error ? e.message : e));
|
|
4440
4947
|
bus.setUi({ error: msg });
|
|
4441
4948
|
const sid2 = sidRef.current;
|
|
4442
4949
|
if (sid2) void bus.exit(sid2);
|
|
@@ -4499,7 +5006,17 @@ function MicButton({
|
|
|
4499
5006
|
clearIdle();
|
|
4500
5007
|
cancelPendingSubmit();
|
|
4501
5008
|
cancelAutoSend();
|
|
5009
|
+
submitInFlightRef.current = false;
|
|
5010
|
+
correctCycleRef.current++;
|
|
5011
|
+
micReadyRef.current = false;
|
|
4502
5012
|
isSpeechTrueCount = 0;
|
|
5013
|
+
isSpeechFalseRun = 0;
|
|
5014
|
+
clearBreakTimer();
|
|
5015
|
+
breakRef.current = null;
|
|
5016
|
+
if (breakDotsTimerRef.current) {
|
|
5017
|
+
clearTimeout(breakDotsTimerRef.current);
|
|
5018
|
+
breakDotsTimerRef.current = null;
|
|
5019
|
+
}
|
|
4503
5020
|
if (autoResumeHintTimerRef.current) {
|
|
4504
5021
|
clearTimeout(autoResumeHintTimerRef.current);
|
|
4505
5022
|
autoResumeHintTimerRef.current = null;
|
|
@@ -4635,7 +5152,7 @@ function MicButton({
|
|
|
4635
5152
|
} else if (pausedForHiddenRef.current && localRef.current === "on") {
|
|
4636
5153
|
pausedForHiddenRef.current = false;
|
|
4637
5154
|
void engineRef.current?.start().catch(() => {
|
|
4638
|
-
|
|
5155
|
+
void exitModeRef.current("manual");
|
|
4639
5156
|
});
|
|
4640
5157
|
}
|
|
4641
5158
|
};
|
|
@@ -4651,7 +5168,7 @@ function MicButton({
|
|
|
4651
5168
|
const sid = sidRef.current;
|
|
4652
5169
|
if (localRef.current === "pending" || localRef.current === "on") {
|
|
4653
5170
|
if (bus.activeSessionId === sid) {
|
|
4654
|
-
setLocalMode("on");
|
|
5171
|
+
if (localRef.current === "on" || micReadyRef.current) setLocalMode("on");
|
|
4655
5172
|
} else if (localRef.current === "pending") {
|
|
4656
5173
|
setLocalMode("off");
|
|
4657
5174
|
}
|
|
@@ -4664,15 +5181,25 @@ function MicButton({
|
|
|
4664
5181
|
const liveDraft = useInput ? useInput((s) => s?.draft ?? "") : "";
|
|
4665
5182
|
const draftRef = (0, import_react3.useRef)("");
|
|
4666
5183
|
draftRef.current = liveDraft;
|
|
5184
|
+
const lastPartialRef = (0, import_react3.useRef)("");
|
|
5185
|
+
const submitInFlightRef = (0, import_react3.useRef)(false);
|
|
5186
|
+
const correctCycleRef = (0, import_react3.useRef)(0);
|
|
4667
5187
|
const livePhase = useInput ? useInput((s) => s?.phase ?? "") : "";
|
|
4668
5188
|
const phaseRef = (0, import_react3.useRef)("");
|
|
4669
5189
|
phaseRef.current = livePhase;
|
|
4670
5190
|
const [holding, setHolding] = (0, import_react3.useState)(false);
|
|
4671
|
-
const label = on ? busy ?
|
|
5191
|
+
const label = on ? busy ? (
|
|
5192
|
+
// UX:loading-model 是加载/下载模型而非识别——「识别中…」与状态不符。
|
|
5193
|
+
bus.ui.state === "loading-model" ? t("buttonLoading") : t("recognizing")
|
|
5194
|
+
) : holdMode ? holding ? t("releaseToSend") : t("holdToTalk") : bus.ui.state === "wake" ? t("sayWake").replace("{wake}", bus.ui.wakeWord || t("wakeWord")) : (
|
|
5195
|
+
// UX:纯聆听态「语音中」与状态不符(并未在说话)→「聆听中」。
|
|
5196
|
+
t("buttonListening")
|
|
5197
|
+
) : local === "pending" ? t("entering") : t("voiceBtn");
|
|
4672
5198
|
const holdPtrRef = (0, import_react3.useRef)(null);
|
|
4673
5199
|
const toggleHoldRef = (0, import_react3.useRef)(false);
|
|
4674
5200
|
const suppressClickUntilRef = (0, import_react3.useRef)(0);
|
|
4675
5201
|
const breakTimerRef = (0, import_react3.useRef)(null);
|
|
5202
|
+
const breakDotsTimerRef = (0, import_react3.useRef)(null);
|
|
4676
5203
|
const clearBreakTimer = () => {
|
|
4677
5204
|
if (breakTimerRef.current !== null) {
|
|
4678
5205
|
clearTimeout(breakTimerRef.current);
|
|
@@ -4804,71 +5331,92 @@ function MicButton({
|
|
|
4804
5331
|
setHolding(false);
|
|
4805
5332
|
engineRef.current?.endHeld(true);
|
|
4806
5333
|
};
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
if (
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
5334
|
+
const micHint = bus.activeSessionId !== sessionId ? bus.ui.error ?? bus.ui.notice ?? "" : "";
|
|
5335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
5336
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
5337
|
+
"button",
|
|
5338
|
+
{
|
|
5339
|
+
onClick: (e) => {
|
|
5340
|
+
if (Date.now() < suppressClickUntilRef.current) return;
|
|
5341
|
+
if (holdMode) {
|
|
5342
|
+
if (e.detail !== 0) return;
|
|
5343
|
+
}
|
|
5344
|
+
toggle();
|
|
5345
|
+
},
|
|
5346
|
+
onPointerDown,
|
|
5347
|
+
onPointerMove,
|
|
5348
|
+
onPointerUp,
|
|
5349
|
+
onPointerCancel,
|
|
5350
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
5351
|
+
ref: btnRef,
|
|
5352
|
+
"data-dshvm": "mic",
|
|
5353
|
+
"aria-label": on ? t("ariaActive") : t("ariaEnter"),
|
|
5354
|
+
"aria-pressed": on,
|
|
5355
|
+
title: on ? holdMode ? t("titleHold") : t("titleToggle") : t("titleEnter"),
|
|
5356
|
+
style: {
|
|
5357
|
+
border: holding ? "1px solid rgba(248, 81, 73, 0.6)" : on ? holdMode ? "1px solid rgba(88, 166, 255, 0.45)" : "1px solid rgba(63, 185, 80, 0.45)" : "1px solid rgba(139, 148, 158, 0.35)",
|
|
5358
|
+
background: holding ? "rgba(248, 81, 73, 0.2)" : on ? holdMode ? "rgba(88, 166, 255, 0.16)" : "rgba(63, 185, 80, 0.16)" : local === "pending" ? "rgba(88, 166, 255, 0.14)" : "rgba(139, 148, 158, 0.08)",
|
|
5359
|
+
cursor: "pointer",
|
|
5360
|
+
padding: "5px 10px",
|
|
5361
|
+
borderRadius: 8,
|
|
5362
|
+
display: "flex",
|
|
5363
|
+
alignItems: "center",
|
|
5364
|
+
gap: 6,
|
|
5365
|
+
fontSize: 12,
|
|
5366
|
+
fontFamily: "system-ui, sans-serif",
|
|
5367
|
+
color: holding ? "#f85149" : on ? holdMode ? "#58a6ff" : "#2ea043" : local === "pending" ? "#58a6ff" : "#8b949e",
|
|
5368
|
+
// 批 H 任务 3:toggle 模式「语音中」绿字加深(#3fb950 → #2ea043)+ fontWeight:600 双保险,
|
|
5369
|
+
// 浅色主题下与浅绿底 (rgba 63,185,80,.16) 对比度 ≥ 4.5:1(WCAG AA 文本级)。
|
|
5370
|
+
fontWeight: on && !holdMode ? 600 : void 0,
|
|
5371
|
+
transition: "background 0.15s ease, color 0.2s ease, border-color 0.15s ease",
|
|
5372
|
+
touchAction: "none",
|
|
5373
|
+
// 触摸设备上让 pointer 事件独占(滑出取消可用)
|
|
5374
|
+
userSelect: "none",
|
|
5375
|
+
WebkitUserSelect: "none",
|
|
5376
|
+
// iOS Safari 前缀,防长按选中文字
|
|
5377
|
+
WebkitTouchCallout: "none"
|
|
5378
|
+
// iOS 长按弹出「拷贝/选择」菜单
|
|
5379
|
+
},
|
|
5380
|
+
children: [
|
|
5381
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, "aria-hidden": "true", children: [
|
|
5382
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
5383
|
+
"path",
|
|
5384
|
+
{
|
|
5385
|
+
fill: "currentColor",
|
|
5386
|
+
d: "M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3Z"
|
|
5387
|
+
}
|
|
5388
|
+
),
|
|
5389
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
5390
|
+
"path",
|
|
5391
|
+
{
|
|
5392
|
+
fill: "currentColor",
|
|
5393
|
+
d: "M17.3 11a.9.9 0 0 0-1.8 0 3.5 3.5 0 0 1-7 0 .9.9 0 0 0-1.8 0 5.3 5.3 0 0 0 4.4 5.2v1.9h-1.7a.9.9 0 0 0 0 1.8h5.2a.9.9 0 0 0 0-1.8h-1.7v-1.9A5.3 5.3 0 0 0 17.3 11Z"
|
|
5394
|
+
}
|
|
5395
|
+
)
|
|
5396
|
+
] }),
|
|
5397
|
+
label
|
|
5398
|
+
]
|
|
5399
|
+
}
|
|
5400
|
+
),
|
|
5401
|
+
micHint && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
5402
|
+
"span",
|
|
5403
|
+
{
|
|
5404
|
+
"data-dshvm": "mic-hint",
|
|
5405
|
+
role: "status",
|
|
5406
|
+
"aria-live": "polite",
|
|
5407
|
+
title: micHint,
|
|
5408
|
+
style: {
|
|
5409
|
+
fontSize: 11,
|
|
5410
|
+
color: "#f85149",
|
|
5411
|
+
maxWidth: 240,
|
|
5412
|
+
overflow: "hidden",
|
|
5413
|
+
textOverflow: "ellipsis",
|
|
5414
|
+
whiteSpace: "nowrap"
|
|
5415
|
+
},
|
|
5416
|
+
children: micHint
|
|
5417
|
+
}
|
|
5418
|
+
)
|
|
5419
|
+
] });
|
|
4872
5420
|
}
|
|
4873
5421
|
function VoiceStatusBar({ bus, sessionId }) {
|
|
4874
5422
|
useLang();
|
|
@@ -4885,9 +5433,37 @@ function VoiceStatusBar({ bus, sessionId }) {
|
|
|
4885
5433
|
const id = setInterval(() => setElapsedSec((s) => s + 1), 1e3);
|
|
4886
5434
|
return () => clearInterval(id);
|
|
4887
5435
|
}, [b.active, sessionId]);
|
|
5436
|
+
const copyDiagnostics = async () => {
|
|
5437
|
+
const tel2 = b.ui.telemetry ?? {};
|
|
5438
|
+
const boot = b.ui.boot;
|
|
5439
|
+
const lines = [
|
|
5440
|
+
`dsh-voice-mode build=${BUILD_TAG}`,
|
|
5441
|
+
`state=${b.ui.state}${b.ui.error ? " error=" + b.ui.error : ""}${b.ui.sseDown ? " sse=down" : ""}`,
|
|
5442
|
+
boot ? `settings silenceMs=${boot.silenceMs} senseVoice=${boot.senseVoice} llmCorrect=${boot.llmCorrect} bargeInSalvage=${boot.bargeInSalvage} mode=${boot.mode} wakeWord=${boot.wakeWord ? "set" : "none"}` : "settings=unavailable",
|
|
5443
|
+
// telemetry 存的是各阶段绝对时刻(Date.now())——输出**相邻阶段差值**(与状态条同算法),
|
|
5444
|
+
// 不把绝对 epoch 当「ms 耗时」输出(审查 M1)。
|
|
5445
|
+
...telemetryDeltas(tel2)
|
|
5446
|
+
];
|
|
5447
|
+
const text = lines.join("\n");
|
|
5448
|
+
try {
|
|
5449
|
+
await navigator.clipboard.writeText(text);
|
|
5450
|
+
bus.setNotice(t("diagCopied"));
|
|
5451
|
+
} catch {
|
|
5452
|
+
bus.setNotice(t("diagCopyFailed"));
|
|
5453
|
+
}
|
|
5454
|
+
};
|
|
5455
|
+
const [transcribingSec, setTranscribingSec] = (0, import_react3.useState)(0);
|
|
5456
|
+
(0, import_react3.useEffect)(() => {
|
|
5457
|
+
if (b.ui.state !== "transcribing") {
|
|
5458
|
+
setTranscribingSec(0);
|
|
5459
|
+
return;
|
|
5460
|
+
}
|
|
5461
|
+
const id = setInterval(() => setTranscribingSec((s) => s + 1), 1e3);
|
|
5462
|
+
return () => clearInterval(id);
|
|
5463
|
+
}, [b.ui.state]);
|
|
4888
5464
|
const isActive = b.active === sessionId;
|
|
4889
5465
|
if (!isActive) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, {});
|
|
4890
|
-
const stateText = b.ui.state === "loading-model" ? t("loadingModel") : b.ui.state === "transcribing" ? t("recognizing") : b.ui.state === "wake" ? t("sayWake").replace("{wake}", b.ui.wakeWord || t("wakeWord")) : b.ui.state === "speech" ? b.ui.mode === "hold" ? t("holdDots") : t("listening") : b.ui.playing ? t("reading") : b.ui.turn === "agent-speaking" ? t("thinking") : b.ui.mode === "hold" ? t("barHold") : t("barListening");
|
|
5466
|
+
const stateText = b.ui.state === "loading-model" ? t("loadingModel") : b.ui.state === "transcribing" ? transcribingSec >= 2 ? t("recognizingSec").replace("{sec}", String(transcribingSec)) : t("recognizing") : b.ui.state === "wake" ? t("sayWake").replace("{wake}", b.ui.wakeWord || t("wakeWord")) : b.ui.state === "speech" ? b.ui.mode === "hold" ? t("holdDots") : t("listening") : b.ui.playing ? t("reading") : b.ui.turn === "agent-speaking" ? t("thinking") : b.ui.mode === "hold" ? t("barHold") : t("barListening");
|
|
4891
5467
|
const bars = Array.from({ length: WAVE_BARS }, (_, i) => b.ui.levels[i] ?? 0);
|
|
4892
5468
|
const botBars = Array.from({ length: WAVE_BARS }, (_, i) => b.ui.botLevels[i] ?? 0);
|
|
4893
5469
|
const telParts = [];
|
|
@@ -4904,7 +5480,7 @@ function VoiceStatusBar({ bus, sessionId }) {
|
|
|
4904
5480
|
const end = tel["first-audio-played"];
|
|
4905
5481
|
if (begin !== void 0 && end !== void 0) telParts.push(`${t("telTotal")} ${fmt(end - begin)}`);
|
|
4906
5482
|
}
|
|
4907
|
-
if (b.ui.interruptConfirmMs !== void 0) {
|
|
5483
|
+
if (telemetryEnabled && b.ui.interruptConfirmMs !== void 0) {
|
|
4908
5484
|
telParts.push(`${t("interruptConfirm")} ${fmt(b.ui.interruptConfirmMs)}`);
|
|
4909
5485
|
}
|
|
4910
5486
|
if (telemetryEnabled && b.ui.echoLevels) {
|
|
@@ -4916,6 +5492,8 @@ function VoiceStatusBar({ bus, sessionId }) {
|
|
|
4916
5492
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
4917
5493
|
"div",
|
|
4918
5494
|
{
|
|
5495
|
+
role: "status",
|
|
5496
|
+
"aria-live": "polite",
|
|
4919
5497
|
style: {
|
|
4920
5498
|
display: "flex",
|
|
4921
5499
|
flexDirection: "column",
|
|
@@ -4968,7 +5546,27 @@ function VoiceStatusBar({ bus, sessionId }) {
|
|
|
4968
5546
|
},
|
|
4969
5547
|
i
|
|
4970
5548
|
)) }),
|
|
4971
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flexGrow: 1 }, children: b.ui.error ? b.ui.error : b.ui.notice ? b.ui.notice : b.ui.idleWarn ? t("idleWarn30s") : b.ui.state === "loading-model" || b.ui.model ? b.ui.model ? `${t("loadingModel")} ${b.ui.model.file} ${b.ui.model.percent}%` : stateText : b.ui.playing || b.ui.turn === "agent-speaking" ? stateText : b.ui.state === "wake" && b.ui.partial ? `${stateText} \xB7 ${b.ui.partial}` : b.ui.partial ? b.ui.partial : b.ui.ttsNotice ? b.ui.ttsNotice : stateText }),
|
|
5549
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flexGrow: 1 }, children: b.ui.error ? b.ui.error : b.ui.sseDown ? t("sseReconnect") : b.ui.notice ? b.ui.notice : b.ui.idleWarn ? t("idleWarn30s") : b.ui.state === "loading-model" || b.ui.model ? b.ui.model ? `${t("loadingModel")} ${b.ui.model.file} ${b.ui.model.percent}%` : stateText : b.ui.playing || b.ui.turn === "agent-speaking" ? stateText : b.ui.state === "wake" && b.ui.partial ? `${stateText} \xB7 ${b.ui.partial}` : b.ui.partial ? b.ui.partial : b.ui.ttsNotice ? b.ui.ttsNotice : stateText }),
|
|
5550
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
5551
|
+
"button",
|
|
5552
|
+
{
|
|
5553
|
+
type: "button",
|
|
5554
|
+
"data-dshvm": "diag",
|
|
5555
|
+
title: t("diagCopy"),
|
|
5556
|
+
"aria-label": t("diagCopy"),
|
|
5557
|
+
onClick: () => void copyDiagnostics(),
|
|
5558
|
+
style: {
|
|
5559
|
+
flexShrink: 0,
|
|
5560
|
+
border: "none",
|
|
5561
|
+
background: "transparent",
|
|
5562
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
5563
|
+
cursor: "pointer",
|
|
5564
|
+
padding: "0 4px",
|
|
5565
|
+
fontSize: 11
|
|
5566
|
+
},
|
|
5567
|
+
children: t("diagCopy")
|
|
5568
|
+
}
|
|
5569
|
+
),
|
|
4972
5570
|
b.ui.isSpeech === true && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
4973
5571
|
"span",
|
|
4974
5572
|
{
|
|
@@ -4986,6 +5584,27 @@ function VoiceStatusBar({ bus, sessionId }) {
|
|
|
4986
5584
|
children: t("vadDetected")
|
|
4987
5585
|
}
|
|
4988
5586
|
),
|
|
5587
|
+
b.ui.ttsNotice && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
5588
|
+
"span",
|
|
5589
|
+
{
|
|
5590
|
+
title: b.ui.ttsNotice,
|
|
5591
|
+
style: {
|
|
5592
|
+
flexShrink: 0,
|
|
5593
|
+
maxWidth: 200,
|
|
5594
|
+
padding: "0 6px",
|
|
5595
|
+
borderRadius: 8,
|
|
5596
|
+
fontSize: 10,
|
|
5597
|
+
lineHeight: "16px",
|
|
5598
|
+
overflow: "hidden",
|
|
5599
|
+
textOverflow: "ellipsis",
|
|
5600
|
+
whiteSpace: "nowrap",
|
|
5601
|
+
color: "#ffa657",
|
|
5602
|
+
background: "rgba(255, 166, 87, 0.15)",
|
|
5603
|
+
border: "1px solid rgba(255, 166, 87, 0.35)"
|
|
5604
|
+
},
|
|
5605
|
+
children: b.ui.ttsNotice
|
|
5606
|
+
}
|
|
5607
|
+
),
|
|
4989
5608
|
elapsedSec > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
4990
5609
|
"span",
|
|
4991
5610
|
{
|
|
@@ -5156,7 +5775,7 @@ function VoiceOverlay({ bus }) {
|
|
|
5156
5775
|
pointerEvents: "auto"
|
|
5157
5776
|
// 仅此按钮可点
|
|
5158
5777
|
},
|
|
5159
|
-
children: t("
|
|
5778
|
+
children: t("skipReading")
|
|
5160
5779
|
}
|
|
5161
5780
|
)
|
|
5162
5781
|
]
|