From 25150c228442e54e48f89938fd248826e9c36c65 Mon Sep 17 00:00:00 2001 From: Admin Date: Sat, 4 Apr 2026 19:49:53 +0500 Subject: [PATCH] =?UTF-8?q?feat:=20TTS=20streaming=20=E2=80=94=20Kokoro/Po?= =?UTF-8?q?cketTTS=20audio=20starts=20immediately?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously all voices waited for full TTS generation before first byte reached the browser (POST → poll → presign flow). For long chapters this meant 2–5 minutes of silence. New flow for Kokoro and PocketTTS: - tryPresign fast path unchanged (audio in MinIO → seekable presigned URL) - On cache miss: set audioEl.src to /api/audio-stream/{slug}/{n} and mark status=ready immediately — audio starts playing within seconds - Backend streams bytes to browser while concurrently uploading to MinIO; subsequent plays use the fast path New SvelteKit route: GET /api/audio-stream/[slug]/[n] - Proxies backend handleAudioStream (already implemented in Go) - Same 3 chapters/day free paywall as POST route - HEAD handler for paywall pre-check (no side effects, no counter increment) so AudioPlayer can surface upgrade CTA before pointing