mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-29 08:01:02 +03:00
feat(web-test): add speech support to showTitleSlide
Title slides can now have TTS narration, same as showCaption/showImage. Pass opts.speech as string for custom narration text, or true to use the title text. Includes smart wait for video timeline sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
9d6ceae4f1
commit
a4e0faaeb3
@@ -4190,7 +4190,19 @@ export async function showTitleSlide(text, opts = {}) {
|
|||||||
background = 'linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%)',
|
background = 'linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%)',
|
||||||
color = '#fff',
|
color = '#fff',
|
||||||
fontSize = 36,
|
fontSize = 36,
|
||||||
|
speech,
|
||||||
} = opts;
|
} = opts;
|
||||||
|
|
||||||
|
// Collect caption for TTS narration if recording
|
||||||
|
let smartWaitMs = 0;
|
||||||
|
if (recorder && speech && speech !== false) {
|
||||||
|
const captionText = typeof speech === 'string' ? speech : text.replace(/\n/g, ' ');
|
||||||
|
if (captionText) {
|
||||||
|
recorder.captions.push({ text: captionText, speech: captionText, time: Math.round(recorder.videoTimeMs) });
|
||||||
|
smartWaitMs = Math.max(2000, captionText.length * 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await page.evaluate(({ text, subtitle, background, color, fontSize }) => {
|
await page.evaluate(({ text, subtitle, background, color, fontSize }) => {
|
||||||
let div = document.getElementById('__web_test_title');
|
let div = document.getElementById('__web_test_title');
|
||||||
if (!div) {
|
if (!div) {
|
||||||
@@ -4211,6 +4223,18 @@ export async function showTitleSlide(text, opts = {}) {
|
|||||||
}
|
}
|
||||||
div.innerHTML = `<div style="text-align:center;max-width:70%;color:${color};font-family:'Segoe UI',Arial,sans-serif;">${html}</div>`;
|
div.innerHTML = `<div style="text-align:center;max-width:70%;color:${color};font-family:'Segoe UI',Arial,sans-serif;">${html}</div>`;
|
||||||
}, { text, subtitle, background, color, fontSize });
|
}, { text, subtitle, background, color, fontSize });
|
||||||
|
|
||||||
|
// Smart TTS wait (same pattern as showCaption/showImage)
|
||||||
|
if (smartWaitMs > 0) {
|
||||||
|
let remaining = smartWaitMs;
|
||||||
|
while (remaining > 0) {
|
||||||
|
const chunk = Math.min(remaining, 1000);
|
||||||
|
await page.waitForTimeout(chunk);
|
||||||
|
remaining -= chunk;
|
||||||
|
if (recorder?._flushFrames) recorder._flushFrames();
|
||||||
|
}
|
||||||
|
recorder.captionCredit = { waitedMs: smartWaitMs, at: Date.now() };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove the title slide overlay. */
|
/** Remove the title slide overlay. */
|
||||||
|
|||||||
Reference in New Issue
Block a user