diff --git a/abogen/web/static/prepare.js b/abogen/web/static/prepare.js index b4ff76c..bd6cfd0 100644 --- a/abogen/web/static/prepare.js +++ b/abogen/web/static/prepare.js @@ -188,6 +188,8 @@ document.addEventListener("DOMContentLoaded", () => { const enabled = row.querySelector('[data-role=chapter-enabled]'); const inputs = Array.from(row.querySelectorAll("input[type=text], select, textarea")); const warning = row.querySelector('[data-role=chapter-warning]'); + const snippet = row.querySelector('[data-role="chapter-snippet"]'); + const details = row.querySelector('[data-role="chapter-details"]'); const isChecked = enabled ? enabled.checked : true; row.dataset.disabled = isChecked ? "false" : "true"; @@ -212,6 +214,16 @@ document.addEventListener("DOMContentLoaded", () => { const select = row.querySelector("select[data-role=voice-select]"); toggleFormula(select); + if (snippet) { + snippet.hidden = !isChecked; + snippet.setAttribute("aria-hidden", isChecked ? "false" : "true"); + } + + if (details) { + details.hidden = !isChecked; + details.setAttribute("aria-hidden", isChecked ? "false" : "true"); + } + if (warning) { warning.hidden = isChecked; warning.setAttribute("aria-hidden", isChecked ? "true" : "false"); @@ -337,7 +349,15 @@ document.addEventListener("DOMContentLoaded", () => { }); const speakerItems = Array.from(form.querySelectorAll(".speaker-list__item")); - speakerItems.forEach((item) => initialiseSpeakerItem(item)); + speakerItems.forEach((item) => { + initialiseSpeakerItem(item); + const pronunciationInput = item.querySelector('[data-role="speaker-pronunciation"]'); + if (pronunciationInput) { + const sync = () => syncPronunciationPreview(item); + pronunciationInput.addEventListener("input", sync); + pronunciationInput.addEventListener("change", sync); + } + }); const activeStepInput = form.querySelector('[data-role="active-step-input"]'); const analysisButtons = Array.from(form.querySelectorAll('[data-role="submit-speaker-analysis"]')); diff --git a/abogen/web/static/speakers.js b/abogen/web/static/speakers.js index 4062446..fed4117 100644 --- a/abogen/web/static/speakers.js +++ b/abogen/web/static/speakers.js @@ -26,6 +26,21 @@ const stopCurrentPlayback = () => { } }; +const resolvePreviewText = (button) => { + const source = (button.dataset.previewSource || "").toLowerCase(); + if (source === "pronunciation") { + const container = button.closest(".speaker-list__item"); + if (container) { + const input = container.querySelector('[data-role="speaker-pronunciation"]'); + const fallback = (container.dataset.defaultPronunciation || "").trim(); + const value = (input?.value || "").trim() || fallback; + button.dataset.previewText = value; + return value; + } + } + return (button.dataset.previewText || "").trim(); +}; + audioElement.addEventListener("ended", () => { stopCurrentPlayback(); }); @@ -37,7 +52,7 @@ audioElement.addEventListener("pause", () => { }); const playPreview = async (button) => { - const text = (button.dataset.previewText || "").trim(); + const text = resolvePreviewText(button); const voice = (button.dataset.voice || "").trim(); const language = (button.dataset.language || "a").trim() || "a"; const speedRaw = button.dataset.speed || "1"; diff --git a/abogen/web/static/styles.css b/abogen/web/static/styles.css index 257ecb0..d8b7fa7 100644 --- a/abogen/web/static/styles.css +++ b/abogen/web/static/styles.css @@ -618,6 +618,16 @@ body { border: 1px solid rgba(148, 163, 184, 0.18); } +button.step-indicator__item { + cursor: pointer; + font: inherit; +} + +button.step-indicator__item:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + .step-indicator__index { width: 1.75rem; height: 1.75rem; diff --git a/abogen/web/templates/index.html b/abogen/web/templates/index.html index 6142d46..93c1008 100644 --- a/abogen/web/templates/index.html +++ b/abogen/web/templates/index.html @@ -17,163 +17,7 @@ -
Step 1 of 3
-Choose your source file or paste text, then set the defaults used for chapter analysis and speaker casting.
-Step 1 of 3
+Choose your source file or paste text, then set the defaults used for chapter analysis and speaker casting.
+{{ pending.original_filename }}
+ {% endif %} +