Skip to main content

Overview

transcribe() needs the whole clip before it can send anything. Live upload starts the request immediately and uploads audio as your code produces it, so authorization, the upload, and every speech segment but the last are done by the time the speaker stops. What is left to wait for is the final segment. The SDKs expose this two ways. Use a session when your audio arrives through a callback — a microphone library, a WebRTC track, a telephony media stream:
Or hand it an iterable or stream you already have, and wait for the result:
Both return the same result as transcribe() and post to POST https://sync.assemblyai.com/v1/transcribe/live.
For short audio onlyLive upload is for short clips: the Sync API caps audio at 120 seconds, and it returns one finished transcript when the audio ends. If you need words back while the speaker is still talking, or you need to capture more than 2 minutes of audio, use the Real-time STT API, which opens a WebSocket connection for up to 3 hours.It is worth using only when the audio is genuinely still being produced — streaming a file that already exists on disk is slower than transcribe(), which sends it in one piece.

Before you begin

To complete this guide, you need:
  • An API key — copy it from API Keys and set it once:
  • A live audio source — a microphone, a recorder process, an in-progress call. This guide uses the microphone.
  • Python 3.8+ for the Python SDK, or Node.js 18+ for the JavaScript SDK.
  • Microphone examples below use sounddevice (Python) and SoX (JavaScript). Any capture library works — all you need is a callback that hands you audio chunks.

Transcribe from a microphone

A capture library calls you back with a chunk of audio each time one is ready. Open a session, write() each chunk from the callback, then close() and collect the result() when the speaker stops. Raw microphone audio is PCM, which carries no header, so set sample_rate and channels on the config.
Leaving the session in the normal way (close(), or the recorder ending) uploads everything you sent. To throw a recording away without transcribing it — the user cancelled, the call dropped — use session.abort() instead; result() then raises.

Pull from a stream you already have

When your audio already comes as something you can iterate — an async generator, a recorder process’s stdout, a ReadableStream — hand it straight to transcribe_live() (Python) / transcribeLive() (JavaScript). It reads the source to the end, then returns the transcript. open_live() is this method with a queue in front of it for callback sources.
The Python method takes any iterable of bytes (synchronous or async, file objects included); AsyncSyncTranscriber.transcribe_live() is the asyncio counterpart. The JavaScript method takes an async iterable, a Node stream, or a web ReadableStream<Uint8Array>. Both reject a whole buffer, a Blob, or a path by name — audio you already hold belongs in transcribe().

What to keep in mind

  • Keep producing until you’re done. An upload that goes silent for too long is aborted server-side. Finish by ending the stream (or calling close()), not by pausing it.
  • The saving comes from overlap. All but the last speech segment are transcribed while you record, so the win grows with clip length. Below roughly a minute there is only one segment, so the only saving is the elided upload.
  • Errors can surface mid-upload. Authorization, rate-limit, and capacity failures can arrive part-way through the upload rather than at the end, as a SyncTranscriptError. Call warm() before you start recording to open the connection ahead of time.
  • The audio limit is unchanged. The Sync API still caps audio at 120 seconds. The default request budget is 180 seconds, covering the recording as well as the transcription.

Next steps

Need help?

If you get stuck, contact our support team at support@assemblyai.com or create a support ticket. Include the session_id from the response to help us look up your request.