dsh-folia 4.26.0-pre.75 → 4.26.0-pre.76
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/lib/tts/voice-center.js +24 -2
- package/package.json +1 -1
package/lib/tts/voice-center.js
CHANGED
|
@@ -126,7 +126,7 @@ function normalizeConfig(raw) {
|
|
|
126
126
|
const volc = src.volcengine && typeof src.volcengine === 'object' ? src.volcengine : {};
|
|
127
127
|
return {
|
|
128
128
|
version: 2,
|
|
129
|
-
preferred: String(src.preferred || '').slice(0, 160),
|
|
129
|
+
preferred: normalizeVoiceId(String(src.preferred || '')).slice(0, 160),
|
|
130
130
|
packDefault: String(src.packDefault || DEFAULT_CONFIG.packDefault).slice(0, 80),
|
|
131
131
|
volcengine: {
|
|
132
132
|
cluster: String(volc.cluster || VOLC_DEFAULT_CLUSTER).slice(0, 80),
|
|
@@ -283,7 +283,7 @@ export function markVolcTest(ok, error, info = {}) {
|
|
|
283
283
|
|
|
284
284
|
export function setPreferredVoice(voiceId) {
|
|
285
285
|
const current = readVoiceCenter();
|
|
286
|
-
const next = String(voiceId || '').trim().slice(0, 160);
|
|
286
|
+
const next = normalizeVoiceId(String(voiceId || '')).trim().slice(0, 160);
|
|
287
287
|
writeVoiceCenter({ ...current, preferred: next });
|
|
288
288
|
return next;
|
|
289
289
|
}
|
|
@@ -294,12 +294,34 @@ export function setDefaultPack(packId) {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/** 音色 id 统一 engine:id;旧数据(裸 Edge 名 / SAPI 名)补齐前缀。 */
|
|
297
|
+
|
|
298
|
+
/** 旧数据兼容:Edge「短标签」(Xiaoxiao / YunJhe…)→ 完整 id。 */
|
|
299
|
+
const EDGE_LABEL_TO_ID = Object.freeze({
|
|
300
|
+
xiaoxiao: 'zh-CN-XiaoxiaoNeural',
|
|
301
|
+
xiaoyi: 'zh-CN-XiaoyiNeural',
|
|
302
|
+
yunjian: 'zh-CN-YunjianNeural',
|
|
303
|
+
yunxi: 'zh-CN-YunxiNeural',
|
|
304
|
+
yunxia: 'zh-CN-YunxiaNeural',
|
|
305
|
+
yunyang: 'zh-CN-YunyangNeural',
|
|
306
|
+
hiugaai: 'zh-HK-HiuGaaiNeural',
|
|
307
|
+
hiumaan: 'zh-HK-HiuMaanNeural',
|
|
308
|
+
wanlung: 'zh-HK-WanLungNeural',
|
|
309
|
+
xiaobei: 'zh-CN-liaoning-XiaobeiNeural',
|
|
310
|
+
hsiaochen: 'zh-TW-HsiaoChenNeural',
|
|
311
|
+
yunjhe: 'zh-TW-YunJheNeural',
|
|
312
|
+
hsiaoyu: 'zh-TW-HsiaoYuNeural',
|
|
313
|
+
xiaoni: 'zh-CN-shaanxi-XiaoniNeural',
|
|
314
|
+
});
|
|
315
|
+
|
|
297
316
|
export function normalizeVoiceId(raw) {
|
|
298
317
|
const text = String(raw || '').trim();
|
|
299
318
|
if (!text) return '';
|
|
300
319
|
if (/^[a-z0-9-]+:/i.test(text)) return text;
|
|
301
320
|
if (/^[a-z]{2}-[A-Z]{2}-[A-Za-z0-9]+Neural$/.test(text)) return 'edge:' + text;
|
|
302
321
|
if (/^Microsoft\s.+\sDesktop$/i.test(text)) return 'sapi:' + text;
|
|
322
|
+
// 旧版把 Edge 标签(如 "YunJhe")当默认值存下来:归一到完整 id。
|
|
323
|
+
const bare = text.replace(/[((].*?[))]/g, '').trim().toLowerCase();
|
|
324
|
+
if (EDGE_LABEL_TO_ID[bare]) return 'edge:' + EDGE_LABEL_TO_ID[bare];
|
|
303
325
|
return 'piper:' + text;
|
|
304
326
|
}
|
|
305
327
|
|
package/package.json
CHANGED