From d219aec6765444e351ae8bc864aa5db47609dac9 Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Fri, 4 Sep 2026 12:55:50 +0200 Subject: [PATCH] refactor: scope voice clone --- CHANGELOG.md | 2 ++ VERSION | 2 +- docs/ARCHITECTURE.md | 1 + static/index.html | 16 ++++++++-------- static/js/voice-clone.js | 27 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cd9cc3..00b4b7b 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 +- **Voice-clone namespace migration.** Clone audio loading/upload, microphone monitoring, design presets, and voice-design + actions now use a private scope with explicit compatibility exports and a `window.TTVC.voiceClone` API. - **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 diff --git a/VERSION b/VERSION index 27ec546..68f8db5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.24.75 +1.24.76 diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index a4a9b0c..cb93f71 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -65,6 +65,7 @@ Done incrementally as global-scope ordered files (no ES-module change needed) - ✅ 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. +- ✅ Voice-clone audio, recording, and design controls use a private scope with explicit 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 e9eb80b..91b2a0a 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/voice-clone.js b/static/js/voice-clone.js index 2ba5bf0..1de12ea 100644 --- a/static/js/voice-clone.js +++ b/static/js/voice-clone.js @@ -1,5 +1,7 @@ // ── Clone: recommended sample sentences ────────────────────────────────── +(function (root) { + const CLONE_SAMPLE_TEXTS = { EN: 'Hello! My name is Sam, and this is my voice. I can speak softly or with great strength. The crisp winter air, warm firelight, and the gentle sound of rain — these are the things I love. Can you hear how clearly I speak?', DE: 'Hallo! Ich heiße Alex und das ist meine Stimme. Ich kann leise flüstern oder mit voller Kraft sprechen. Klare Winterluft, warmes Kerzenlicht und der Klang des Regens am Fenster — das liebe ich. Hörst du, wie deutlich ich spreche?', @@ -1045,3 +1047,28 @@ $('transcribe-btn').addEventListener('click', async () => { tabs.forEach(t => t.addEventListener('click', () => show(t.dataset.src))); show(localStorage.getItem(KEY) || 'mic'); })(); + +// Preserve existing clone handlers while keeping recording, upload, and voice +// design implementation details inside a single module scope. +Object.assign(root, { + CLONE_SAMPLE_TEXTS, CLONE_SAMPLE_NAMES, cloneSampleForLang, + ws, wsRegions, currentFileId, trimmedFileId, designedFileId, editingVoiceId, editingVoicePath, + initWaveSurfer, updateRegion, updateDurationLabel, loadAudioId, dropZone, fileInput, + uploadFile, loadLibraryVoiceAudio, RAW_MIC_CONSTRAINTS, visibleMicrophoneCount, + microphoneErrorMessage, requestMicrophoneStream, _cloneMonState, _cloneRenderMeter, + _cloneStartMeter, _cloneStartMonitor, _cloneStopMonitor, mediaRec, recChunks, recTimer, recSecs, + DESIGN_LANG_CODE, DESIGN_GENDER_WORD, DESIGN_PRESET_KEY, DESIGN_PRESET_SEEDED_KEY, + DEFAULT_DESIGN_PRESETS, QWEN_DESIGN_SAMPLES, currentDesignSource, loadDesignPresets, + saveDesignPresets, syncDesignPresetsToServer, seedDesignPresets, refreshDesignPresetSelect, + applyDesignPreset, renderDesignPresetLibrary, renderQwenSampleCards, applyQwenSample, + isDialogueDesign, voiceDesignPayload, _dVoiceIdManual, designSafeName, voiceIdSafePart, + suggestedStyleVoiceId, _updateDVoiceId, runVoiceDesign, +}); +root.TTVC = root.TTVC || {}; +root.TTVC.voiceClone = root.TTVC.voiceClone || {}; +Object.assign(root.TTVC.voiceClone, { + samples: { forLanguage: cloneSampleForLang }, + audio: { init: initWaveSurfer, load: loadAudioId, upload: uploadFile }, + design: { run: runVoiceDesign, buildPayload: voiceDesignPayload }, +}); +})(window);