Voice Test

Test your voice agents before going to production using the built-in browser-based Voice Test tool or via the Sessions API.


Browser Voice Test (Dashboard)

The easiest way to test — no code required:

  • Log in to the UltraVoice dashboard
  • Navigate to Voice Test in the left sidebar
  • Select an agent from the dropdown
  • Click Start Conversation
  • Speak into your microphone — the AI responds in real-time
  • View the live transcript in the panel below
  • Click End Conversation when done
💡

Make sure your browser has microphone permission granted. Chrome and Safari are recommended for lowest audio latency.


API-Based Test Session

Start a test session programmatically and connect via WebSocket:

BASH
# Start a session
curl -X POST https://ultravoice.us.inc/api/v1/voice/sessions/start \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "YOUR_AGENT_ID",
    "user_id": "test-user",
    "welcome_message": "Hello! This is a test."
  }'

# Response:
# { "session_id": "f7e8d9c0-...", "status": "ready" }

Connect to the WebSocket and stream audio:

TEXT
wss://ultravoice.us.inc/api/v1/voice/ws/{session_id}

Test Phone Call

Test telephony by placing an outbound call to your own phone number:

BASH
curl -X POST https://ultravoice.us.inc/api/v1/telephony/calls/outbound \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "YOUR_AGENT_ID",
    "to_number": "+1234567890",
    "dynamic_context": {
      "caller_name": "Test Caller"
    }
  }'
â„šī¸

Outbound calls require telephony credentials configured on the agent. See the Telephony page for setup instructions.


View Active Sessions

BASH
# List all active sessions
curl https://ultravoice.us.inc/api/v1/sessions/active \
  -H "Authorization: Bearer $TOKEN"

# End a session
curl -X POST https://ultravoice.us.inc/api/v1/voice/sessions/{session_id}/end \
  -H "Content-Type: application/json"

JavaScript Voice Client

JAVASCRIPT
const API = "https://ultravoice.us.inc/api/v1";

async function startVoiceTest(agentId) {
  const res = await fetch(`${API}/voice/sessions/start`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ agent_id: agentId, user_id: "test" }),
  });
  const { session_id } = await res.json();

  const ws = new WebSocket(`wss://ultravoice.us.inc/api/v1/voice/ws/${session_id}`);
  ws.binaryType = "arraybuffer";

  const stream = await navigator.mediaDevices.getUserMedia({
    audio: { sampleRate: 16000, channelCount: 1, echoCancellation: true },
  });
  const ctx = new AudioContext({ sampleRate: 16000 });
  const source = ctx.createMediaStreamSource(stream);
  const processor = ctx.createScriptProcessor(4096, 1, 1);
  source.connect(processor);
  processor.connect(ctx.destination);

  processor.onaudioprocess = (e) => {
    if (ws.readyState !== WebSocket.OPEN) return;
    const f32 = e.inputBuffer.getChannelData(0);
    const i16 = new Int16Array(f32.length);
    for (let i = 0; i < f32.length; i++) {
      i16[i] = Math.max(-32768, Math.min(32767, f32[i] * 32768));
    }
    ws.send(i16.buffer);
  };

  ws.onmessage = (e) => {
    if (e.data instanceof ArrayBuffer) {
      console.log("Audio chunk:", e.data.byteLength, "bytes");
    } else {
      const event = JSON.parse(e.data);
      console.log(`[${event.type}] ${event.text || ""}`);
    }
  };
  return ws;
}