Prerequisites
Before you start, you’ll need:- pyannoteAI account with credit or active subscription
- An API key from your dashboard
- A publicly accessible audio file URL
1. Diarize API request
Send a POST request to the diarize endpoint with your audio file URL. In our example we use a sample audio file hosted on pyannoteAI servers. Its a 79 second recording with two speakers. You may use this url to test the API:https://files.pyannote.ai/marklex1min.wav
The URL must be a direct link to a publicly accessible audio file. Make sure the URL points directly to the file (e.g., ends with
.wav, .mp3, etc.) and is accessible without authentication.Typically, you’ll use a signed URL from cloud storage such as AWS S3 buckets or other cloud storage services. We also offer our own upload file solution. For details on uploading audio files to our servers, see:diarize.py
jobId that you can use to track the diarization job progress:
Example response
2. Get diarization result
Once you have ajobId, you can retrieve the results using either polling or using webhooks:
Polling
Poll the get job endpoint to check job status and retrieve results when complete.Be cautious of rate limits when polling. Excessive requests can lead to rate
limiting. In production, we strongly recommend using webhooks instead.
polling.py
Webhook
Specify a webhook URL when creating the diarization job to receive results automatically when the job completes.1. Specify your webhook URL
Add thewebhook parameter to your diarization request payload:
diarize_with_webhook.py
2. Create server exposing webhook endpoint
Here we show a simple example of how to expose a server that accepts the webhook POST requests. You can use any web framework of your choice.webhook.py
- Receiving webhooks - Learn about webhook payloads, retries, and failure codes
- Verifying webhooks - Learn how to verify webhook signatures to ensure requests are from pyannoteAI