Skip to main content
Realtime STT accepts raw audio only: the audio bytes, with no file header. To stream a WAV file, send the samples inside it, not the file itself. This Realtime STT example shows how. The encoding and sample rate can’t be detected from the audio data, so pass both as query parameters. Match them to whatever your upstream pipeline already produces, such as microphone capture, a telephony stream, or ML model output.

Parameters

For the full parameter list, see the API reference for Realtime STT (Auto) and Realtime STT (Manual).
string
How each audio sample is stored, for example as 16-bit integers, 32-bit floats, or compressed telephony audio.
number
The sample rate of the input audio in Hz, from 8,000 to 48,000. Must match the actual sample rate of the audio you send.
Unlike the realtime endpoints, Batch STT also accepts containerized audio, such as wav and mp3.For Batch STT, set encoding and sample_rate only when you upload raw audio. Realtime STT always requires both.

Cheat sheet

As a rule of thumb, start with the row that matches your audio source:

Telephony

North America and Japan

Many customers send their audio over Twilio. Twilio transcodes all audio it carries to µ-law encoding with an 8 kHz sample rate.

Europe, India, and others

The standard for European and international telephone networks (G.711A) is 8-bit A-law compressed PCM with an 8 kHz sample rate.

Voice agent platforms

Many voice agent platforms use pcm_s16le at a 16 kHz sample rate in their pipeline. Confirm what your platform uses.

Web browsers

When you capture microphone audio through the Web Audio API, the samples are pcm_f32le. That’s because an AudioContext, and the AudioWorklet nodes you read frames from, always produce 32-bit floats. The capture sample rate defaults to whatever the user’s input hardware reports, commonly 48 kHz but sometimes 44.1 kHz. Read it from AudioContext.sampleRate and send the same value:
Speech recognition gains little from rates above 16 kHz, so downsampling to pcm_s16le at 16 kHz before you send cuts bandwidth with negligible impact on accuracy.

Double check your parameters

The model decodes your bytes using the encoding and sample_rate you declared in the connection. If these parameters are wrong, the server might not return an error. To check them, save your audio data and play it back with ffplay:
If the playback sounds wrong, your encoding or sample_rate doesn’t match the data. The difference is usually obvious. Correct the values until your audio plays back cleanly, then send those same values to the API.