API referenceStream live audio
Stream live audio
A WebSocket session: configuration, audio, and the messages Audrey sends back.
WSSwss://api.p99lab.com/v1/stream
Configuration message
The first message after connecting: one JSON text message, within 10 seconds. Every field is optional.
languagestringdefault en
Audrey serves English: en.
sample_rateintegerdefault 16000
Rate of the PCM you send: 8000, 16000, 24000 or 48000.
formatbooleandefault true
Written forms in finals. Partials are always plain words.
promptstringoptional
Context for the call, up to 500 characters; longer text is cut.
endpoint_msintegerdefault 1500
Pause that ends an utterance, in milliseconds. Values are kept within 200 to 3000.
partial_msintegerdefault 300
How often a partial is produced while someone speaks, in milliseconds. Values are kept within 250 to 5000.
turn_detectionbooleandefault true
End utterances when turn-1-mini decides the speaker has finished, and send turn_end.
See turn detection.
keystringoptional
Your API key, if the client cannot send the Authorization header.
Configuration
{
"language": "en",
"sample_rate": 16000,
"format": true,
"endpoint_ms": 1500
}
Audio
Binary messages of raw 16-bit little-endian PCM, mono, at the configured sample rate, up to 64 KB each. Send audio as it is captured, at real-time speed: more than 5 s of unprocessed audio ends the session.
Messages you send
{"type": "flush"}
Finalise the current utterance now. Ignored with less than 0.2 s of open speech.
{"type": "end"}
No more audio. Audrey finalises what it has, sends done and closes.
Audio at 16 kHz, 20 ms per message
320 samples × 2 bytes = 640 bytes
Messages you receive
JSON text messages with a type. Times are seconds from the start of the stream.
partial
textstring
The utterance so far, plain words. Replaces the previous partial.
startnumber
Start of the utterance.
decode_msinteger
Server time spent on this message.
final
textstring
The finished utterance, with written forms when format is on. Can be empty.
start, endnumber
Start and end of the utterance.
decode_msinteger
Server time spent on this message.
turn_end
probabilitynumber
Confidence that the turn is over, 0 to 1.
atnumber
Seconds of audio received at the decision.
done
audio_secondsnumber
Audio received in the session. Sent once, after end, when every final has been delivered; then the socket closes. Other fields may appear; ignore them.
error
messagestring
What went wrong. The socket closes right after.
codeintegeroptional
402, 429 or 503 for account and billing errors.
top_up_url, plans_urlstringoptional
With a 402: the console's billing page.
audio_secondsnumberoptional
When billing stops an open stream: audio received.
Messages, in order
{"type": "partial", "text": "Can you move it to", "start": 4.1, "decode_ms": 38}
{"type": "final", "text": "Can you move it to Thursday?", "start": 4.1, "end": 5.86, "decode_ms": 132}
{"type": "turn_end", "probability": 0.912, "at": 6.12}
{"type": "done", "audio_seconds": 9.4}
Error
{"type": "error", "message": "audio message larger than 64 KB"}
Limits
Configuration within 10 s; audio messages up to 64 KB; at most 5 s of unprocessed audio; sessions up to 2 hours. Self-serve keys can hold 4 streams open at once. Every error message is in errors and limits.