The user's topic, voice selection, and duration are sent to DeepSeek-V4-Flash via GMI's LLM API with stream: true. Tokens arrive in real-time over an SSE connection and are forwarded to the browser. The model returns a structured JSON script — host/guest turns, company, guest name, title — in a single pass (~1–2 s).
02
Parallel Voice Synthesis
All N dialogue lines are dispatched to Inworld TTS-2 concurrently via Promise.all() — not sequentially. Each request returns an MP3 audio_url and word-level timestamps (timestamp_type: 'WORD') used for live transcript highlighting. Parallel dispatch cuts synthesis time from ~N×T to ~max(T).
03
Progressive Playback via SSE
The Node.js server streams token, meta, line, and done events to the browser via Server-Sent Events. The play button activates after the first 3 audio segments are preloaded — without waiting for the full episode. Lines are appended to the transcript progressively as TTS resolves.
04
Word-Level Transcript Sync
Inworld TTS-2 returns wordAlignment arrays: words[], wordStartTimeSeconds[], wordEndTimeSeconds[]. A requestAnimationFrame loop compares audio.currentTime against each word's start offset and applies the .spoken class for real-time highlighting.