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, the upload is already done. On recordings past roughly 90 seconds, the earlier speech is also already transcribed. 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: it caps audio at 120 seconds, and it returns one finished transcript when the audio ends. For a recording of up to 20 minutes that can wait until the speaker stops, record it first and post it to POST /v1/transcribe over HTTP. If you need words back while the speaker is still talking, or you need to capture more than 20 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. The upload runs while you record, so it is off the critical path. A speech segment is transcribed early once two later segments have arrived, so past roughly 90 seconds of audio the earlier segments are also transcribed while you record. Below that, the 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.
  • Live upload caps audio at 120 seconds. Audio past that is rejected with 413 mid-upload, as soon as it crosses the limit. Over HTTP, POST /v1/transcribe accepts up to 20 minutes. The SDKs time a live request out after 180 seconds by default, covering the recording as well as the transcription; the server allows 300 seconds.

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.