TTS redeems, skip button, per-source chat placement

- Redeem variations can have a TTS voice: the viewer's text is cleaned
  (links out, repeats collapsed, max length, blocked words -> not read),
  spoken as "<name> says: ..." and shown as the big paper note; the
  variation's sound is not played when TTS is on (picker greyed out)
- Settings: TTS max length, say-the-name, blocked words (never sent to
  overlay pages: db.getOverlaySettings)
- Dashboard "Skip current alert" -> /alerts/skip -> overlay skips it
- db.migrate()/addColumn: new columns on existing databases
- Chat: ?chat=left,top,width,height and ?chatflow=up per browser source
  (e.g. the Intermission panel); default unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-21 14:34:41 +02:00
parent b5a81bdb15
commit 4fda6060bf
16 changed files with 228 additions and 28 deletions

View file

@ -11,11 +11,27 @@
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat</code><br>
<small>Everything except chat (alerts, redeems, poll, Hype Train bar, raid send-off):</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=nochat</code><br>
<small>Chat somewhere else, e.g. in the Intermission panel (left,top,width,height in px of the 1920×1080 page; <em>up</em> = newest at the bottom):</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat&amp;chat=130,640,700,360&amp;chatflow=up</code><br>
<small title="parts: chat, alerts, poll, hypebar, raid. List them (?parts=chat,raid) or exclude with no… (?parts=nochat,noraid). No ?parts = everything.">
Other combinations: hover for help · everything in one source: <code>/overlay/<%= settings.overlay_id %></code></small>
</div>
</div>
<div style="display:flex; gap:.8rem; align-items:center; margin-bottom:1.5rem;">
<button type="button" id="skip-alert" class="outline" style="width:auto; margin:0;"
title="Stops the alert that is on screen right now (sound and TTS voice too). Queued alerts carry on.">⏭ Skip current alert</button>
<small id="skip-status"></small>
</div>
<script>
document.getElementById('skip-alert').addEventListener('click', async () => {
const st = document.getElementById('skip-status');
try { const r = await fetch('/alerts/skip', { method: 'POST' }); st.textContent = r.ok ? 'Skipped' : `Failed (${r.status})`; }
catch (e) { st.textContent = 'Failed: ' + e.message; }
setTimeout(() => { st.textContent = ''; }, 3000);
});
</script>
<h3>Twitch connection</h3>
<p>
<% if (eventsubStatus.connected) { %>

View file

@ -67,7 +67,7 @@
</style>
</head>
<body>
<% if (has('chat')) { %><div id="chat"></div><% } %>
<% if (has('chat')) { %><div id="chat" class="<%= chatFlow %>"<% if (chatBox) { %> style="--chat-left:<%= chatBox.left %>px; --chat-top:<%= chatBox.top %>px; --chat-width:<%= chatBox.width %>px; --chat-height:<%= chatBox.height %>px;"<% } %>></div><% } %>
<% if (has('alerts')) { %><div id="alert-box"></div>
<video id="alert-video" autoplay></video><% } %>
@ -161,6 +161,7 @@
// NOWPLAYING: if (msg.type === 'nowplaying') { if (PARTS.has('nowplaying')) NowPlaying.update(msg.np); return; }
if (msg.type === 'nowplaying') return;
if (msg.type === 'raid_card') { if (PARTS.has('raid')) RaidCard.update(msg.phase, msg.raid); return; }
if (msg.type === 'alert_skip') { if (PARTS.has('alerts')) PolaroidAlerts.skip(); return; }
if (!PARTS.has('alerts')) return; // alerts and legacy actions below
if (msg.type === 'alert') {
// test buttons: replace other test alerts at once, but never cut off a real alert

View file

@ -40,6 +40,7 @@
<% if (t.cost != null) { %><span class="meta"><%= t.cost %> pts</span><% } %>
<% if (t.missing) { %><span class="badge badge-red">not on Twitch anymore</span><% } %>
<% if (t.live === false) { %><span class="badge badge-grey">paused on Twitch</span><% } %>
<% if (t.variations.some(v => v.tts_voice_id)) { %><span class="badge badge-green" title="At least one variation reads the viewer's text aloud">TTS</span><% } %>
<span class="meta">
<%= t.variations.length ? `${on.length}/${t.variations.length} variation${t.variations.length === 1 ? '' : 's'} on` : 'no alert' %>
</span>
@ -72,6 +73,10 @@
<option value="">sticker: headset Streamer</option>
<% for (const st of stickers) { %><option value="<%= st.url %>" <%= v.art === st.url ? 'selected' : '' %>>sticker: <%= st.label %></option><% } %>
</select>
<select name="tts_voice_id" data-tts style="width:auto;" title="Read the viewer's typed text aloud with a voice from the TTS page, shown as a big paper note. The voice replaces the sound. The reward needs 'Require Viewer to Enter Text' on Twitch.">
<option value="">TTS: off</option>
<% for (const tv of ttsVoices) { %><option value="<%= tv.id %>" <%= v.tts_voice_id === tv.id ? 'selected' : '' %>>TTS: <%= tv.name %></option><% } %>
</select>
<button type="button" class="outline btn-sm" data-play title="Play the sound here in the browser">▶</button>
<button type="submit" class="btn-sm">Save</button>
<button type="button" class="outline btn-sm" data-test-var="<%= v.id %>" title="Show it on the overlay">Test</button>
@ -122,6 +127,17 @@
post('/redeems/trigger/test', { kind: b.dataset.kind, key: b.dataset.key });
}));
// TTS on = no sound: grey out the sound picker (the server ignores it too)
document.querySelectorAll('[data-tts]').forEach(sel => {
const form = sel.closest('form'), snd = form.querySelector('[data-sound]');
const sync = () => {
snd.disabled = !!sel.value;
snd.title = sel.value ? 'TTS is on: the voice replaces the sound' : '';
};
sel.addEventListener('change', sync); sync();
form.addEventListener('submit', () => { snd.disabled = false; }); // still submit it, so turning TTS off brings the sound back
});
// two-step delete, no browser dialog
document.querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', () => {
const c = b.parentElement.querySelector('[data-del-confirm]');

View file

@ -58,6 +58,25 @@
<small>e.g. 3600 = 1 hour of silence → max volume</small>
</label>
<h3>TTS redeems</h3>
<p><small>For redeem variations with a TTS voice (set on the Redeems page; voices are made on the TTS page).</small></p>
<div style="display:grid; grid-template-columns:1fr 1fr; gap:1rem;">
<label>
Max length (characters)
<input type="number" name="tts_max_chars" value="<%= settings.tts_max_chars %>" min="20" max="300">
<small>Longer messages are cut at a word.</small>
</label>
<label style="align-self:center;">
<input type="checkbox" name="tts_say_name" role="switch" <%= settings.tts_say_name ? 'checked' : '' %>>
Say the name first ("ChickenWhisperer says: …")
</label>
</div>
<label>
Blocked words
<textarea name="tts_blocklist" rows="4" placeholder="one per line, or comma-separated"><%= settings.tts_blocklist %></textarea>
<small>If a message contains one, nothing is read and the note shows "(message removed)". Not case-sensitive; also catches simple swaps like 0→o, $→s, and spaced-out letters for words of 4+ letters. Links are always removed.</small>
</label>
<h3>Custom CSS / JS</h3>
<label>
Custom CSS (injected into the overlay)