DocumentationQuickstart

Speech-to-Speech (STS)

Conversational speech-to-speech — the caller speaks, the agent replies with voice in real time. This is the same stack as Live talk and the dashboard Live talk studio.

STS is delivered over a WebSocket, not the REST /v1/audio/* endpoints used for TTS and STT.

Endpoints

PurposeURL
WebSocketwss://platform.oogam.in/v1/realtime
Session metaGET https://platform.oogam.in/api/naad/sts/v1/realtime/session
VoicesGET https://platform.oogam.in/api/naad/sts/voices
LanguagesGET https://platform.oogam.in/api/naad/sts/languages

Everything terminates on the platform: your clients only ever talk to platform.oogam.in. Each WebSocket connection is its own isolated realtime session — audio and events are never mixed across connections.

Authentication

STS uses the same platform API key (sk-setu-…) as REST TTS/STT — with the naad product enabled and credit in the project wallet. Pass it as a Bearer header:

text
Authorization: Bearer sk-setu-…

Browser WebSockets cannot set headers, so browser clients may pass the key as a query param instead:

text
wss://platform.oogam.in/v1/realtime?api_key=sk-setu-…

Connections are metered per actual connection second and billed to the key's project wallet at the naad-sts-v1 per-minute rate — same as Live talk in the dashboard.

Audio formats

DirectionFormat
Client → server (mic)Binary WS frames · PCM16 LE mono @ 16 kHz
Server → client (agent)Binary WS frames · PCM16 LE mono @ 24 kHz

JSON control events share the same WebSocket.

Important differences from REST TTS/STT

  • Language codes are 2-letter (hi, en, mr) — not HIN / ENG.
  • Voice ids are f1, m1, … — not aditi / arjun. List them via GET /api/naad/sts/voices.

Call flow

  1. GET /api/naad/sts/v1/realtime/session — confirm protocol
  2. Open the WebSocket
  3. Send set_lang then set_voice
  4. Wait for voice_ack
  5. Send start_utterance
  6. Stream mic PCM continuously as binary frames
  7. Handle state, stt, reply, and binary agent audio
  8. On hang-up: stop_utterance / close the socket

Client → server events

json
{"type":"set_lang","value":"hi"}
{"type":"set_voice","voice":"f1"}
{"type":"set_context","system":"You are a helpful support agent…","kb_id":"kb_1","temperature":0.3}
{"type":"start_utterance"}
{"type":"stop_utterance"}
{"type":"reset"}
EventPurpose
set_langPin language. Prefer a real code over auto for turn 1.
set_voicePin voice (f1 = Aditi, m1 = Arjun, …)
set_contextOptional system prompt / KB grounding (≤ 8000 chars)
start_utteranceBegin listening
stop_utteranceEnd or cancel the current turn
resetClear conversation history (keeps voice / lang / context)

Server → client events

EventMeaning
stateidle | listening | thinking | speaking
voice_ackVoice pin accepted
context_ackContext pin accepted
sttTranscript. If replace: true, overwrite the last user line instead of appending.
lang_hintOptional hint that the caller may be speaking another language — show a switch prompt; never auto-switch.
replyAgent text for the turn
interruptedCaller barged in — stop local playback
endTurn finished
errorError with code / detail
binary framesAgent audio PCM16 @ 24 kHz

Inspect the protocol

bash
curl -sS "https://platform.oogam.in/api/naad/sts/v1/realtime/session"
curl -sS "https://platform.oogam.in/api/naad/sts/voices"
curl -sS "https://platform.oogam.in/api/naad/sts/languages"

Node example

ts
import WebSocket from "ws";

const ws = new WebSocket("wss://platform.oogam.in/v1/realtime", {
  headers: { Authorization: `Bearer ${process.env.SETU_API_KEY}` },
});

ws.on("open", () => {
  ws.send(JSON.stringify({ type: "set_lang", value: "hi" }));
  ws.send(JSON.stringify({ type: "set_voice", voice: "f1" }));
});

ws.on("message", (data, isBinary) => {
  if (isBinary) {
    // PCM16 LE mono @ 24 kHz — play to speaker
    return;
  }
  const msg = JSON.parse(data.toString());
  if (msg.type === "voice_ack") {
    ws.send(JSON.stringify({ type: "start_utterance" }));
    // then stream mic as binary PCM16 LE mono @ 16 kHz
  }
  if (msg.type === "stt") {
    console.log("user:", msg.text ?? msg.value, msg.replace ? "(replace)" : "");
  }
  if (msg.type === "reply") {
    console.log("agent:", msg.text ?? msg.value);
  }
});

Builtin voices

IdNameGender
f1AditiFemale
f2KavyaFemale
f3MeeraFemale
f4IshaFemale
m1ArjunMale
m2KabirMale
m3RohanMale
m4VikramMale

Offline re-voice (not conversational STS)

To re-voice a recorded file without a live call, use the REST voice changer instead:

bash
curl https://platform.oogam.in/v1/audio/voice-changer \
  -H "Authorization: Bearer $SETU_API_KEY" \
  -F model="naad-s2s-v1" \
  -F voice="arjun" \
  -F file="@speech.wav" \
  --output changed.wav

See also Audio & Voice for TTS and STT.