# Sending audio

Raw audio in binary frames at the pace of real time: how much per frame, and the formats a session takes.

- **Binary frames** hold raw audio: not a WAV or MP3 file but its samples, in the `encoding` and at the `sample_rate` you declared.
- **100 ms of audio per frame** gives the lowest latency. The API recognizes speech in steps of 0.64 s and starts each step as soon as its audio, and a little more, has arrived: with longer frames a step waits for the rest of the frame. There is no minimum, and a frame need not hold whole samples.
- **At most 1 s of audio per frame** (of both channels with `multichannel`). More ends the session with `audio_chunk_too_large`, close 1009. A WebSocket message over 1 MiB closes the connection with 1009 at once, without an `error` message.
- **Send at the pace of real time,** as a microphone would: a file sent faster gives no faster results. The API reads at most 1000 binary frames and 20 text messages a second (more are read later, never refused), and stops reading a client that is more than 20 s of audio ahead.
- **Keep the session alive.** After 15 seconds without any audio or message, the session ends with `idle_timeout`. While your source is paused or muted, send silence or `{"type": "ping"}` (answered with `{"type": "pong"}`).

## Audio formats

The last column is the size of a 100 ms frame, the size with the lowest latency.

| encoding, sample_rate | Samples | 100 ms of audio |
|---|---|---|
| `pcm_s16le, 16000` | 16-bit signed little-endian, mono | 3,200 bytes |
| `pcm_s16le, 8000` | the same | 1,600 bytes |
| `pcm_s16le, 22050 / 24000` | the same | 4,410 / 4,800 bytes |
| `pcm_s16le, 44100 / 48000` | the same | 8,820 / 9,600 bytes |
| `pcm_f32le, any rate` | 32-bit little-endian floats, -1 to 1, mono | twice the `pcm_s16le` size: 6,400 bytes at 16000 |
| `mulaw, 8000` | telephone mu-law, one byte per sample | 800 bytes |
| `alaw, 8000` | telephone A-law (European phone lines), one byte per sample | 800 bytes |
| two channels (`multichannel=true`) | the same samples, left and right interleaved | twice the size: `pcm_s16le` at 16000 6,400 bytes, `mulaw` or `alaw` 1,600 bytes |

- The API converts every format to 16 kHz for recognition; 16 kHz needs no conversion.
- Mix stereo down to mono before sending, unless each channel is one side of a call (`multichannel=true`).
- An odd byte at the end of a PCM frame, or half a two-channel sample, waits for the next frame.
