Skip to content
Live WebSocket

Stream audio. Hear back every 2 seconds.

Send 16 kHz PCM from a microphone, a browser tab, a phone bridge or a server. Auscultare reads it in short overlapping stretches and answers as you go: each stretch, a rolling answer, and an alert when the voice turns not original.

WSwss://auscultare.io/api/v1/livelive
  1. ready{"sessionId":"0b9e4c1a-7d3f-4e2b-a5c6-1f8e9d7c6b5a","model":{"name":"TrueSound","version":"2.1","demo":false},"windowSec":4,"hopSec":2,"rollingWindows":6,"remainingSec":1740,"maxSessionSec":3600,"note":null}
  2. status{"state":"listening"}
  3. 4.0swindow{"index":0,"start":0,"end":4,"speech":0.82,"signal":0.21,"flag":false,"lean":null}
  4. 4.0srolling{"at":4,"label":"inconclusive","signal":null,"lean":null,"windows":1}
  5. 6.0swindow{"index":1,"start":2,"end":6,"speech":0.91,"signal":0.17,"flag":false,"lean":null}
  6. 6.0srolling{"at":6,"label":"original","signal":0.19,"lean":null,"windows":2}
  7. 18.0swindow{"index":7,"start":14,"end":18,"speech":0.88,"signal":0.79,"flag":true,"lean":"ai_generated"}
  8. 18.0srolling{"at":18,"label":"ai_generated","signal":0.68,"lean":0.81,"windows":6}
  9. 18.0salert{"at":18,"label":"ai_generated","signal":0.68,"alertId":"c4d2e9f1-5a6b-4c7d-8e9f-0a1b2c3d4e5f"}
  10. usage{"seconds":30,"remainingSec":1710}
Illustration: a fictional session, not a real reading.

In short

Open wss://…/api/v1/live with a ticket (browsers) or your key (servers), send a start message, then binary frames of 16 kHz mono PCM16. Every 2 seconds you get a window event and a rolling answer over the last stretches with speech; an alert fires when that answer turns not original. Audio is never stored.

How a session goes

  1. ConnectServers send the key as Authorization: Bearer on the upgrade. Browsers and the extension use a one-use ticket in the URL.
  2. Say startThe first message is JSON: start with the audio format. Frames sent before it are refused.
  3. StreamBinary frames of 16 kHz mono PCM16, little-endian, as the audio comes. 250 ms frames are a good size.
  4. Listenwindow for each stretch, rolling for the answer so far, alert when it turns not original.
  5. StopSend stop (or close the socket). end brings the session’s summary.
Each bar is one stretch read, coloured by its evidence (mint below the line, amber at it, red above). The bracket is the rolling answer: the last 6 stretches with speech.

One engine, four doors

The app, the API, the Chrome extension and phone calls all reach the same streaming engine. The first three speak the protocol on this page.

One engine, four doors
DoorURLSign-in
The app’s Live pagewss://auscultare.io/api/live?ticket=…The session cookie, through a ticket
Your codewss://auscultare.io/api/v1/liveBearer key (servers) or ticket (browsers)
The Chrome extensionwss://auscultare.io/api/v1/live?ticket=…Ticket from the extension’s key
Phone calls (Twilio)wss://auscultare.io/api/telephony/twilio/<token>The connector’s secret URL

Tickets for browsers

A browser cannot set headers on a WebSocket and must never hold a key. Your server asks POST /api/v1/live/tickets with the key and hands the page the ticket: it works once, within 60 seconds.

Your server (Express): the key stays here, the page gets a one-use ticket

app.post('/auscultare/ticket', async (req, res) => {
  // Check your own user's session first: whoever gets a ticket can listen on your workspace's allowance.
  const r = await fetch('https://auscultare.io/api/v1/live/tickets', {
    method: 'POST',
    headers: { Authorization: `Bearer ${process.env.AUSCULTARE_KEY}` },
  });
  res.status(r.status).json(await r.json()); // { ticket, url, expiresAt }: one use, valid 60 s
});

The start message

