dsh-gsv-tts 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/CHANGELOG_EN.md +14 -0
- package/README.md +36 -12
- package/README_EN.md +35 -11
- package/docs/images/architecture.png +0 -0
- package/docs/voices.json +66 -66
- package/lib/client.js +110 -52
- package/lib/config.d.ts +3 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +6 -1
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +104 -22
- package/lib/index.js.map +1 -1
- package/lib/migration.d.ts +1 -1
- package/lib/migration.js +2 -2
- package/lib/migration.js.map +1 -1
- package/lib/providers/deepseek.d.ts +95 -0
- package/lib/providers/deepseek.d.ts.map +1 -0
- package/lib/providers/deepseek.js +265 -0
- package/lib/providers/deepseek.js.map +1 -0
- package/lib/providers/edge.d.ts +3 -0
- package/lib/providers/edge.d.ts.map +1 -1
- package/lib/providers/edge.js +9 -1
- package/lib/providers/edge.js.map +1 -1
- package/lib/tts.service.d.ts +16 -0
- package/lib/tts.service.d.ts.map +1 -1
- package/lib/tts.service.js +129 -8
- package/lib/tts.service.js.map +1 -1
- package/lib/types.d.ts +9 -4
- package/lib/types.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -29,6 +29,11 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
|
|
30
30
|
// ─── 文案 ───
|
|
31
31
|
const NS = "gsv-tts";
|
|
32
|
+
// DeepSeek 官方音色是固定的两个:直接内置,切模式不发网络请求
|
|
33
|
+
const DEEPSEEK_VOICE_OPTIONS = [
|
|
34
|
+
{ id: "stella", name: "海星(女声)" },
|
|
35
|
+
{ id: "tide", name: "暗潮(男声)" },
|
|
36
|
+
];
|
|
32
37
|
const zh = {
|
|
33
38
|
"read": "朗读结果",
|
|
34
39
|
"reading": "朗读中…",
|
|
@@ -53,6 +58,14 @@ window.__ModuleLoader__.load({
|
|
|
53
58
|
"mode.badgeLocal": "🖥️ 本地·离线",
|
|
54
59
|
"mode.quickDesc": "微软 Edge 云端声音,免安装免配置,需要联网",
|
|
55
60
|
"mode.proDesc": "本地 GSV-TTS-Lite,离线 / 隐私 / 音色克隆",
|
|
61
|
+
"mode.official": "官方语音(DeepSeek)",
|
|
62
|
+
"mode.badgeOfficial": "🌐 官方·计费",
|
|
63
|
+
"mode.officialDesc": "DeepSeek 官方 TTS(海星/暗潮),复用已有 Key,按字符计费",
|
|
64
|
+
"field.apiKey": "DeepSeek API Key",
|
|
65
|
+
"field.apiKeyHint": "留空 = 直接复用 Harness 凭据;填写则覆盖",
|
|
66
|
+
"field.apiKeyReuse": "默认复用 Harness 已配置的 DEEPSEEK_API_KEY(模型设置里保存的那个),无需再填 Key",
|
|
67
|
+
"field.apiKeyRef": "凭据名称",
|
|
68
|
+
"field.apiKeyRefHint": "默认 DEEPSEEK_API_KEY;留空则不查 Harness 凭据",
|
|
56
69
|
"mode.healthOk": "云端通道正常",
|
|
57
70
|
"mode.healthDown": "云端通道暂不可用",
|
|
58
71
|
"mode.healthBusy": "云端体验通道拥挤,建议切换本地无限引擎",
|
|
@@ -145,6 +158,14 @@ window.__ModuleLoader__.load({
|
|
|
145
158
|
"mode.badgeLocal": "🖥️ Local·Offline",
|
|
146
159
|
"mode.quickDesc": "Microsoft Edge cloud voices, zero setup, requires network",
|
|
147
160
|
"mode.proDesc": "Local GSV-TTS-Lite: offline / private / voice cloning",
|
|
161
|
+
"mode.official": "Official (DeepSeek)",
|
|
162
|
+
"mode.badgeOfficial": "🌐 Official·Billed",
|
|
163
|
+
"mode.officialDesc": "DeepSeek official TTS (Stella/Tide), reuses your API key, billed per character",
|
|
164
|
+
"field.apiKey": "DeepSeek API Key",
|
|
165
|
+
"field.apiKeyHint": "Empty = reuse the Harness credential; filling it overrides",
|
|
166
|
+
"field.apiKeyReuse": "Reuses the DEEPSEEK_API_KEY already configured in the Harness (the one saved in model settings); no key needed here",
|
|
167
|
+
"field.apiKeyRef": "Credential name",
|
|
168
|
+
"field.apiKeyRefHint": "Defaults to DEEPSEEK_API_KEY; leave empty to skip the Harness credential service",
|
|
148
169
|
"mode.healthOk": "Cloud channel healthy",
|
|
149
170
|
"mode.healthDown": "Cloud channel temporarily unavailable",
|
|
150
171
|
"mode.healthBusy": "Cloud channel is congested; switch to the unlimited local engine",
|
|
@@ -930,7 +951,9 @@ window.__ModuleLoader__.load({
|
|
|
930
951
|
const [confirmInstall, setConfirmInstall] = react.useState(null); // { pkg }
|
|
931
952
|
const [confirmRemove, setConfirmRemove] = react.useState(null); // { id, name }
|
|
932
953
|
// ─── 4.0.0 简单模式状态(同样必须在提前 return 之前声明) ───
|
|
933
|
-
const [
|
|
954
|
+
const [cloudVoices, setCloudVoices] = react.useState(null); // VoiceInfo[] | null
|
|
955
|
+
// 云端音色缓存:edge 只拉一次;deepseek 固定列表,无需请求
|
|
956
|
+
const cloudVoicesCache = react.useRef({ edge: null });
|
|
934
957
|
const [providerHealth, setProviderHealth] = react.useState(null); // { available, rateLimited?, message? } | null
|
|
935
958
|
const [cloudBusy, setCloudBusy] = react.useState(null); // 'one' | 'all' | null
|
|
936
959
|
const valueJson = JSON.stringify(value);
|
|
@@ -938,19 +961,31 @@ window.__ModuleLoader__.load({
|
|
|
938
961
|
setDraft(structuredClone(value));
|
|
939
962
|
}, [valueJson]);
|
|
940
963
|
// provider 判定:迁移写回完成前默认按 gsv 展示(服务端已写回后快照即含 provider)
|
|
941
|
-
const provider = draft && draft.provider === 'edge'
|
|
942
|
-
// edge
|
|
964
|
+
const provider = draft && (draft.provider === 'edge' || draft.provider === 'deepseek') ? draft.provider : 'gsv';
|
|
965
|
+
// 云端模式(edge / deepseek)共用音色下拉与试听,隐藏本地引擎/预设
|
|
966
|
+
const isCloud = provider !== 'gsv';
|
|
967
|
+
// 云端音色与健康:deepseek 用内置列表(零网络),edge 列表拉一次后缓存
|
|
943
968
|
react.useEffect(() => {
|
|
944
|
-
if (draft === null ||
|
|
969
|
+
if (draft === null || !isCloud) return;
|
|
945
970
|
let alive = true;
|
|
971
|
+
if (provider === 'deepseek') {
|
|
972
|
+
setCloudVoices(DEEPSEEK_VOICE_OPTIONS.map((v) => ({ ...v })));
|
|
973
|
+
} else if (cloudVoicesCache.current.edge) {
|
|
974
|
+
setCloudVoices(cloudVoicesCache.current.edge);
|
|
975
|
+
}
|
|
946
976
|
const load = async () => {
|
|
977
|
+
if (provider === 'edge' && !cloudVoicesCache.current.edge) {
|
|
978
|
+
try {
|
|
979
|
+
const vr = await fetch("/dsh-gsv-tts/provider/voices", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ provider }) });
|
|
980
|
+
const vd = await vr.json().catch(() => ({}));
|
|
981
|
+
if (alive && vd.voices && vd.voices.length) {
|
|
982
|
+
cloudVoicesCache.current.edge = vd.voices;
|
|
983
|
+
setCloudVoices(vd.voices);
|
|
984
|
+
}
|
|
985
|
+
} catch { /* 忽略 */ }
|
|
986
|
+
}
|
|
947
987
|
try {
|
|
948
|
-
const
|
|
949
|
-
const vd = await vr.json().catch(() => ({}));
|
|
950
|
-
if (alive && vd.voices) setEdgeVoices(vd.voices);
|
|
951
|
-
} catch { /* 忽略 */ }
|
|
952
|
-
try {
|
|
953
|
-
const hr = await fetch("/dsh-gsv-tts/provider/health", { method: "POST", headers: { "Content-Type": "application/json" }, body: "{}" });
|
|
988
|
+
const hr = await fetch("/dsh-gsv-tts/provider/health", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ provider }) });
|
|
954
989
|
const hd = await hr.json().catch(() => ({}));
|
|
955
990
|
if (alive) setProviderHealth({ available: !!hd.available, rateLimited: !!hd.rateLimited, message: hd.message || null });
|
|
956
991
|
} catch (e) {
|
|
@@ -958,31 +993,45 @@ window.__ModuleLoader__.load({
|
|
|
958
993
|
}
|
|
959
994
|
};
|
|
960
995
|
load();
|
|
961
|
-
const timer = setInterval(load, 60000); //
|
|
996
|
+
const timer = setInterval(load, 60000); // 每分钟轻量刷新一次(服务端退避缓存)
|
|
962
997
|
return () => { alive = false; clearInterval(timer); };
|
|
963
|
-
}, [provider, draft === null ? 0 : 1]);
|
|
964
|
-
//
|
|
965
|
-
const switchProvider =
|
|
998
|
+
}, [provider, draft === null ? 0 : 1, provider === 'deepseek' ? String((draft && draft.deepseekApiKey) || '') : '']);
|
|
999
|
+
// 模式切换:先本地切(界面立即响应),持久化与列表加载放后台
|
|
1000
|
+
const switchProvider = (kind) => {
|
|
966
1001
|
if (kind === provider) return;
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1002
|
+
const next = { ...draft, provider: kind };
|
|
1003
|
+
if (kind === 'gsv') {
|
|
1004
|
+
const local = draft.voices || [];
|
|
1005
|
+
next.defaultVoice = local.length ? local[0].name : '';
|
|
1006
|
+
} else if (kind === 'deepseek') {
|
|
1007
|
+
next.defaultVoice = 'stella';
|
|
1008
|
+
setCloudVoices(DEEPSEEK_VOICE_OPTIONS.map((v) => ({ ...v })));
|
|
1009
|
+
} else {
|
|
1010
|
+
const cached = cloudVoicesCache.current.edge;
|
|
1011
|
+
if (cached && cached.length) {
|
|
1012
|
+
setCloudVoices(cached);
|
|
1013
|
+
next.defaultVoice = cached[0].id;
|
|
976
1014
|
}
|
|
977
|
-
}
|
|
978
|
-
setDraft(next);
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1015
|
+
}
|
|
1016
|
+
setDraft(next); // 立即生效,不等网络
|
|
1017
|
+
scope.set('provider', kind).catch((e) => setError(String((e && e.message) || e)));
|
|
1018
|
+
// 同一份写入里落定默认音色:否则配置快照刷新会把草稿里的 defaultVoice 冲回旧值(下拉闪一下)
|
|
1019
|
+
if (next.defaultVoice) scope.set('defaultVoice', next.defaultVoice).catch(() => {});
|
|
1020
|
+
if (kind === 'gsv' && next.engineMode === 'always') {
|
|
1021
|
+
fetch("/dsh-gsv-tts/engine/start", { method: "POST" }).catch(() => {});
|
|
1022
|
+
}
|
|
1023
|
+
if (kind === 'edge' && !cloudVoicesCache.current.edge) {
|
|
1024
|
+
// 后台拉 Edge 音色:到达后再修正默认音色(不阻塞切换)
|
|
1025
|
+
fetch("/dsh-gsv-tts/provider/voices", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ provider: "edge" }) })
|
|
1026
|
+
.then((r) => r.json())
|
|
1027
|
+
.then((vd) => {
|
|
1028
|
+
if (!vd.voices || !vd.voices.length) return;
|
|
1029
|
+
cloudVoicesCache.current.edge = vd.voices;
|
|
1030
|
+
setCloudVoices(vd.voices);
|
|
1031
|
+
setDraft((d) => (d && d.provider === "edge" && !/^[a-z]{2,3}-/.test(String(d.defaultVoice || "")) ? { ...d, defaultVoice: vd.voices[0].id } : d));
|
|
1032
|
+
})
|
|
1033
|
+
.catch(() => {});
|
|
1034
|
+
}
|
|
986
1035
|
};
|
|
987
1036
|
// ─── 云端音色试听:单条(当前选中)+ 全部(串行合成→排队播放,防限流) ───
|
|
988
1037
|
const cloudPreview = async (voiceId) => {
|
|
@@ -995,7 +1044,7 @@ window.__ModuleLoader__.load({
|
|
|
995
1044
|
const resp = await fetch("/dsh-gsv-tts/provider/preview", {
|
|
996
1045
|
method: "POST",
|
|
997
1046
|
headers: { "Content-Type": "application/json" },
|
|
998
|
-
body: JSON.stringify({ voice: voiceId })
|
|
1047
|
+
body: JSON.stringify({ voice: voiceId, provider })
|
|
999
1048
|
});
|
|
1000
1049
|
const data = await resp.json().catch(() => ({}));
|
|
1001
1050
|
if (!resp.ok || !data.audioUrl) throw new Error(data.message || "no audio");
|
|
@@ -1008,7 +1057,7 @@ window.__ModuleLoader__.load({
|
|
|
1008
1057
|
};
|
|
1009
1058
|
const cloudPreviewAll = async () => {
|
|
1010
1059
|
if (player.isActive("cloud:all")) { player.stop(); return; }
|
|
1011
|
-
const voices =
|
|
1060
|
+
const voices = cloudVoices || [];
|
|
1012
1061
|
if (voices.length === 0) return;
|
|
1013
1062
|
setCloudBusy("all");
|
|
1014
1063
|
setPreviewError(null);
|
|
@@ -1020,7 +1069,7 @@ window.__ModuleLoader__.load({
|
|
|
1020
1069
|
const resp = await fetch("/dsh-gsv-tts/provider/preview", {
|
|
1021
1070
|
method: "POST",
|
|
1022
1071
|
headers: { "Content-Type": "application/json" },
|
|
1023
|
-
body: JSON.stringify({ voice: v.id })
|
|
1072
|
+
body: JSON.stringify({ voice: v.id, provider })
|
|
1024
1073
|
});
|
|
1025
1074
|
const data = await resp.json().catch(() => ({}));
|
|
1026
1075
|
if (!resp.ok || !data.audioUrl) { errs.push(data.message || ("HTTP " + resp.status)); continue; }
|
|
@@ -1047,8 +1096,8 @@ window.__ModuleLoader__.load({
|
|
|
1047
1096
|
if (snapshot && snapshot.status === "loading") {
|
|
1048
1097
|
return jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 12, marginTop: 6 }, children: t("cardLoading") });
|
|
1049
1098
|
}
|
|
1050
|
-
const voiceOptions =
|
|
1051
|
-
? (
|
|
1099
|
+
const voiceOptions = isCloud
|
|
1100
|
+
? (cloudVoices || []).map((v) => ({ id: v.id, label: provider === "edge" ? v.name + " (" + v.id + ")" : v.name }))
|
|
1052
1101
|
: (draft.voices || []).map((v) => ({ id: v.name, label: v.name }));
|
|
1053
1102
|
// 当前生效音色:显式选择优先,空则取第一个(与朗读实际行为一致)
|
|
1054
1103
|
const effectiveVoice = draft.defaultVoice || (voiceOptions.length ? voiceOptions[0].id : "");
|
|
@@ -1203,8 +1252,8 @@ window.__ModuleLoader__.load({
|
|
|
1203
1252
|
try {
|
|
1204
1253
|
const base = (snapshot && snapshot.base) || {};
|
|
1205
1254
|
let rejected = 0;
|
|
1206
|
-
for (const field of ["apiUrl", "defaultVoice", "autoPlay", "interruptOnNew", "provider", "timeout", "installDir", "voices"]) {
|
|
1207
|
-
const next = draft[field];
|
|
1255
|
+
for (const field of ["apiUrl", "defaultVoice", "autoPlay", "interruptOnNew", "provider", "deepseekApiKey", "deepseekApiKeyEnv", "timeout", "installDir", "voices"]) {
|
|
1256
|
+
const next = field === "deepseekApiKey" ? (draft.deepseekApiKey ?? "") : field === "deepseekApiKeyEnv" ? (draft.deepseekApiKeyEnv ?? "") : draft[field];
|
|
1208
1257
|
const baseVal = base[field];
|
|
1209
1258
|
// DSH 0.2:set/unset 返回宿主是否接受写入(false = 被拒绝),需要显式提示
|
|
1210
1259
|
const accepted = baseVal !== void 0 && JSON.stringify(next) === JSON.stringify(baseVal)
|
|
@@ -1232,26 +1281,35 @@ window.__ModuleLoader__.load({
|
|
|
1232
1281
|
jsx.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, marginTop: 10, flexWrap: "wrap" }, children: [
|
|
1233
1282
|
jsx.jsx("span", { style: { fontWeight: 600, fontSize: 13, color: "var(--dsw-alias-label-primary)" }, children: t("mode.title") + ":" }),
|
|
1234
1283
|
jsx.jsx("button", { type: "button", disabled: !writable, onClick: () => switchProvider("edge"), style: { cursor: "pointer", border: "1px solid " + (provider === "edge" ? "var(--dsw-alias-brand,#6e56cf)" : "var(--dsw-alias-border-l2)"), background: provider === "edge" ? "var(--dsw-alias-interactive-bg-hover)" : "0 0", color: "var(--dsw-alias-label-secondary)", borderRadius: 14, padding: "4px 12px", fontSize: 12 }, children: t("mode.quick") }),
|
|
1284
|
+
jsx.jsx("button", { type: "button", disabled: !writable, onClick: () => switchProvider("deepseek"), style: { cursor: "pointer", border: "1px solid " + (provider === "deepseek" ? "var(--dsw-alias-brand,#6e56cf)" : "var(--dsw-alias-border-l2)"), background: provider === "deepseek" ? "var(--dsw-alias-interactive-bg-hover)" : "0 0", color: "var(--dsw-alias-label-secondary)", borderRadius: 14, padding: "4px 12px", fontSize: 12 }, children: t("mode.official") }),
|
|
1235
1285
|
jsx.jsx("button", { type: "button", disabled: !writable, onClick: () => switchProvider("gsv"), style: { cursor: "pointer", border: "1px solid " + (provider === "gsv" ? "var(--dsw-alias-brand,#6e56cf)" : "var(--dsw-alias-border-l2)"), background: provider === "gsv" ? "var(--dsw-alias-interactive-bg-hover)" : "0 0", color: "var(--dsw-alias-label-secondary)", borderRadius: 14, padding: "4px 12px", fontSize: 12 }, children: t("mode.pro") }),
|
|
1236
|
-
jsx.jsx("span", { style: { fontSize: 12, fontWeight: 600, color: provider === "
|
|
1286
|
+
jsx.jsx("span", { style: { fontSize: 12, fontWeight: 600, color: provider === "gsv" ? "var(--dsw-alias-success, #30a46c)" : "var(--dsw-alias-label-tertiary)" }, children: provider === "gsv" ? t("mode.badgeLocal") : (provider === "deepseek" ? t("mode.badgeOfficial") : t("mode.badgeCloud")) })
|
|
1287
|
+
] }),
|
|
1288
|
+
jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 11, marginTop: 4 }, children: provider === "deepseek" ? t("mode.officialDesc") : (provider === "edge" ? t("mode.quickDesc") : t("mode.proDesc")) }),
|
|
1289
|
+
isCloud && providerHealth !== null && jsx.jsx("div", { style: { fontSize: 12, marginTop: 4, color: providerHealth.available ? "var(--dsw-alias-success, #30a46c)" : "var(--dsw-alias-danger, #e5484d)" }, children: providerHealth.available ? t("mode.healthOk") : (providerHealth.rateLimited ? t("mode.healthBusy") : (providerHealth.message || t("mode.healthDown"))) }),
|
|
1290
|
+
isCloud && providerHealth !== null && !providerHealth.available && jsx.jsx("button", { type: "button", disabled: !writable, onClick: () => switchProvider("gsv"), style: linkBtn, children: t("mode.switchPro") }),
|
|
1291
|
+
provider === "deepseek" && jsx.jsx(react.Fragment, { children: [
|
|
1292
|
+
jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 11, marginTop: 6 }, children: t("field.apiKeyReuse") }),
|
|
1293
|
+
jsx.jsx("label", { style: labelStyle, children: t("field.apiKey") }),
|
|
1294
|
+
jsx.jsx("input", { style: inputStyle, disabled: !writable, type: "password", value: draft.deepseekApiKey ?? "", placeholder: t("field.apiKeyHint"), onChange: (e) => patchField("deepseekApiKey", e.target.value) }),
|
|
1295
|
+
jsx.jsx("label", { style: labelStyle, children: t("field.apiKeyRef") }),
|
|
1296
|
+
jsx.jsx("input", { style: inputStyle, disabled: !writable, value: draft.deepseekApiKeyEnv ?? "", placeholder: "DEEPSEEK_API_KEY", onChange: (e) => patchField("deepseekApiKeyEnv", e.target.value) }),
|
|
1297
|
+
jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 11, marginTop: 4 }, children: t("field.apiKeyRefHint") })
|
|
1237
1298
|
] }),
|
|
1238
|
-
jsx.jsx("
|
|
1239
|
-
provider === "edge" && providerHealth !== null && jsx.jsx("div", { style: { fontSize: 12, marginTop: 4, color: providerHealth.available ? "var(--dsw-alias-success, #30a46c)" : "var(--dsw-alias-danger, #e5484d)" }, children: providerHealth.available ? t("mode.healthOk") : (providerHealth.rateLimited ? t("mode.healthBusy") : t("mode.healthDown")) }),
|
|
1240
|
-
provider === "edge" && providerHealth !== null && !providerHealth.available && jsx.jsx("button", { type: "button", disabled: !writable, onClick: () => switchProvider("gsv"), style: linkBtn, children: t("mode.switchPro") }),
|
|
1241
|
-
jsx.jsx("label", { style: labelStyle, children: provider === "edge" ? t("field.cloudVoice") : t("field.defaultVoice") }),
|
|
1299
|
+
jsx.jsx("label", { style: labelStyle, children: isCloud ? t("field.cloudVoice") : t("field.defaultVoice") }),
|
|
1242
1300
|
voiceOptions.length > 0
|
|
1243
1301
|
? jsx.jsx("select", { style: inputStyle, disabled: !writable, value: effectiveVoice, onChange: (e) => { const v = e.target.value; patchField("defaultVoice", v); try { scope.set("defaultVoice", v); } catch { /* 只读时忽略,保存按钮兜底 */ } }, children: [
|
|
1244
1302
|
...voiceOptions.map((o) => jsx.jsx("option", { key: o.id, value: o.id, children: o.label }))
|
|
1245
1303
|
] })
|
|
1246
1304
|
: jsx.jsx("input", { style: inputStyle, disabled: !writable, value: draft.defaultVoice ?? "", placeholder: t("field.defaultVoiceHint"), onChange: (e) => patchField("defaultVoice", e.target.value) }),
|
|
1247
1305
|
jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 11, marginTop: 4 }, children: t("currentVoice") + ":" + (currentLabel || t("voice.default")) }),
|
|
1248
|
-
|
|
1306
|
+
isCloud && jsx.jsx("div", { style: { display: "flex", gap: 12, alignItems: "center", marginTop: 4, flexWrap: "wrap" }, children: [
|
|
1249
1307
|
jsx.jsx("button", { type: "button", disabled: !effectiveVoice || cloudBusy === "one", onClick: () => cloudPreview(effectiveVoice), style: linkBtn, children: player.isActive("cloud:" + effectiveVoice) ? t("stop") : t("voice.preview") }),
|
|
1250
1308
|
jsx.jsx("button", { type: "button", disabled: cloudBusy === "all", onClick: cloudPreviewAll, style: linkBtn, children: player.isActive("cloud:all") ? t("stop") : t("voice.previewAllSeq") })
|
|
1251
1309
|
] }),
|
|
1252
|
-
|
|
1310
|
+
isCloud && previewError !== null && jsx.jsx("div", { style: { color: "var(--dsw-alias-danger, #e5484d)", fontSize: 12, marginTop: 6 }, children: previewError }),
|
|
1253
1311
|
// ─── 仅本地专业(GSV)模式的字段 ───
|
|
1254
|
-
|
|
1312
|
+
!isCloud && jsx.jsx(react.Fragment, { children: [
|
|
1255
1313
|
jsx.jsx("label", { style: labelStyle, children: t("field.apiUrl") }),
|
|
1256
1314
|
jsx.jsx("input", { style: inputStyle, disabled: !writable, value: draft.apiUrl ?? "", placeholder: t("field.apiUrlHint"), onChange: (e) => patchField("apiUrl", e.target.value) }),
|
|
1257
1315
|
jsx.jsx("label", { style: labelStyle, children: t("field.timeout") }),
|
|
@@ -1269,7 +1327,7 @@ window.__ModuleLoader__.load({
|
|
|
1269
1327
|
] }) }),
|
|
1270
1328
|
jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 11, marginTop: 2 }, children: t("field.interruptOnNewHint") }),
|
|
1271
1329
|
// ─── 仅本地专业(GSV)模式的音色预设 + 市场 ───
|
|
1272
|
-
|
|
1330
|
+
!isCloud && jsx.jsx(react.Fragment, { children: [
|
|
1273
1331
|
jsx.jsx("label", { style: labelStyle, children: t("field.voices") }),
|
|
1274
1332
|
(draft.voices || []).map((v, i) => {
|
|
1275
1333
|
const isReg = v.source === "registry"; // 注册表音色只读托管
|
|
@@ -1356,14 +1414,14 @@ window.__ModuleLoader__.load({
|
|
|
1356
1414
|
function EngineSection({ scope, t }) {
|
|
1357
1415
|
const [status, setStatus] = react.useState({ loading: true, running: false, busy: false, message: null, phase: "idle" });
|
|
1358
1416
|
const [modeError, setModeError] = react.useState(null);
|
|
1359
|
-
// 当前 TTS
|
|
1417
|
+
// 当前 TTS 模式(云端模式隐藏本地引擎开关,避免重叠)
|
|
1360
1418
|
const [snap, setSnap] = react.useState(() => {
|
|
1361
1419
|
try { return scope.getSnapshot(); } catch { return null; }
|
|
1362
1420
|
});
|
|
1363
1421
|
react.useEffect(() => {
|
|
1364
1422
|
try { return scope.subscribe(() => setSnap(scope.getSnapshot())); } catch { return () => {}; }
|
|
1365
1423
|
}, [scope]);
|
|
1366
|
-
const sectionProvider = snap && snap.value && snap.value.provider === "edge"
|
|
1424
|
+
const sectionProvider = snap && snap.value && (snap.value.provider === "edge" || snap.value.provider === "deepseek") ? snap.value.provider : "gsv";
|
|
1367
1425
|
const refresh = react.useCallback(async () => {
|
|
1368
1426
|
try {
|
|
1369
1427
|
const resp = await fetch("/dsh-gsv-tts/engine/status");
|
|
@@ -1444,7 +1502,7 @@ window.__ModuleLoader__.load({
|
|
|
1444
1502
|
});
|
|
1445
1503
|
const statusText = status.phase === "on" ? t("engineStarting") : status.phase === "off" ? t("engineStopping") : status.running ? t("engineRunning") : t("engineStopped");
|
|
1446
1504
|
return jsx.jsx(GsvErrorBoundary, { children: jsx.jsxs("div", { children: [
|
|
1447
|
-
sectionProvider
|
|
1505
|
+
sectionProvider === "gsv" && jsx.jsx(react.Fragment, { children: [
|
|
1448
1506
|
jsx.jsx("div", { style: { fontWeight: 600, fontSize: 14, color: "var(--dsw-alias-label-primary)" }, children: t("engineTitle") }),
|
|
1449
1507
|
jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 12, marginTop: 2 }, children: t("engineDesc") }),
|
|
1450
1508
|
jsx.jsx("div", { style: { color: "var(--dsw-alias-label-secondary)", fontSize: 12, marginTop: 12 }, children: t("engineMode.title") }),
|
|
@@ -1462,7 +1520,7 @@ window.__ModuleLoader__.load({
|
|
|
1462
1520
|
] }),
|
|
1463
1521
|
status.message !== null && jsx.jsx("div", { style: { color: "var(--dsw-alias-danger, #e5484d)", fontSize: 12, marginTop: 6 }, children: status.message })
|
|
1464
1522
|
] }),
|
|
1465
|
-
sectionProvider
|
|
1523
|
+
sectionProvider !== "gsv" && jsx.jsx("div", { style: { color: "var(--dsw-alias-label-tertiary)", fontSize: 12, marginTop: 2 }, children: t("engineNotNeeded") }),
|
|
1466
1524
|
jsx.jsx("div", { style: { borderTop: "1px solid var(--dsw-alias-border-l2)", marginTop: 16, paddingTop: 8 }, children: jsx.jsx(TtsSettingsCard, { scope, t }) }),
|
|
1467
1525
|
jsx.jsx("div", { style: { borderTop: "1px solid var(--dsw-alias-border-l2)", marginTop: 16, paddingTop: 8 }, children: jsx.jsx(HelpBlock, { t }) })
|
|
1468
1526
|
] }) });
|
package/lib/config.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Config, ProviderKind, VoicePreset } from './types.js';
|
|
|
3
3
|
export declare const DEFAULT_API_URL = "http://localhost:9880";
|
|
4
4
|
export declare const DEFAULT_INSTALL_DIR = "./GSV-TTS-Lite";
|
|
5
5
|
export declare const DEFAULT_VOICE_REGISTRY_URL = "https://taoruiliu19.github.io/gsv-market/voices.json";
|
|
6
|
+
/** 默认凭据引用名:与 Harness 的 DeepSeek 模型鉴权同名,因此可直接复用已保存的 Key。 */
|
|
7
|
+
export declare const DEFAULT_DEEPSEEK_KEY_REF = "DEEPSEEK_API_KEY";
|
|
6
8
|
export declare const SCHEMA_VERSION = 1;
|
|
7
9
|
/**
|
|
8
10
|
* DSH 0.2+ 的 `Schema.volatile()` 字段在插件 `apply(config)` 中不是普通值,
|
|
@@ -20,6 +22,7 @@ export declare function readConfigValue<T>(value: unknown, fallback: T): T;
|
|
|
20
22
|
* 未显式选择 provider 时的判定:
|
|
21
23
|
* - 已配置音色预设 → gsv(老用户沿用本地专业模式,声音不变)
|
|
22
24
|
* - 全新安装(无音色)→ edge(云端快速体验,装上即听)
|
|
25
|
+
* 显式选择(含 deepseek)一律尊重,避免把用户切回别的引擎。
|
|
23
26
|
*/
|
|
24
27
|
export declare function resolveProviderKind(stored: unknown, voices: readonly VoicePreset[]): ProviderKind;
|
|
25
28
|
/** 读取显式持久化的 provider(未设置时为 undefined),用于迁移守卫判断是否需要写回。 */
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,eAAe,0BAA0B,CAAC;AACvD,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,0BAA0B,yDAAyD,CAAC;AACjG,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,GAAG,IAAI,CAAC,CAAC;CACV;AAED,mCAAmC;AACnC,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,OAAO,CAAC,CAMvE;AAED,iCAAiC;AACjC,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAMjE;AAED
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,eAAe,0BAA0B,CAAC;AACvD,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,0BAA0B,yDAAyD,CAAC;AACjG,2DAA2D;AAC3D,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAC3D,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,GAAG,IAAI,CAAC,CAAC;CACV;AAED,mCAAmC;AACnC,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,OAAO,CAAC,CAMvE;AAED,iCAAiC;AACjC,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAMjE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,YAAY,CAGjG;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,GAAG,KAAK,CAInF;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAsBnD"}
|
package/lib/config.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export const DEFAULT_API_URL = 'http://localhost:9880';
|
|
3
3
|
export const DEFAULT_INSTALL_DIR = './GSV-TTS-Lite';
|
|
4
4
|
export const DEFAULT_VOICE_REGISTRY_URL = 'https://taoruiliu19.github.io/gsv-market/voices.json';
|
|
5
|
+
/** 默认凭据引用名:与 Harness 的 DeepSeek 模型鉴权同名,因此可直接复用已保存的 Key。 */
|
|
6
|
+
export const DEFAULT_DEEPSEEK_KEY_REF = 'DEEPSEEK_API_KEY';
|
|
5
7
|
export const SCHEMA_VERSION = 1;
|
|
6
8
|
/** 判断一个配置值是否是宿主下发的 volatile 引用。 */
|
|
7
9
|
export function isConfigRef(value) {
|
|
@@ -21,9 +23,10 @@ export function readConfigValue(value, fallback) {
|
|
|
21
23
|
* 未显式选择 provider 时的判定:
|
|
22
24
|
* - 已配置音色预设 → gsv(老用户沿用本地专业模式,声音不变)
|
|
23
25
|
* - 全新安装(无音色)→ edge(云端快速体验,装上即听)
|
|
26
|
+
* 显式选择(含 deepseek)一律尊重,避免把用户切回别的引擎。
|
|
24
27
|
*/
|
|
25
28
|
export function resolveProviderKind(stored, voices) {
|
|
26
|
-
if (stored === 'edge' || stored === '
|
|
29
|
+
if (stored === 'gsv' || stored === 'edge' || stored === 'deepseek')
|
|
27
30
|
return stored;
|
|
28
31
|
return voices.length > 0 ? 'gsv' : 'edge';
|
|
29
32
|
}
|
|
@@ -60,6 +63,8 @@ export function snapshotConfig(raw) {
|
|
|
60
63
|
voiceRegistryUrl: readConfigValue(source.voiceRegistryUrl, DEFAULT_VOICE_REGISTRY_URL),
|
|
61
64
|
schemaVersion: readConfigValue(source.schemaVersion, SCHEMA_VERSION),
|
|
62
65
|
provider: resolveProviderKind(readConfigValue(source.provider, undefined), list),
|
|
66
|
+
deepseekApiKey: String(readConfigValue(source.deepseekApiKey, '') ?? ''),
|
|
67
|
+
deepseekApiKeyEnv: String(readConfigValue(source.deepseekApiKeyEnv, DEFAULT_DEEPSEEK_KEY_REF) ?? ''),
|
|
63
68
|
quotaDaily: readConfigValue(source.quotaDaily, null),
|
|
64
69
|
};
|
|
65
70
|
}
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AACpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,sDAAsD,CAAC;AACjG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAWhC,mCAAmC;AACnC,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAA2B,CAAC,GAAG,KAAK,UAAU,CACvD,CAAC;AACJ,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAAI,KAAc,EAAE,QAAW;IAC5D,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QAC5B,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAE,OAAa,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAE,KAAW,CAAC;AACvD,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AACpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,sDAAsD,CAAC;AACjG,2DAA2D;AAC3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAWhC,mCAAmC;AACnC,MAAM,UAA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M,CAAC,eAAe,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;QACxE,iBAAiB,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,iBAAiB,EAAE,wBAAwB,CAAC,IAAI,EAAE,CAAC;QACpG,UAAU,EAAE,eAAe,CAAgB,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC;KACpE,CAAC;AACJ,CAAC"}
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,IAAI,gBAAgB,CAAC;AAClC,eAAO,MAAM,MAAM,UAAqC,CAAC;AAiBzD,eAAO,MAAM,MAAM,EAAE,GAsBnB,CAAC;AAEH,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QA8mC1C"}
|