speaker_labels parameter in your request, and then find the results inside a field called utterances.
Get started
Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for a free account and get your API key from your dashboard. The complete source code for this guide can be viewed here. Here is an audio example for this guide:Step-by-step instructions
1
- Python SDK
- Tab Title
Install the SDK.
- Python (requests)
- Python SDK
- JavaScript
2
- Python SDK
- Tab Title
Import the
assemblyai package and set the API key.- Python (requests)
- Python SDK
- JavaScript
3
- Python SDK
- Tab Title
Create a
TranscriptionConfig with speaker_labels set to True.- Python (requests)
- Python SDK
- JavaScript
4
- Python SDK
- Tab Title
Create a
Transcriber object and pass in the configuration.- Python (requests)
- Python SDK
- JavaScript
5
- Python SDK
- Tab Title
Use the
Transcriber object’s transcribe method and pass in the audio file’s
path as a parameter. The transcribe method saves the results of the transcription to the Transcriber object’s transcript attribute.- Python (requests)
- Python SDK
- JavaScript
6
- Python SDK
- Tab Title
You can access the speaker label results through the transcription object’s
utterances attribute.- Python (requests)
- Python SDK
- JavaScript
Understanding the response
The speaker label information is included in theutterances key of the response. Each utterance object in the list includes a speaker field, which contains a string identifier for the speaker (e.g., “A”, “B”, etc.). The utterances list also contains a text field for each utterance containing the spoken text, and confidence scores both for utterances and their individual words.
Specifying the number of speakers
You can provide the optional parameterspeakers_expected, that can be used to specify the expected number of speakers in an audio file.
API/Model Reference