调整1.0鉴权音色方式

This commit is contained in:
RT15548
2026-01-20 10:36:35 +08:00
committed by GitHub
parent dc507d7d6d
commit d1a4aca025
3 changed files with 93 additions and 73 deletions

View File

@@ -1408,13 +1408,20 @@ select.input { cursor: pointer; }
<label class="form-label">音色 ID</label>
<input type="text" id="newVoiceId" class="input" placeholder="如 S_xxx">
</div>
<div class="form-group">
<label class="form-label">名称</label>
<input type="text" id="newVoiceName" class="input" placeholder="显示名称">
</div>
<button class="btn btn-primary" id="addMySpeakerBtn" style="margin-top: 18px;"><i class="fa-solid fa-plus"></i></button>
</div>
</div>
<div class="form-group">
<label class="form-label">名称</label>
<input type="text" id="newVoiceName" class="input" placeholder="显示名称">
</div>
<div class="form-group">
<label class="form-label">复刻版本</label>
<select id="newVoiceResourceId" class="input">
<option value="seed-icl-2.0">复刻 2.0</option>
<option value="seed-icl-1.0">复刻 1.0</option>
</select>
</div>
<button class="btn btn-primary" id="addMySpeakerBtn" style="margin-top: 18px;"><i class="fa-solid fa-plus"></i></button>
</div>
</div>
</div>
</div>
@@ -2149,14 +2156,15 @@ function renderAuthVoiceList() {
// 数据处理
// ═══════════════════════════════════════════════════════════════════════════
function normalizeMySpeakers(list) {
if (!Array.isArray(list)) return [];
return list.map(item => ({
name: String(item?.name || '').trim(),
value: String(item?.value || '').trim(),
source: item?.source || getVoiceSource(item?.value || ''),
})).filter(item => item.value);
}
function normalizeMySpeakers(list) {
if (!Array.isArray(list)) return [];
return list.map(item => ({
name: String(item?.name || '').trim(),
value: String(item?.value || '').trim(),
source: item?.source || getVoiceSource(item?.value || ''),
resourceId: item?.resourceId || null,
})).filter(item => item.value);
}
function applyCacheStats(stats = {}) {
$('cacheCount').textContent = stats.count ?? 0;
@@ -2265,13 +2273,16 @@ function doTestVoice(speaker, source, textElId, statusElId) {
setTestStatus(statusElId, 'playing', '正在合成...');
post('xb-tts:test-speak', {
const speakerItem = mySpeakers.find(s => s.value === speaker);
const resolvedResourceId = speakerItem?.resourceId;
post('xb-tts:test-speak', {
text,
speaker,
source,
resourceId: source === 'auth' ? inferResourceIdBySpeaker(speaker) : '',
});
}
resourceId: source === 'auth' ? (resolvedResourceId || inferResourceIdBySpeaker(speaker)) : '',
});
}
// ═══════════════════════════════════════════════════════════════════════════
// 消息处理
@@ -2434,17 +2445,18 @@ document.addEventListener('DOMContentLoaded', () => {
post('xb-tts:toast', { type: 'success', message: `已添加:${name}` });
});
$('addMySpeakerBtn').addEventListener('click', () => {
const id = $('newVoiceId').value.trim();
const name = $('newVoiceName').value.trim();
if (!id) { post('xb-tts:toast', { type: 'error', message: '请输入音色ID' }); return; }
if (!isInMyList(id)) {
mySpeakers.push({ name: name || id, value: id, source: 'auth' });
}
selectedVoiceValue = id;
$('newVoiceId').value = '';
$('newVoiceName').value = '';
$('addMySpeakerBtn').addEventListener('click', () => {
const id = $('newVoiceId').value.trim();
const name = $('newVoiceName').value.trim();
const resourceId = $('newVoiceResourceId').value;
if (!id) { post('xb-tts:toast', { type: 'error', message: '请输入音色ID' }); return; }
if (!isInMyList(id)) {
mySpeakers.push({ name: name || id, value: id, source: 'auth', resourceId });
}
selectedVoiceValue = id;
$('newVoiceId').value = '';
$('newVoiceName').value = '';
renderMyVoiceList();
updateCurrentVoiceDisplay();