Customize voice settings, tone, accent, and instructions for your AI agent
NAVAI provides flexible voice customization options to create the perfect voice experience for your users. You can customize the voice, tone, accent, and instructions for your AI agent.
import { registerNavaiExpressRoutes } from "@navai/voice-backend";const backendOptions = { openaiApiKey: process.env.OPENAI_API_KEY, defaultInstructions: `You are a helpful shopping assistant. Help users find products, answer questions about items, and guide them through checkout. Be concise and friendly. Always confirm before making purchases.`};registerNavaiExpressRoutes(app, { backendOptions });
Here’s a complete example combining all customization options:
.env
# Voice ConfigurationOPENAI_API_KEY=sk-...OPENAI_REALTIME_MODEL=gpt-realtimeOPENAI_REALTIME_VOICE=coral# Tone and AccentOPENAI_REALTIME_VOICE_TONE=friendly and professionalOPENAI_REALTIME_VOICE_ACCENT=neutral American English# InstructionsOPENAI_REALTIME_INSTRUCTIONS=You are a voice navigation assistant. Help users navigate the app efficiently and answer their questions clearly.
NAVAI automatically combines your customizations using the buildSessionInstructions function:
// From packages/voice-backend/src/index.ts:134-158function buildSessionInstructions(input: { baseInstructions: string; language?: string; voiceAccent?: string; voiceTone?: string;}): string { const lines = [input.baseInstructions.trim()]; if (language) { lines.push(`Always reply in ${language}.`); } if (voiceAccent) { lines.push(`Use a ${voiceAccent} accent while speaking.`); } if (voiceTone) { lines.push(`Use a ${voiceTone} tone while speaking.`); } return lines.join("\n");}
You can override any of these settings at runtime by passing them to createRealtimeClientSecret with the request body.