Skip to content

feat: Switch to OpenAI Realtime API for voice calls#3

Open
Bartok9 wants to merge 1 commit into
ellie-copeland:mainfrom
Bartok9:main
Open

feat: Switch to OpenAI Realtime API for voice calls#3
Bartok9 wants to merge 1 commit into
ellie-copeland:mainfrom
Bartok9:main

Conversation

@Bartok9
Copy link
Copy Markdown

@Bartok9 Bartok9 commented Mar 5, 2026

Summary

Replaces the turn-based speak/gather flow with real-time bidirectional audio streaming via OpenAI's Realtime API.

Why

The previous Hume EVI integration was experiencing reliability issues (~7 second error). OpenAI Realtime provides:

  • Lower latency (sub-second)
  • More reliable connection
  • Server-side VAD
  • Better voice quality

Architecture

Phone → Telnyx → WebSocket Media Stream → OpenAI Realtime API
           ↓                                    ↓
       PCMU Audio ←←←←←←←←←←←←←←←←←←←←←←← AI Response

Changes

  • Add server.js with WebSocket + Next.js support
  • Update voice webhook to use Telnyx streaming answer
  • Add OpenAIRealtimeBridge helper class
  • Update package.json with ws dependency
  • Add .env.example with required config

Testing

  • Server starts successfully with npm run dev
  • WebSocket endpoint available at /media-stream
  • Verified syntax and module loading

Required Environment Variables

  • TELNYX_API_KEY
  • OPENAI_API_KEY
  • OPENAI_VOICE (optional, defaults to 'alloy')

Replaces the previous turn-based speak/gather flow with real-time
bidirectional audio streaming via OpenAI's Realtime API.

Architecture:
- Custom server.js with WebSocket support for /media-stream
- Telnyx media streaming (bidirectional RTP) → OpenAI Realtime
- Server-side VAD for natural turn detection
- g711_ulaw codec for telephony compatibility

Changes:
- Add server.js with WebSocket + Next.js
- Update voice webhook to use streaming answer
- Add OpenAIRealtimeBridge helper class
- Update package.json with ws dependency
- Add .env.example with required config

Closes: Hume EVI reliability issues
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