From cf90b6be5445a659a78eee5bfbe8f96f80fc3b3e Mon Sep 17 00:00:00 2001 From: Bashy Date: Sat, 21 Nov 2026 15:03:07 +0200 Subject: [PATCH] TTS: allow up to 500 characters, smaller handwriting on the letter for long messages Co-Authored-By: Claude Opus 5.5 --- public/alerts/fx.css | 11 ++++++++--- public/alerts/fx.js | 2 +- src/routers/settings.js | 2 +- src/tts.js | 2 +- views/settings.ejs | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/public/alerts/fx.css b/public/alerts/fx.css index f085773..d324954 100644 --- a/public/alerts/fx.css +++ b/public/alerts/fx.css @@ -46,9 +46,14 @@ @keyframes fx-flap { from { transform:rotateX(180deg); z-index:4; } } #fx-alert .envl .slot { position:absolute; left:-40px; right:-40px; bottom:0; top:-400px; overflow:hidden; z-index:2; animation:fx-zswap 1.6s .8s both; } @keyframes fx-zswap { 0%, 54% { z-index:2; } 55%, 100% { z-index:6; } } -#fx-alert .envl .letter { position:absolute; left:62px; bottom:30px; width:316px; min-height:290px; background:#fffdf7; padding:18px 22px 22px; +#fx-alert .envl .letter { --fs:24px; --lh:30px; position:absolute; left:62px; bottom:30px; width:316px; min-height:290px; background:#fffdf7; padding:18px 22px 22px; box-shadow:0 4px 12px rgba(0,0,0,.3); animation:fx-rise 1.6s .8s both; - background-image:repeating-linear-gradient(transparent 0 29px, rgba(110,150,200,.3) 29px 30px); background-position:0 46px; } + background-image:repeating-linear-gradient(transparent 0 calc(var(--lh) - 1px), rgba(110,150,200,.3) calc(var(--lh) - 1px) var(--lh)); + background-position:0 calc(22px + var(--lh) - 6px); } +/* longer messages: smaller handwriting, the ruled lines follow */ +#fx-alert .envl .letter.long { --fs:20px; --lh:25px; } +#fx-alert .envl .letter.longer { --fs:17px; --lh:21px; width:340px; } +#fx-alert .envl .letter.huge { --fs:15px; --lh:18px; width:356px; } @keyframes fx-rise { 0% { transform:translateY(110px); animation-timing-function:cubic-bezier(.3,.7,.4,1); } 45% { transform:translateY(-200px) rotate(-1deg); } @@ -56,7 +61,7 @@ 100% { transform:translateY(-14px) rotate(-2deg); } } #fx-alert .envl .to { font:700 22px/1 Caveat, cursive; color:var(--red); margin-bottom:6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } -#fx-alert .envl .tx { font:700 24px/30px Caveat, cursive; color:var(--ink); word-wrap:break-word; } +#fx-alert .envl .tx { font:700 var(--fs)/var(--lh) Caveat, cursive; color:var(--ink); word-wrap:break-word; } #fx-alert .envl .w { opacity:.12; transition:opacity .25s; } #fx-alert .envl .w.on { opacity:1; } #fx-alert .envl .seal { position:absolute; left:157px; bottom:86px; width:46px; height:46px; z-index:5; border-radius:50%; background:#b74347; diff --git a/public/alerts/fx.js b/public/alerts/fx.js index 7e019b6..e1cdaf6 100644 --- a/public/alerts/fx.js +++ b/public/alerts/fx.js @@ -156,7 +156,7 @@ const text = d.msg || ''; const words = text.split(/\s+/).filter(Boolean); el.innerHTML = `
-
from ${esc(d.name)} ♡
+
from ${esc(d.name)} ♡
${words.map(w => `${esc(w)}`).join(' ')}
♥
`; el.style.visibility = 'visible'; diff --git a/src/routers/settings.js b/src/routers/settings.js index 63c2870..b55b255 100644 --- a/src/routers/settings.js +++ b/src/routers/settings.js @@ -25,7 +25,7 @@ router.post('/', (req, res) => { gap_audio_min_volume: flt(b.gap_audio_min_volume, 0.2), gap_audio_max_volume: flt(b.gap_audio_max_volume, 1.0), gap_audio_loud_after: int(b.gap_audio_loud_after, 3600), - tts_max_chars: Math.max(20, Math.min(300, int(b.tts_max_chars, 200))), + tts_max_chars: Math.max(20, Math.min(500, int(b.tts_max_chars, 200))), tts_say_name: b.tts_say_name === 'on' ? 1 : 0, tts_blocklist: String(b.tts_blocklist || '').slice(0, 20000), custom_css: b.custom_css || '', diff --git a/src/tts.js b/src/tts.js index 218b2ed..1f07c27 100644 --- a/src/tts.js +++ b/src/tts.js @@ -20,7 +20,7 @@ const VOICES_DIR = process.env.TTS_VOICES_DIR || path.join(ROOT, 'tools/tts/voic const OUT_DIR = path.join(ROOT, 'public/tts'); const TMP_DIR = path.join(OUT_DIR, 'tmp'); const KEEP_FILES = 300; // cached mp3s kept in public/tts (oldest deleted first) -const MAX_CHARS = 300; +const MAX_CHARS = 500; // Twitch chat messages are max 500 characters const SR = 44100; const LIMITS = { diff --git a/views/settings.ejs b/views/settings.ejs index f653c79..725fe22 100644 --- a/views/settings.ejs +++ b/views/settings.ejs @@ -63,7 +63,7 @@