Audio Formats
By default, the server expects 16-bit signed little-endian PCM, 16 kHz, mono. If your audio is in that format, just send it.
For any other format, send one AudioConfig message as the first text message on the connection, before any audio:
Then send the audio as binary frames. The server converts every supported format before transcription, so you don’t need to convert audio yourself.
Send exactly one AudioConfig per connection, and send it before any audio. To use a different format, open a new connection.
Supported formats
Telephony
Most telephony platforms stream call audio as 8 kHz G.711. Declare it as-is:
8 kHz µ-law
8 kHz A-law
Common in North America and Japan, and the default on many cloud telephony platforms.
Many telephony media streams deliver audio as base64 text inside JSON events. Decode the base64 and send the raw bytes as a binary frame. Do not forward the provider’s JSON event.
Full telephony session
The server sends the turn’s final transcript. The connection stays open for the next turn.
Web and mobile audio
Opus (WebRTC)
PCM at 44.1 kHz
PCM at 16 kHz (default)
Send each Opus packet as its own binary frame. Do not combine several packets into one frame, and do not send Ogg or WebM container data, such as the output of the browser’s MediaRecorder.
Format errors
If codec, sample_rate or channels is invalid, a binary frame cannot be decoded, or a text frame is not a JSON object, the server sends an Error message and closes the connection with code 4002.
If your source audio uses a sample rate that isn’t listed, such as 22.05 kHz, resample it to a supported rate before sending.
See Errors for every close code.