From 998a65f2bad52ef47161fd19b340331f97aac650 Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Fri, 4 Sep 2026 12:53:44 +0200 Subject: [PATCH] refactor: scope tts preview --- CHANGELOG.md | 2 ++ VERSION | 2 +- docs/ARCHITECTURE.md | 1 + static/index.html | 16 ++++++++-------- static/js/tts-preview.js | 26 ++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f095e92..5cd9cc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index 01d9cc8..27ec546 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.24.74 +1.24.75 diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 107ef27..a4a9b0c 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -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. diff --git a/static/index.html b/static/index.html index 07e2654..e9eb80b 100644 --- a/static/index.html +++ b/static/index.html @@ -10,7 +10,7 @@ - + @@ -27,12 +27,12 @@ - - - - - - + + + + + + @@ -397,7 +397,7 @@ window.toggleNavTree = function(treeId, chevronId) { - + diff --git a/static/js/tts-preview.js b/static/js/tts-preview.js index 4f270cf..ca679a4 100644 --- a/static/js/tts-preview.js +++ b/static/js/tts-preview.js @@ -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);