The start message
FieldTypeMeaning
type"start"Always start.
sampleRate16000Always 16000.
encoding"pcm_s16le"Always pcm_s16le.
channels1Always 1 (mono).
labelstring?What is being listened to, up to 120 characters (“Team call”). Shown in History.
inputstring?microphone, tab, file, phone or other. For display.
modelstring?A model id from GET /models; the default when left out.
windowsboolean?false sends only rolling, alert and end events. Default true.

Any other format answers an error with bad_format.

The start message
{
  "type": "start",
  "sampleRate": 16000,
  "encoding": "pcm_s16le",
  "channels": 1,
  "label": "Team call",
  "input": "microphone",
  "model": "truesound-2.1",
  "windows": true
}

Audio frames

  • Signed 16-bit little-endian PCM, mono, 16000 Hz, in binary frames.
  • Any length up to 64 KB a frame; 100 ms to 1 s is typical.
  • Send as the audio comes, in real time.
  • Send the start message within 15 seconds of opening the socket.
  • 30 seconds without audio end the session (idle_timeout).
  • A session lasts up to 60 minutes (60 seconds with a development key); start a new one right after.
  • Sessions at once per workspace, every door and every phone track included: Free 3, Pro 10, Enterprise 50.

Timing

  • The protocol reads stretches of 4 s, one every 2 s, once 4 s have arrived.
  • The rolling answer covers the last 6 stretches with speech, about 14 s of audio: the same reading a file scan gives a clip of that length. It stays inconclusive until 2 stretches with speech have arrived.
  • A stretch with under 30% speech, or under half a second of it, is not scored (its signal is null).
  • An alert fires when the rolling answer turns not original, and again only after it went back to original or after 60 s.
  • After a quiet spell the model takes about 25 s to start: status: waking_model, and your audio is kept and read as soon as it is up.

Events

JSON text frames, one event each.

Events
EventWhen
readyThe session is open: its id, the model, the timing, the seconds you may still use and the longest it may run.
statuswaking_model while the model starts, then listening.
windowOne stretch read: start, end, its share of speech, signal (null with too little speech), flag and lean.
rollingThe answer over the last stretches with speech: label (inconclusive until enough speech), signal, lean.
alertThe rolling answer turned not original. Also sent to your webhooks as live.alert.
usageEvery 10 s: seconds used in this session and seconds left this month.
errorA code, a message and recoverable: false means the server closes next.
endWhy the session ended and its summary: the answer over the whole session, like a file scan.
Illustration: a fictional session, not a real reading.
{"type":"ready","sessionId":"0b9e4c1a-7d3f-4e2b-a5c6-1f8e9d7c6b5a","model":{"name":"TrueSound","version":"2.1","demo":false},"windowSec":4,"hopSec":2,"rollingWindows":6,"remainingSec":1740,"maxSessionSec":3600,"note":null}
{"type":"status","state":"listening"}
{"type":"window","index":0,"start":0,"end":4,"speech":0.82,"signal":0.21,"flag":false,"lean":null}
{"type":"rolling","at":4,"label":"inconclusive","signal":null,"lean":null,"windows":1}
{"type":"window","index":1,"start":2,"end":6,"speech":0.91,"signal":0.17,"flag":false,"lean":null}
{"type":"rolling","at":6,"label":"original","signal":0.19,"lean":null,"windows":2}
{"type":"window","index":7,"start":14,"end":18,"speech":0.88,"signal":0.79,"flag":true,"lean":"ai_generated"}
{"type":"rolling","at":18,"label":"ai_generated","signal":0.68,"lean":0.81,"windows":6}
{"type":"alert","at":18,"label":"ai_generated","signal":0.68,"alertId":"c4d2e9f1-5a6b-4c7d-8e9f-0a1b2c3d4e5f"}
{"type":"usage","seconds":30,"remainingSec":1710}

Error codes

