Voice Chat

UseBelha supports real-time voice conversations through a secure WebSocket proxy (/api/live). Users can speak naturally and hear responses instantly.

Emotion-Aware Voice

Voice templates can enable emotion-aware responses for more natural conversations.

Voice Templates

Voice Assistant

tpl_voice

Friendly voice assistant for general conversations. Uses Puck voice.

Voice Support Agent

tpl_voice_support

Empathetic customer support via voice. Uses Kore voice.

Available Voices

VoiceDescriptionStyle
PuckFriendly and casualNeutral
CharonProfessional and calmMale
KoreWarm and empatheticFemale
FenrirConfident and energeticMale
AoedeClear and articulateFemale

Voice Configuration

Add voice support to any agent:

json
{
  "name": "My Voice Agent",
  "systemPrompt": "You are a helpful voice assistant...",
  "voice": {
    "enabled": true,
    "voiceName": "Kore",
    "affectiveDialog": true
  }
}

How It Works

  1. Connection - Browser connects to /api/live WebSocket proxy
  2. Audio Capture - Microphone captures 16-bit PCM at 16kHz
  3. Streaming - Audio streams through the backend proxy to the voice service
  4. Response - AI generates audio response in real-time
  5. Playback - Response plays through speakers at 24kHz

Using the useLiveChat Hook

typescript
import { useLiveChat } from '@/lib/useLiveChat';

const {
  isConnected,      // WebSocket connected
  isConnecting,     // Connection in progress
  isListening,      // Microphone active
  isSpeaking,       // AI generating audio
  messages,         // Chat history with transcriptions
  connect,          // Start connection
  disconnect,       // Close connection
  startListening,   // Begin voice capture
  stopListening,    // Stop voice capture
  sendText,         // Send text message
  interrupt,        // Stop current playback
} = useLiveChat({
  systemPrompt: 'You are a helpful assistant.',
  voiceName: 'Kore',
  affectiveDialog: true,
});

Audio Requirements

DirectionFormatSample Rate
Input (microphone)16-bit PCM, little-endian16kHz
Output (speakers)16-bit PCM, little-endian24kHz

Testing Voice

  1. Open the Dashboard
  2. Select a voice template (tpl_voice or tpl_voice_support)
  3. Click Quick Test
  4. Allow microphone access when prompted
  5. Click the microphone button to start speaking

Browser Support

Voice requires a modern browser with WebSocket, AudioWorklet, and microphone permissions. Chrome, Edge, and Firefox are recommended.