Voice Coach (Real-Time Sales Simulator)
Role: Solo, end-to-end
Tech Stack: Node.js/Express, React, OpenAI Realtime API, WebRTC, TypeScript
Repository: Private. Demo available on request
Overview
Voice Coach is a real-time conversational AI tool for practicing sales calls. Practice objection handling, closing, and discovery against a realistic AI prospect before burning real leads.
Using OpenAIās Realtime API over WebRTC, the system enables natural conversation with sub-500ms latency, which is what makes ābarge-inā (interrupting the AI) and real conversational flow actually work the way they would on a real call.
The Latency Problem
Most voice assistants feel robotic because of the latency chain:
- Speech-to-Text (waiting) ā LLM Inference (waiting) ā Text-to-Speech (waiting)
In a sales call, a 3-second pause destroys the momentum. The whole point of practice is training the muscle, and the muscle doesnāt work if the rhythm is wrong.
Solution: Peer-to-Peer WebRTC Architecture
- Client-Side Processing: the heavy lifting happens client-side using OpenAIās Realtime API.
- Ephemeral Token Server: the lightweight Express backend (
server.js) exists purely to mint security tokens. - Direct Connection: once the token is received, the React client establishes a direct WebRTC connection with the model.
- Barge-In Capability: interrupt the AI and it stops speaking immediately, mimicking natural human cadence.
The Dynamic Context-Aware Co-Pilot
In real sales calls, professionals have ābattle cardsā or scripts on their desk. Voice Coach acts as a dynamic co-pilot that follows the conversation.
The Dynamic Cheatsheet listens to the transcript stream and automatically switches UI context based on keyword triggers:
// Simplified logic from client/components/App.jsx
if (/expensive|budget|cost/i.test(text)) {
return "Objection Handling Framework"; // Auto-switch to pricing rebuttals
}
if (/agreement|sign|commit/i.test(text)) {
return "Closing Techniques"; // Auto-switch to closing scripts
}
When the AI prospect says āThat sounds great, but we donāt have the budget,ā the screen snaps to the Objection Handling panel with the āFeel-Felt-Foundā framework ready to go.
Strict Scenario Injection
Generic LLMs are too agreeable to be good practice partners. To train effectively, the AI has to be difficult and realistic.
The PromptEditor constructs rigorous system instructions with detailed persona templates:
āYou are Linda, the owner of Sweet Treats Bakery. You are stressed because a delivery was just canceled. You are skeptical of salespeople. Do not be polite for the sake of it.ā
That turns the AI into a sparring partner that offers real resistance, which forces you to actually deploy the soft skills rather than glide through a compliant conversation.
Post-Game Automated Rubric
The most valuable part of training is feedback. Rather than leaving it to subjective guessing, the system provides structured evaluation.
Analytics loop:
- Transcript Extraction: the app compiles the full conversation history.
- The āJudgeā Call: a secondary, silent LLM request evaluates the transcript against a rubric.
- Structured JSON Output: the model returns scores and specific evidence.
Example feedback:
Score: 2/4. Feedback: You acknowledged the price concern but moved too quickly to a discount without establishing value first.
System Architecture
graph TD
A[User Speaks] -->|Audio Stream| B[WebRTC Connection]
B -->|Realtime API| C[OpenAI Model]
C -->|Response| B
B -->|Audio Output| D[User Hears Response]
E[Transcript Stream] -->|Keyword Detection| F[Dynamic Cheatsheet]
F -->|Context Switch| G[React UI]
H[Session End] -->|Full Transcript| I[Evaluation Engine]
I -->|Structured Analysis| J[Feedback Report]
Use Cases
- Sales Training: practice objection handling, closing, and discovery.
- Interview Prep: mock interviews with instant feedback on communication skills.
- Negotiation Practice: role-play high-stakes negotiation scenarios.
Tech Stack
- Backend: Node.js, Express
- Frontend: React, TypeScript
- Real-Time: OpenAI Realtime API, WebRTC
- UI: React Context for state management
- Deployment: Docker, Cloud environments
Architecture: Mode-Based Extensibility
The codebase uses a mode-based architecture where swapping the ScenarioSelector and PromptTemplate components instantly transforms the engine from a Sales Coach into a Mock Interviewer or Negotiation Trainer.
The same real-time infrastructure serves multiple training use cases without any changes to the core WebRTC and evaluation logic.