Skip to content

Speech engine example#233

Merged
tadaspetra merged 7 commits into
mainfrom
speech-engine
May 21, 2026
Merged

Speech engine example#233
tadaspetra merged 7 commits into
mainfrom
speech-engine

Conversation

@tadaspetra
Copy link
Copy Markdown
Collaborator

@tadaspetra tadaspetra commented May 21, 2026

Note

Medium Risk
Adds a new Next.js example that introduces a standalone Speech Engine WebSocket server, OpenAI-backed response generation, and file-backed chat-history linking, increasing operational and dependency surface area. Risk is contained to the new example, but it touches realtime voice session flows and env/secret handling patterns.

Overview
Adds a new Speech Engine quickstart example (Next.js). The repo now includes speech-engine/nextjs/quickstart with docs, a generator PROMPT.md, and a setup.sh that seeds from the Next.js template while adding @elevenlabs/react, @elevenlabs/elevenlabs-js, openai, dotenv, tsx, and a livekit-client pin.

The generated example/ introduces (1) a standalone server.mts that attaches speechEngine.attach(..., "/ws") and streams OpenAI Responses API output back to ElevenLabs, (2) API routes for typed chat (/api/chat), WebRTC tokens (/api/token), and a demo-only file-backed voice-history bridge (/api/voice-history*), and (3) a single-page UI that can switch between typed chat and live voice while preserving context.

Docs and repo indices are updated to list the new example and add /speech-engine to the scaffold reference matrix.

Reviewed by Cursor Bugbot for commit 8c33ec1. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread speech-engine/nextjs/quickstart/example/app/page.tsx Outdated
Comment thread speech-engine/nextjs/quickstart/example/components/ui/live-waveform.tsx Outdated
Comment thread speech-engine/nextjs/quickstart/example/app/page.tsx
Comment thread speech-engine/nextjs/quickstart/setup.sh
Comment thread speech-engine/nextjs/quickstart/example/app/page.tsx Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit a264bb5. Configure here.


if (history.length > 0 || attempt === 4) {
initialHistoryByConversation.set(conversationId, history);
return history;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty history cached permanently prevents later retrieval

Medium Severity

loadInitialHistory caches empty results on the final retry attempt (attempt === 4). Once cached, the early-return on has(conversationId) means subsequent onTranscript calls for the same conversation always return the cached empty array, even if the voice history link POST completes successfully afterward. This permanently drops typed chat context for the voice session whenever the link is delayed beyond the ~320ms retry window.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a264bb5. Configure here.

@tadaspetra tadaspetra merged commit 3007ef5 into main May 21, 2026
3 checks passed
@tadaspetra tadaspetra deleted the speech-engine branch May 21, 2026 17:50
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.

2 participants