Skip to content

feat: add streaming-tts-karaoke demo - #31

Open
luke-speechify wants to merge 1 commit into
mainfrom
feat/streaming-tts-karaoke
Open

feat: add streaming-tts-karaoke demo#31
luke-speechify wants to merge 1 commit into
mainfrom
feat/streaming-tts-karaoke

Conversation

@luke-speechify

Copy link
Copy Markdown
Contributor

Pairs with the upcoming speechify.ai post "Realtime streaming TTS with word highlighting" (the pivot of the agent-events ticket — see below).

What this demo is

Realtime streaming TTS with dual word highlighting, built on POST /v1/audio/stream/with-timestamps (Server-Sent Events, simba-3.2):

  1. Received — each word lights up the instant its speech_marks arrive over the stream (marks race ahead of audio). Shows the wire speed.
  2. Playing — a second highlight follows the actual audio position during playback.
  • Server (app/api/stream/route.ts, Node) proxies the SSE straight through, key held server-side.
  • Client (app/page.tsx) parses speech.chunk events, maps each word mark to the rendered text by character offset, streams the base64 audio into <audio> via the MediaSource API, and follows playback with requestAnimationFrame.
  • Distinct from live-captions (that's the batch /v1/audio/speech endpoint + playback-only highlight); this is the streaming endpoint + arrival-vs-playback dual highlight.

Why this replaces the agent-events demo

The original DRG-381 was a changelog about a "realtime agent events" stream. I couldn't find any evidence that feature/endpoint exists (no SSE/WS for live agent calls; the conversations API only exposes status/timing). Rather than write about something unverifiable, this pivots to a real, verified capability — streaming TTS with word timestamps — which is a stronger demo anyway. Closing #25 (agent-events-inspector) in favour of this.

Hosting + abuse protection

  • Registered as a Vercel Service under /streaming-tts-karaoke (vercel.json + pnpm-workspace.yaml), basePath set, README/manifest regenerated via pnpm generate.
  • Gates /api/stream with the shared Cloudflare Turnstile helper (app/lib/turnstile.ts, verbatim), fail-open when TURNSTILE_SECRET_KEY is unset.

Verification

  • pnpm --filter streaming-tts-karaoke build
  • pnpm e2e ✅ — real-API Playwright test: drives the live SSE endpoint, asserts word marks arrive and highlight (.w.received), and the audio element gets a streamed source.

Blog post is written separately.

Realtime streaming TTS on POST /v1/audio/stream/with-timestamps (SSE): each
word highlights the instant its audio + timestamp arrive over the wire, then a
second highlight follows playback via the MediaSource API. A one-route Node
proxy pipes the SSE through so the API key stays server-side. Hosted under
/streaming-tts-karaoke, Turnstile-gated, with a real-API Playwright e2e.
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
speechify-api-demos Ready Ready Preview Aug 21, 2026 10:11am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant