Skip to main content
The endpoint reads the body as it arrives, so a client that uploads during the recording gets its transcript sooner: the connection, authentication, and upload all overlap the recording instead of following it. On a long recording the endpoint can also start transcribing early. Audio is split into speech segments of up to about 32 seconds, and a segment is transcribed once two later segments exist, so early transcription only begins on recordings longer than roughly 90 seconds.

Rules for a chunked upload

Three rules apply to a chunked upload:
  • The config part must arrive before the first audio byte.
  • Don’t let the connection go silent for long stretches mid-body — an abandoned upload is timed out rather than held open. For mute or push-to-talk, end the request when the user stops and start a new one when they resume, rather than pausing the stream.
  • A chunked body can’t be replayed. Keep the audio in memory if you want to retry a failed request.
Raw PCM is the easiest format to stream, since it needs no container header — declare sample_rate and channels in config and send frames as they come off the microphone.

With the Python SDK

The Python SDK does the framing for you. transcribe_live() takes an iterator of audio chunks, and open_live() takes audio pushed in from a callback — a microphone library, a WebRTC track, a telephony media stream:
AsyncDictationTranscriber is the asyncio counterpart, with the same two methods. Call transcriber.warm() when you know audio is coming — as the user reaches for the record button — to pay the DNS, TCP and TLS setup before the first byte rather than in front of it.

With the JavaScript SDK

The JavaScript SDK does the framing for you too. transcribeLive() takes a stream or an async iterable of audio chunks, and openLive() takes audio pushed in from a callback. Both examples record from the default microphone with SoX, so install it first (brew install sox or sudo apt-get install sox):
Call client.dictation.warm() when you know audio is coming to open the connection before the first byte rather than in front of it.

Without the SDK

Without the SDK, frame the multipart body yourself:
Passing a generator to data= makes requests send the body with chunked transfer encoding, which is what lets the upload start before the audio is complete. A body with a Content-Length is also accepted, and still streams — the server does not wait for the full body before it begins.