feat: add live-captions demo - #26
Open
luke-speechify wants to merge 2 commits into
Open
Conversation
…k with speech marks
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pairs with the upcoming speechify.ai post "Live captions as a browser extension with speech marks".
This is the hostable web update of the earlier post "Building real-time captions with Speechify TTS speech marks" — the original framed the captions as a browser extension, which can't be hosted, so this ships the same speech-marks logic as a page you can host and run.
What it does
POST /api/speak(Node runtime) synthesizes withclient.audio.speech(modelsimba-3.2, voicegeffen_32, MP3) and returns{ audio, speechMarks }, wherespeechMarksisresponse.speech_marks.chunks— one entry per word withstart_time/end_timein milliseconds and the wordvalue.requestAnimationFrame, readsaudio.currentTimeand highlights the word whose[start_time, end_time)window contains the current position (binary search). No forced alignment, no polling timer, no custom decoder.activeIndexAt()logic drops straight into a browser-extension content script — swap the React state update for aclassListtoggle.Security + gating
SPEECHIFY_API_KEYstays server-side: every Speechify call runs inside theapp/api/speakroute handler, andnext.config.tsmarks@speechify/apias a server-external package so the SDK is never bundled into client JS.verifyTurnstile(req)first and returns 403 on failure; the client renders the shared Turnstile widget and attachesx-turnstile-tokento the gated fetch. Turnstile fail-opens when unconfigured (local dev).Hosting registration
live-captionsservice + rewrite invercel.json(rewrite placed before/and the catch-all).demos/live-captionstopnpm-workspace.yaml.pnpm generateto refresh the README table and site manifest.Verification
pnpm --filter live-captions build✅audio_dataplusspeech_marks.chunks, each chunk carryingstart_time/end_time(ms) andvalue, with the exact model (simba-3.2), voice (geffen_32), and body the route sends.