Error codes
CodeMeaning
unauthorizedNo key or ticket, or one that is not valid (or a ticket used twice).
bad_formatThe start message asks for a format other than 16 kHz mono PCM16.
not_startedAudio arrived before the start message.
frame_too_largeA frame over 64 KB.
quota_exceededThe month’s live minutes are used up; the session ends.
plan_requiredThe plan has no live listening.
too_many_sessionsToo many sessions at once in this workspace.
session_too_longThe session reached 60 minutes.
idle_timeoutNo audio for 30 seconds.
detector_unavailableThe detector could not answer.
internalSomething broke on our side.

Clients

A microphone in the browser, a file streamed from Node.js, the same from Python. Turn browser noise suppression off: it changes real voices, and real speech through strong noise suppression is wrongly flagged more often.

live.js · a microphone, read as you speak

const WORKLET = `class Pcm16 extends AudioWorkletProcessor {
  constructor() {
    super();
    this.step = sampleRate / 16000; // e.g. 3 at 48 kHz
    this.pos = 0; this.sum = 0; this.count = 0;
    this.out = new Int16Array(4000); this.n = 0; // 250 ms
  }
  process(inputs) {
    const input = inputs[0][0];
    if (!input) return true;
    for (let i = 0; i < input.length; i++) {
      this.sum += input[i]; this.count++;
      if (++this.pos >= this.step) {
        this.pos -= this.step;
        const s = Math.max(-1, Math.min(1, this.sum / this.count));
        this.sum = 0; this.count = 0;
        this.out[this.n++] = s < 0 ? s * 0x8000 : s * 0x7fff;
        if (this.n === this.out.length) {
          this.port.postMessage(this.out.buffer, [this.out.buffer]);
          this.out = new Int16Array(4000); this.n = 0;
        }
      }
    }
    return true;
  }
}
registerProcessor('pcm16', Pcm16);`;

export async function listen({ onRolling, onAlert } = {}) {
  // 1. A one-use ticket from YOUR server (never put an API key in a page).
  const { url } = await (await fetch('/auscultare/ticket', { method: 'POST' })).json();

  // 2. The microphone. Browser noise suppression changes real voices: turn it off.
  const media = await navigator.mediaDevices.getUserMedia({
    audio: { channelCount: 1, noiseSuppression: false, echoCancellation: false, autoGainControl: false },
  });
  const ctx = new AudioContext();
  await ctx.audioWorklet.addModule(URL.createObjectURL(new Blob([WORKLET], { type: 'text/javascript' })));
  const source = ctx.createMediaStreamSource(media);
  const pcm = new AudioWorkletNode(ctx, 'pcm16');
  const mute = new GainNode(ctx, { gain: 0 });
  source.connect(pcm).connect(mute).connect(ctx.destination);

  // 3. The socket: "start" first, then binary frames of 16 kHz PCM16.
  const ws = new WebSocket(url);
  ws.binaryType = 'arraybuffer';
  let ready = false;
  ws.onopen = () => ws.send(JSON.stringify({ type: 'start', sampleRate: 16000, encoding: 'pcm_s16le', channels: 1, input: 'microphone', label: 'Browser' }));
  pcm.port.onmessage = (e) => ready && ws.readyState === WebSocket.OPEN && ws.send(e.data);

  ws.onmessage = (e) => {
    const ev = JSON.parse(e.data);
    if (ev.type === 'ready') ready = true;
    else if (ev.type === 'status') console.log(ev.state); // waking_model, then listening
    else if (ev.type === 'rolling') onRolling?.(ev.label, ev.signal); // the answer over the last ~14 s of speech
    else if (ev.type === 'alert') onAlert?.(ev);
    else if (ev.type === 'error' && !ev.recoverable) console.error(ev.code, ev.message);
    else if (ev.type === 'end') console.log('session', ev.reason, ev.summary.label);
  };

  return function stop() {
    if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: 'stop' }));
    media.getTracks().forEach((t) => t.stop());
    void ctx.close();
  };
}

Nothing is recorded

Live audio is never stored. Only the events and the session’s summary are kept, without audio, for GET /api/v1/live/sessions. Usage counts the seconds streamed against the workspace’s live minutes.

Live listening is on Free, Pro, and Enterprise.