Skip to main content

Introduction

Streaming diarization lets you identify who is speaking in real-time over a WebSocket connection. As you stream audio, the API continuously emits speaker turn events, telling you which speaker started or stopped talking and when. Use cases include live captioning, real-time meeting assistants, call center monitoring, and any application that needs to attribute speech to speakers without waiting for the full audio to be recorded.

Auth

All requests to the streaming API require a valid API key. You can generate an API key from your pyannote.ai dashboard. Pass your key as a Bearer token in the Authorization header when creating a stream session.

Quickstart

Getting real-time diarization takes three steps: 1. Create a stream session
Response:
The response contains a single-use url. You can hand this URL directly to your end-user’s client, it only grants access to this one stream and carries no team credentials or API key. 2. Connect to the WebSocket URL Open a WebSocket connection to the url returned above. The connection authenticates automatically via the token embedded in the URL, no additional headers needed.
Cold-starts may delay the WebSocket connection by a few seconds. Wait for the connection to be fully open before sending audio, the open event (or equivalent in your WebSocket client) is your signal that it is safe to start streaming.
3. Stream audio and receive diarization events Send raw audio binary frames over the WebSocket at real-time pace every 100 ms. The server enforces a maximum 5-second buffer; rushing audio ahead of real-time will cause the connection to be closed. The server will emit JSON diarization events as speakers are detected.

Input events

audio_chunk

Send audio as raw binary WebSocket frames. The audio must meet these requirements:
Send raw PCM bytes only — do not include any file headers (e.g. WAV/RIFF headers). The server expects a continuous stream of audio samples with no container or metadata.
The API tracks up to 8 speakers simultaneously. In case the stream involves more speakers, multiple speakers will end up being merged into one.

end_of_stream

When you have no more audio to send, signal the end of the stream by sending a JSON text frame:
Sending this message is optional, but recommended. It tells the server that no more audio frames will be sent, allowing it to finalize diarization and emit any remaining events without waiting for a timeout. The server will then close the connection with close code 1000: normal closure. Do not send further audio frames after end_of_stream. Using this message is recommended over abruptly closing the socket, which may cause final outputs to be lost.

Output events

The server emits JSON text frames with the following event types:

diarization_speaker_start

Emitted when a speaker begins a turn.

diarization_speaker_end

Emitted when a speaker’s turn ends.
timestamp is in seconds, relative to the start of the stream. speaker is a stable string label for the duration of the session.

error

Emitted when the server encounters a problem processing a frame (e.g. wrong chunk size).

Pricing

Streams are billed based on the audio duration sent over the WebSocket connection, with a 20-second minimum per stream. See Billing for details.

Limits

Example: Streaming microphone

Add realtime transcription

Combine streaming diarization with OpenAI realtime transcription to print speaker-attributed transcripts live.