refactor: scope tts preview

This commit is contained in:
mARTin-B78 2026-09-04 12:53:44 +02:00
parent 656d0473d4
commit 998a65f2ba
5 changed files with 38 additions and 9 deletions

View File

@ -8,6 +8,8 @@ Follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · versioned wi
## [Unreleased]
### Changed
- **TTS preview namespace migration.** Backend voice selection, Fish emotion tags, preview synthesis, stream fallback,
and performance-history helpers now use a private scope with explicit compatibility exports and a `window.TTVC.tts` API.
- **Settings namespace migration.** Settings state, backend catalogs, help rendering, and provider configuration now use
a private scope with live compatibility accessors and a `window.TTVC.settings` API.
- **Character library namespace migration.** SQLite-backed character persistence, identity merging, image updates, and

View File

@ -1 +1 @@
1.24.74
1.24.75

View File

@ -64,6 +64,7 @@ Done incrementally as global-scope ordered files (no ES-module change needed)
- ✅ Studio navigation and DOM-borrowing coordination use a private scope with explicit compatibility exports.
- ✅ Character library persistence and rendering use a private scope with explicit identity/image compatibility exports.
- ✅ Settings state and backend configuration use a private scope with live compatibility accessors and a namespace API.
- ✅ TTS preview and performance-history helpers use a private scope with explicit preview/history compatibility exports.
- ✅ `static/css/resource-diagnostics.css` — isolated Performance/resource diagnostic panel styles.
- ✅ `static/css/background-jobs.css` — isolated background-job history and retry-panel styles.
- ✅ `static/css/voice-design.css` — isolated Voice Design form, samples, and preview-match styles.

View File

@ -10,7 +10,7 @@
<meta name="format-detection" content="telephone=no">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#2563EB">
<meta name="app-version" content="1.24.74">
<meta name="app-version" content="1.24.75">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="icon" href="/static/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/static/icon.svg">
@ -27,12 +27,12 @@
<!-- ── Core styles (local — no CDN dependency for first paint) ────────── -->
<link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css">
<link rel="stylesheet" href="/static/style.css?v=1.24.74">
<link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.74">
<link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.74">
<link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.74">
<link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.74">
<link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.74">
<link rel="stylesheet" href="/static/style.css?v=1.24.75">
<link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.75">
<link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.75">
<link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.75">
<link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.75">
<link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.75">
<!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── -->
@ -397,7 +397,7 @@ window.toggleNavTree = function(treeId, chevronId) {
</script>
<!-- loader.js: fetches sections → loads JS modules → removes skeleton -->
<script src="/static/loader.js?v=1.24.74"></script>
<script src="/static/loader.js?v=1.24.75"></script>
</body>
</html>

View File

@ -1,5 +1,7 @@
// ── TTS preview ───────────────────────────────────────────────────────────
(function (root) {
function backendVoiceId(value) {
return typeof value === 'string' ? value : (value?.id || value?.voice || value?.name || JSON.stringify(value));
}
@ -292,6 +294,7 @@ function _fishTagsSync() {
if (ta) { ta.value = FISH_TAG_SAMPLE_TEXT; ta.focus(); }
});
})();
function _ttsApplyEmotionTag(text, emotionValue) {
const backend = $('tts-backend-select')?.value || '';
if (!_ttsIsFishBackend(backend) || !emotionValue) return text;
@ -973,3 +976,26 @@ function renderPerfHistory() {
renderPerfHistory();
})();
Object.assign(root, {
backendVoiceId, shouldFilterBackendVoices, shouldReplaceWithLibraryVoices,
activeLibraryVoiceIds, cleanReferenceText, selectedPreviewLibraryVoice,
previewVoiceWarnings, updatePreviewVoiceMatchPanel, synthesizeSelectedReferenceText,
_ttsIsFishBackend, FISH_EMOTION_TAGS, FISH_TAG_SAMPLE_TEXT, _fishInsertTag,
_fishTagsRender, _fishTagsSync, _ttsApplyEmotionTag, _ttsStreamHealth,
effectiveTtsPlaybackMode, isTtsStreamAvailable, createTtsStreamUrl,
_ttsPreviewFetchWithRetry, _ttsBackendForVoice, fetchTtsPreviewBlob,
_textWords, _textSimilarity, _voiceRoundtripCheck, createTtsAudioSource,
previewBlob, PREVIEW_SAMPLE_TEXT, _onPreviewGenerated, _TRYOUT_SPEED_KEY,
PERF_HISTORY_KEY, PERF_HISTORY_MAX, PERF_HISTORY_SORT, perfHistoryLoad,
perfHistorySave, perfHistoryAdd, perfSparklineSvg, perfHistoryVoiceLookup,
perfHistoryVoiceMeta, perfHistoryExtraFields, perfHistoryGenderLabel,
perfHistoryDeviceLabel, perfHistoryDeviceHtml, perfHistoryAvatarHtml,
perfHistorySortValue, perfHistoryCompare, perfHistoryHeadButton, renderPerfHistory,
});
root.TTVC = root.TTVC || {};
root.TTVC.tts = root.TTVC.tts || {};
Object.assign(root.TTVC.tts, {
preview: { synthesize: synthesizeSelectedReferenceText, createAudio: createTtsAudioSource },
history: { load: perfHistoryLoad, save: perfHistorySave, render: renderPerfHistory },
});
})(window);