WSS/v2/room
Send the room's mixed audio as one source. Baton separates the voices (up to 8),
transcribes each voice on its own, identifies each voice's language, and reports turn
events for the room as a whole (speaker: "room").
Transcripts. Each voice gets asr.partial for its newest, still-changing word and
asr.final for words that will not change. A word becomes final as soon as the
speaker says another word, after about a second without change, or when you send
finalize.
Turn boundaries. When your own turn logic decides a speaker has finished, send
finalize. Every voice's pending word is emitted as asr.final, followed by
asr.flushed. Cut your segments on asr.flushed, not on turn.end.
Languages. When a voice is clearly speaking another language from your
allowed list, its transcription switches to that language; each asr.final says
which language it is in. Without an allowed list Baton only warns (warning with
code: language_mismatch). Add language to signals for the language events.
Same session options as the streams: signals (vad, bargein, and in rooms
partials and language), agent.speech, keywords, idle_timeout_s, eot, and
messages (the conversation so far, used to judge whether an utterance is
complete, as on /v2/stream).
When rooms are at capacity the start closes with 1013; retry with backoff.
speaker: "room".Show Session, Audio, Speech and turns, Barge-in
Session
Open, configure and close the session.
session.startyou sendThe first frame of a room. The same options as a stream's session.start.
Rejections close with 1008 (the same reasons as a stream's session.start,
or unsupported language '<code>' when the room's transcriber can't serve a
language) or 1013 when rooms are at capacity or temporarily unavailable
(retry with backoff).
| Field | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type required | "session.start" | ||||||||||||||||
api_key required | string | ||||||||||||||||
mode | "transactional_call" | "working_session" | "one_on_one" | "brainstorm" | "formal" | Default | |||||||||||||||
eot | object | Choose an end-of-turn operating point by name, or by the mean latency you can
afford (the closest of the
English figures,
| |||||||||||||||
language | one of: Pinned, Allowed set, Automatic | The language the user speaks. Telling Baton improves quality; if they may speak
one of several, an allowed list is still better than nothing.
Default | |||||||||||||||
signals | array of "vad" | "bargein" | "partials" | "language" | Optional event families to receive besides the turn events and
asr.final, which every room gets:
| |||||||||||||||
keywords | object | Words that interrupt your agent at once, said over it ( | |||||||||||||||
echo | "on" | "off" |
| |||||||||||||||
idle_timeout_s | number | Close after this many seconds without speech. 0 or less disables it. Default | |||||||||||||||
inference_interval | number | Leave it at 0.1; other values void the published numbers and timings. Default | |||||||||||||||
messages | array of object | Conversation so far, used to judge whether an utterance is complete. Read once, at |
An English meeting that may switch to Spanish or French speakers.
{
"type": "session.start",
"api_key": "baton_0123456789abcdef0123456789abcdef0123456789abcdef",
"eot": {"profile": "cutoff_5pct"},
"language": {"allowed": ["en", "es", "fr"]},
"signals": ["vad", "bargein", "partials"],
"idle_timeout_s": 900
}
session.startedyou receiveThe room is open and the transcriber is ready.
| Field | Type | Description |
|---|---|---|
type required | "session.started" | |
schema_version required | 2 | The protocol version, sent once per connection on |
session_id required | string | |
signals required | array of "vad" | "bargein" | "partials" | "language" | The optional event families this room receives, as you asked for them (in this order). |
eot required | object | The policy this session uses. |
echo | "on" | "off" | Whether Baton ignores your agent's echo in this session, as |
models | object | Present when |
{
"type": "session.started",
"schema_version": 2,
"session_id": "8b1e4f2a9c3d4e7f8a1b2c3d4e5f6a7b",
"signals": ["vad", "partials"],
"eot": {
"profile": "cutoff_5pct",
"rule": "score_point",
"action_delay_ms": 300,
"timeout_ms": 3000,
"overridden": [],
"mean_latency_ms": 563,
"cutoff_rate": 0.0482
}
}
warning (idle_timeout)you receiveNo speech for a while. The session will close soon.
Sent before an idle close (idle_timeout_s, default 600 s). Speech resets the
timer. The close is code 1000 with reason idle_timeout.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "warning" | |
code required | "idle_timeout" | |
close_in_s required | number | Seconds until the idle close. |
{
"type": "warning",
"seq": 40,
"code": "idle_timeout",
"close_in_s": 30.0
}
session.endyou sendEnd the session. Baton replies with session.summary and closes with 1000.
| Field | Type | Description |
|---|---|---|
type required | "session.end" |
{"type": "session.end"}
session.summaryyou receiveTotals for the session. Sent in reply to session.end.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "session.summary" | |
audio_s required | number | Seconds of audio received. |
turns required | integer | Turn ends |
{
"type": "session.summary",
"seq": 41,
"audio_s": 312.4,
"turns": 18
}
Audio
16 kHz mono PCM16 in binary frames.
audioyou sendOne binary frame of audio.
A binary WebSocket frame: one leading byte (send 0; it identifies the source
and is reserved for multi-source sessions), then signed 16-bit little-endian PCM,
mono, 16 000 Hz. Any whole number of samples per frame; 80–100 ms (1280–1600
samples) is typical. Resample on the client: other rates are not accepted. A frame
whose PCM part is an odd number of bytes (e.g. no source byte) closes the session
with 1008 audio frame must be a source byte and 16-bit PCM.
Binary frame. [u8 source = 0][PCM16LE mono 16 kHz samples...]
Speech and turns
When people speak, pause and finish, what they answered, and what may have been missed.
vad.startyou receiveSomeone in the room started speaking. With vad in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "vad.start" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker | "room" |
vad.endyou receiveThe room went quiet. With vad in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "vad.end" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker | "room" | |
duration | number |
turn.endyou receiveThe room's current turn has ended.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.end" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker | "room" | |
p_eot | number | Probability, from 0 to 1, that the user has finished their turn, at the moment the turn ended. With |
latency_ms | integer | |
by | "score" | "timeout" | |
profile | string | |
hint | object | Baton heard speech in this turn but no clear words. |
answer | object or null | Which of your |
turn.resumedyou receiveSpeech resumed within 2 s of turn.end.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.resumed" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker | "room" | |
after_ms | integer |
turn.answeryou receiveWhich of your expected answers the user gave in the turn that just ended.
The result for a turn that followed an agent.speech with expect. It comes on
the turn.end itself when ready; otherwise in this event, typically 2–3 s after
the turn.end (occasionally about 4 s, never more than 6 s). turn_t is that
turn.end's t: match on it. At most one per turn end. A turn.resumed cancels
it with its turn end, and the answer comes again with the next turn.end. An
answer still pending at session.end is not sent: wait for it before ending the
session.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.answer" | |
turn_t required | number | The |
answer required | object or null | Which of your |
{
"type": "turn.answer",
"seq": 5,
"turn_t": 3.0,
"answer": {
"match": "feel good",
"score": 0.91,
"runner_up": "feel bad",
"scores": {"feel good": 0.91, "feel bad": 0.06, "none": 0.03}
}
}
turn.hintyou receiveBaton's best guess at words it heard in the turn that just ended.
Baton heard speech in a turn but no clear words. The hint is its best guess at
what was said. It comes on the turn.end itself when ready; otherwise in this
event, typically 2–3 s after the turn.end (occasionally about 4 s, never more
than 6 s). turn_t is that turn.end's t: match on it. At most one per turn
end, and none when every word was heard. A turn.resumed cancels it with its
turn end. A hint still pending at session.end is not sent. Never logged or
stored.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "turn.hint" | |
turn_t required | number | The |
hint required | object | Baton heard speech in this turn but no clear words. |
{
"type": "turn.hint",
"seq": 4,
"turn_t": 3.0,
"hint": {
"suspect": "speech_without_words",
"text": "Yes.",
"certainty": "low"
}
}
Barge-in
Speech over your agent: a real interruption, or a backchannel.
agent.speechyou sendTell Baton what your agent is saying, and when.
Telling Baton what your agent says makes its predictions better exactly where they are hardest: quiet users, noisy rooms, speakerphones, and short one-word answers.
- Your agent's own voice is ignored. When the user hears your agent through
a speaker, the microphone picks it up again. With
text(andduration_s) orwords, Baton knows that sound is your agent: it opens no turn and never stops your agent, while the user's own words still do. - Answers you expect are recognised. With
expecton the question, Baton tells you which answer the user gave, with a confidence, so your agent can act on it at once (answeronturn.end, orturn.answer). - Barge-in.
startandendtell Baton when your agent is talking, so speech over it is reported (bargein.onset,bargein.class).
Send start before your agent's audio can reach the user's microphone, and end
when it stops. Every field but phase is optional. A malformed field closes the
session with 1008 (see Errors and limits). A phase other than start or end
is ignored.
| Field | Type | Description |
|---|---|---|
type required | "agent.speech" | |
phase required | "start" | "end" | |
utterance_id | string | Your id for the agent utterance. Echoed on barge-in events (null when you sent none). |
text | string | What the agent says. With |
duration_s | number | How long the utterance plays, in seconds. Accepted on |
words | array of object | Instead of |
expect | array of string |
|
{
"type": "agent.speech",
"phase": "start",
"utterance_id": "sp_1"
}
{
"type": "agent.speech",
"phase": "end",
"utterance_id": "sp_1"
}
bargein.onsetyou receiveThe user started speaking while your agent was talking.
Sent when the speech starts. bargein.class follows with the decision. Your
agent's own voice coming back through the user's speaker never opens one.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "bargein.onset" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
agent_speaking required | true | |
utterance_id | string or null |
{
"type": "bargein.onset",
"seq": 7,
"t": 12.1,
"agent_speaking": true,
"utterance_id": "sp_1"
}
bargein.classyou receiveWhether the interruption claims the floor or is a backchannel.
claim means the user wants to talk: stop or yield. backchannel ("mm-hmm",
"right") means keep talking. Decided as soon as Baton is confident, typically a few
hundred milliseconds into the interruption. p_claim is the probability, from 0
to 1, that the user is taking the floor; it is null when the user stopped too
soon to judge (reported as a backchannel) and on a claim decided by a word.
A stop word ("stop", "wait", "hold on"), a floor grab ("no", "actually") or one
of your answer words decides a claim at once. Such a claim carries text (the
word or phrase, as in your list) and intent (stop or answer). It can follow
a backchannel for the same interruption, and it comes with its own
bargein.onset when none was open. One per agent utterance. Your agent's own
voice saying "stop" never triggers it.
Rooms only: confirmed_by: two_speakers marks a stop said by someone in the room
over your agent's own "stop".
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "bargein.class" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
class required | "claim" | "backchannel" | |
text | string | On a claim decided by a word: the stop word, floor grab or answer heard, as in your list (or Baton's). Absent otherwise. |
intent | "stop" | "answer" | With |
confirmed_by | "two_speakers" | Rooms, with |
p_claim required | number or null | Probability, from 0 to 1, that the user is taking the floor (1 = certainly a claim, 0 = certainly a backchannel). Null when the user stopped too soon to judge, and on a claim decided by a word, which needs no probability. |
decided_after_ms required | integer | Milliseconds from the onset to this decision. |
utterance_id | string or null |
{
"type": "bargein.class",
"seq": 8,
"t": 12.4,
"class": "claim",
"p_claim": 0.9,
"decided_after_ms": 300,
"utterance_id": "sp_1"
}
{
"type": "bargein.class",
"seq": 9,
"t": 15.2,
"class": "claim",
"text": "stop",
"intent": "stop",
"p_claim": null,
"decided_after_ms": 100,
"utterance_id": "sp_2"
}
Transcripts
Per-speaker words, and clean cuts at turn boundaries.
finalizeyou sendFinalise every voice's pending word now (a turn boundary you decided).
Baton emits each voice's pending newest word as asr.final, then asr.flushed.
Without it, a speaker's last word waits up to 1 s and can land after you have
already cut the segment ("...in Saint" / "Paul").
| Field | Type | Description |
|---|---|---|
type required | "finalize" |
{"type": "finalize"}
asr.partialyou receiveA voice's newest word or words, still subject to change. With partials in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "asr.partial" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker required | string | A voice in the room, numbered in order of first appearance. Stable for the session. |
text required | string | The voice's newest word or words not yet final. Replaces the previous partial for this voice. |
language required | string | The language this voice is decoded in. |
{
"type": "asr.partial",
"seq": 2,
"t": 3.2,
"speaker": "spk_1",
"text": "I",
"language": "en"
}
asr.finalyou receiveWords from one voice that will not change.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "asr.final" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker required | string | A voice in the room, numbered in order of first appearance. Stable for the session. |
text required | string | Final words. Append to the voice's transcript. |
t0 required | number | When the first of these words was first heard (seconds). |
t1 required | number | When the last of these words was first heard (seconds). |
language required | string |
{
"type": "asr.final",
"seq": 4,
"t": 3.52,
"speaker": "spk_1",
"text": "I never",
"t0": 3.2,
"t1": 3.52,
"language": "en"
}
asr.flushedyou receiveEvery word pending at your finalize has been sent. Safe to cut segments.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "asr.flushed" |
{"type": "asr.flushed", "seq": 6}
Languages
Each voice's language, and switching within your allowed set.
asr.languageyou receiveThe language Baton hears one voice speaking. With language in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "asr.language" | |
t required | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker required | string | A voice in the room, numbered in order of first appearance. Stable for the session. |
language required | string | |
confidence required | number |
{
"type": "asr.language",
"seq": 30,
"t": 15.36,
"speaker": "spk_0",
"language": "en",
"confidence": 0.9981
}
warning (language_mismatch)you receiveA voice sounds like a different language and the room has no allowed list.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "warning" | |
code | "language_mismatch" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker | string | A voice in the room, numbered in order of first appearance. Stable for the session. |
language | string |
language.switchedyou receiveA voice is now transcribed in another language from your allowed list. With language in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "language.switched" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker | string | A voice in the room, numbered in order of first appearance. Stable for the session. |
language | string | |
model | string | Diagnostic; may change or be removed. |
{
"type": "language.switched",
"seq": 52,
"t": 41.6,
"speaker": "spk_2",
"language": "es"
}
language.switch_recommendedyou receiveA voice is speaking a language from your allowed list that this room can't switch its transcript to. With language in signals.
That voice's asr.final keeps coming in the room's current language, so its words
may be poor. Turn events are unaffected. To get a good transcript of that voice,
start a new room with language set to include it: pin it if that person is the
one you need, or put it first in allowed if most of the room speaks it.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "language.switch_recommended" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speaker | string | A voice in the room, numbered in order of first appearance. Stable for the session. |
language | string |
language.summaryyou receiveSeconds of speech per voice per language. Sent at the end, with language in signals.
| Field | Type | Description |
|---|---|---|
seq required | integer | Event sequence number. Starts at 1 and increases by one per event. |
type required | "language.summary" | |
t | number | Audio time in seconds since the session's first sample. Not always increasing across events; |
speakers | object | {voice: {language: seconds of solo speech}} |
{
"type": "language.summary",
"seq": 900,
"t": 1802.24,
"speakers": {
"spk_0": {"en": 512.0},
"spk_1": {"en": 301.0, "es": 12.0}
}
}