Skip to main content

Overview

transcribe() needs the whole clip before it can send anything. transcribe_live() starts the request on the first chunk and uploads audio as your code produces it, so by the time the speaker stops, most of the work is already done. What is left to wait for is the tail of the audio. Both return the same result 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, an in-progress call, an upload from a browser. This guide uses the microphone.
  • Python 3.8+ for the Python SDK, or Node.js 18+ for the JavaScript SDK.
  • The microphone examples use sounddevice (Python) and SoX (JavaScript). Any source that hands you audio chunks works.

Transcribe live audio

transcribe_live() in Python and transcribeLive() in JavaScript take a source that produces audio over time, upload each chunk as it arrives, and return the transcript once the source ends. Microphone audio is raw PCM with no header, so the config names the sample rate and channel count.
The source is any iterable of bytes. This generator records from the default microphone until you press Enter. The capture callback puts each chunk on a queue and the generator drains it, so recording continues while transcribe_live() is busy on the network. A blocking read() inside the generator would instead overflow the device buffer and silently drop audio whenever the upload stalls:
Run it, say a sentence, and the transcript prints when the recording ends.

Use your own audio source

The call is the same for any source that produces audio over time. Replace the microphone with whatever you already have:
async generators work too, with AsyncSyncTranscriber.transcribe_live().
If your audio arrives through a callback rather than something you can iterate, such as a capture library or a WebRTC track, open a session instead: open_live() returns an object you write() each chunk to and close() when the speaker stops. The Quickstart has a runnable microphone version.
Ending the source normally uploads everything you sent. To throw a recording away without transcribing it, because the user cancelled or the call dropped, use session.abort(); result() then raises.
Audio you already hold in full, such as a buffer, a Blob, or a file on disk, belongs in transcribe(). Streaming a finished clip is slower than sending it whole.

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 source (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.